Skip to the lesson
FixTheRobot Explore Robotics / Linear Algebra / M2 Matrices and Linear Transformations / M2-T3

Linear Algebra · Theory · M2

M2-T3 — Matrix-Vector Multiplication

A matrix times a vector is the operation robots perform thousands of times per second. It has two readings, and fluent engineers use both.

  • Lesson 3 of 7
  • Module 2: Matrices and Linear Transformations
  • Matrices
  • About 9 minutes to read

Converting wheel speeds into body motion, rotating a LiDAR point into the robot frame, mapping joint rates to hand velocity: each is a matrix times a vector. Understanding the product as a mix of columns will make every later idea in this course easier.

Learning objectives

After this lesson, you should be able to:

  • Compute A x using the row view (each output is a row dotted with x) and the column view (a combination of the columns of A).
  • Explain why the two views always agree, with a short derivation.
  • State the two linearity properties A(x + y) = Ax + Ay and A(cx) = cAx.
  • Use a matrix-vector product to convert robot quantities such as wheel speeds and sensor measurements.

Introduction and motivation

Every time a robot converts one set of numbers into another by a fixed linear rule, it multiplies a matrix by a vector: wheel speeds into body velocity, joint rates into hand velocity, a raw sensor reading into robot coordinates. The product is so central that seeing it two ways is worth the time. The row view is how you compute; the column view is how you think.

The intuition

Take A x where x = (x₁, x₂). The row view: each entry of the answer is a row of A dotted with x. That is the recipe a computer follows, and it uses only the dot product you already know.

The column view: the answer is x₁ times the first column of A plus x₂ times the second column. In words, the entries of x say how much of each column to mix. The input vector is a recipe, the columns are the ingredients, and the output is the finished mixture.

Interactive figure. The matrix-vector product A x drawn as a combination of columns: the first column scaled by x₁, then the second column scaled by x₂ placed head to tail, ending at A x. The readout shows the row view giving the same numbers. This figure needs JavaScript to be interactive.

Drag the blue handle to change x₁ and the gold handle to change x₂. The green arrow A x is always the first column stretched by x₁ plus the second column stretched by x₂, placed head to tail.
Wheel speeds to body motionA differential-drive robot. The two wheel angular speeds form a vector. A two by two matrix built from the wheel radius and the track width turns it into forward speed and turn rate.0.050.05−0.250.25J × 810wheel speeds(ωL, ωR) rad/s = 0.90.5body motion(v m/s, ω rad/s) row 1: v = 0.05·8 + 0.05·10 = 0.9 row 2: ω = −0.25·8 + 0.25·10 = 0.5 wheel radius r = 0.1 m, track width L = 0.4 m J = [[r/2, r/2], [−r/L, r/L]]
A differential-drive robot: wheel speeds (8, 10) rad/s become a forward speed of 0.9 m/s and a turn rate of 0.5 rad/s through a single matrix-vector product.

Geometric and physical interpretation

Geometric view. The set of all outputs A x (as x varies) is everything you can build from the columns: for two independent columns in the plane, that is the whole plane; for dependent columns, only a line. Whether a target output is reachable is therefore a question about the columns, the heart of Module 3. Physical view. In the drive example, the first column says what one rad/s of left-wheel speed does to the body (it moves forward a little and turns the robot to the right), and the second column says what the right wheel does (forward and to the left). Real motion is a mix of the two.

The mathematics

A
an m × n matrix with columns a₁, …, an.
x
a vector with n entries x₁, …, xn (the “input”).
A x
the m-entry vector of outputs.

The row view

(A x)i = ai1·x1 + ai2·x2 + ... + ain·xn = (row i of A) · x

What it means. Each output entry is one dot product. In a robot, each row is one formula: “forward speed equals this weighted sum of the wheel speeds”.

The column view

A x = x1·a1 + x2·a2 + ... + xn·an

What it means. The output is a combination of the columns of A, with the entries of x as the weights. This is the view that tells you what outputs are possible.

Linearity

A(x + y) = A x + A y            A(c x) = c (A x)

What it means. Mixing two inputs mixes the outputs the same way, and doubling the input doubles the output. These two rules are what “linear” means; they are why a robot's response to a combination of commands is the combination of the responses.

Row view for computing, column view for understanding. Both give the same vector.

Step-by-step derivation: the column view follows from the row view

Start from the row view for a 2 × 2 matrix A = [[a, b], [c, d]] and x = (x₁, x₂). Then A x = (a x₁ + b x₂, c x₁ + d x₂).

  1. Split each entry into the part that comes from x₁ and the part that comes from x₂: A x = (a x₁, c x₁) + (b x₂, d x₂).
  2. Factor the scalars out of each vector: (a x₁, c x₁) = x₁ (a, c) and (b x₂, d x₂) = x₂ (b, d).
  3. Recognise that (a, c) is the first column of A and (b, d) is the second: A x = x₁·(first column) + x₂·(second column).

The same three steps work for any size, giving A x = x₁a₁ + … + xnan.

Linearity follows from the column view. For the sum: A(x + y) = Σ (xj + yj) aj = Σ xjaj + Σ yjaj = A x + A y. For scaling: A(cx) = Σ (c xj) aj = c Σ xjaj = c A x.

Two consequences: A 0 = 0 (the zero input gives the zero output, so a linear map cannot shift the origin) and A ej = aj (feeding the j-th unit vector returns the j-th column). The second fact is the key to the next lesson.

A worked example: both views, and a robot drive

Both views. Let A = [[2, 1], [0.5, 2]] and x = (1.5, 1).

  1. Row view. Row 1: 2·1.5 + 1·1 = 4. Row 2: 0.5·1.5 + 2·1 = 2.75. So A x = (4, 2.75).
  2. Column view. 1.5·(2, 0.5) + 1·(1, 2) = (3, 0.75) + (1, 2) = (4, 2.75). The same answer.
  3. Linearity. For x = (1, 0) and y = (0, 1), A x = (2, 0.5) and A y = (1, 2), so A x + A y = (3, 2.5); and A (x + y) = A (1, 1) = (3, 2.5).

A differential-drive robot. With wheel radius r = 0.1 m and track width L = 0.4 m, the forward speed is v = (r/2)(ωL + ωR) and the turn rate is ω = (r/L)(ωR − ωL). As a matrix, J = [[0.05, 0.05], [−0.25, 0.25]]. For wheel speeds (ωL, ωR) = (8, 10) rad/s: v = 0.05·8 + 0.05·10 = 0.9 m/s and ω = −0.25·8 + 0.25·10 = 0.5 rad/s. A faster right wheel turns the robot to the left, as expected.

A sensor measurement. A LiDAR point at (2, 0) in a sensor frame rotated by 30° relative to the robot frame becomes, in robot coordinates, (2 cos 30°, 2 sin 30°) = (1.732, 1.000): a matrix times a vector with the rotation matrix of the next modules.

Robotics application

Drive kinematics. The mapping from wheel speeds to body velocity is the matrix above, and inverting it gives the wheel speeds needed for a desired motion. The Navigation track starts from this model in robot motion models for navigation.

Transforming measurements. A matrix converts sensor readings into robot coordinates (a rotation), rescales units (a diagonal matrix), or corrects a known sensor distortion. The column view tells you what a calibration does: its columns are where the sensor's own axes land in robot coordinates.

Joint rates to hand velocity. In Module 8 the Jacobian J turns joint velocities q̇ into hand velocity ẋ = J q̇. Its columns are the contribution of each joint, which is the column view exactly.

Estimation. A measurement model z = H x predicts what a sensor would read for a state x; this is the matrix-vector product inside every Kalman filter (see the UAV error-state Kalman filter lesson).

Engineering implications and limitations

Practical rules

  • Shapes first. A is m × n and x must have n entries; the answer has m entries. A mismatch is a bug, not a rounding problem.
  • 1D arrays are not column vectors. In NumPy a shape-(n,) array works with A @ x but behaves differently from a shape-(n, 1) array in broadcasting. Be explicit about which you use.
  • Do not form the matrix when you only need the product. For a chain, apply each matrix to the vector in turn; for a rotation by a known angle, use the cosine and sine directly.
  • Units live inside the matrix. In the drive matrix, the entries have units (metres per radian for the first row, one over metres for the second). A matrix with mixed units is normal; adding rows of different units is not.
  • Only linear relationships are matrices. A translation (adding an offset) is not a matrix-vector product, since A 0 = 0. Module 7 shows how to include translations with one extra coordinate.

Limits

The drive model above assumes no wheel slip and a rigid body: real wheels slip, so the true relation is only approximately linear. Treat the matrix as a model, and test it by comparing predicted and measured motion.

Common misconceptions

“A x is a number.”

A x is a vector with as many entries as A has rows. Only a row times a column (a dot product) is a single number.

“I can write x A for A x.”

The shapes only work one way: an n × 1 column cannot be multiplied on the left of an m × n matrix. (If x is stored as a row, you need x Aᵀ.)

“A matrix always makes vectors longer.”

It can stretch some directions, shrink others, or collapse a direction to zero. Whether lengths are preserved depends on the matrix; rotations preserve them, a diagonal scaling does not.

“The columns of A are the rows of Aᵀ, so reading columns is a trick.”

Reading the columns is the point: they are the outputs for the unit inputs, and any other output is a mix of them.

Engineering takeaways

  1. The row view computes A x one dot product at a time; the column view builds it as x₁a₁ + … + xnan.
  2. The two views are the same calculation grouped differently, as the derivation shows.
  3. A x is linear: A(x + y) = Ax + Ay and A(cx) = cAx, which also forces A0 = 0.
  4. Feeding the unit vectors returns the columns, so the columns of a matrix are its responses to the basic inputs.
  5. Wheel speeds to body velocity, sensor frame to robot frame and joint rates to hand velocity are all matrix-vector products.

References and further reading

Primary papers and authoritative documentation.

Knowledge check

Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

For A = [[1, 2], [3, 4]] and x = (1, −1), compute A x with the row view and with the column view and confirm that they agree.

Explanation

Row view: row 1 · x = 1·1 + 2·(−1) = −1 and row 2 · x = 3·1 + 4·(−1) = −1, so A x = (−1, −1). Column view: 1·(1, 3) + (−1)·(2, 4) = (1, 3) + (−2, −4) = (−1, −1). The two views are the same calculation grouped differently, so they must agree.

Question 2

A differential-drive robot has J = [[0.05, 0.05], [−0.25, 0.25]]. What wheel speeds (ωL, ωR) make it turn on the spot (v = 0) at ω = 0.5 rad/s? Which column view fact lets you see this without a calculation?

Explanation

v = 0.05(ωL + ωR) = 0 requires ωR = −ωL, and ω = 0.25(ωR − ωL) = 0.5 then gives ωR − ωL = 2, so ωL = −1 and ωR = +1 rad/s. In the column view the two columns are (0.05, −0.25) and (0.05, 0.25): adding equal and opposite multiples of them cancels the forward parts (the 0.05s) and doubles the turning parts, so opposite wheel speeds give a pure turn.

Question 3

Why can a matrix-vector product never move the origin, and what does this imply for representing a translation?

Explanation

Linearity gives A 0 = A(0·0) = 0·(A 0) = 0, so the zero vector always maps to the zero vector. A translation adds a fixed offset and moves the origin, so it is not a matrix-vector product in the plane. Module 7 solves this by adding a constant coordinate (homogeneous coordinates), which turns translations into matrices in one dimension higher.

What’s next

You can now compute and read A x. Next you will see that every such matrix is a transformation of the plane, completely described by where it sends the two basic arrows.

Next lesson

M2-T4 — Matrices as Linear Transformations

Read the columns of a matrix as where the basis vectors land, and recognise scaling, rotation, reflection and shear.

Nothing below is required to finish this lesson.