Use symbolic linear algebraLesson 31 of 48 · 8 min

A matrix acts on a vector

Calculate a matrix-vector product and interpret its rows.

Maths refresher: Rows times columns

Each output entry is a dot product: multiply corresponding entries and add them.

(1201)(34)=(114)\begin{pmatrix}1&2\\0&1\end{pmatrix}\begin{pmatrix}3\\4\end{pmatrix}=\begin{pmatrix}11\\4\end{pmatrix}
Worked example

The first row gives 1⋅3+2⋅4=111\cdot3+2\cdot4=11. The second gives 0⋅3+1⋅4=40\cdot3+1\cdot4=4.

Maths prerequisite map ↗

A matrix is a rectangular arrangement of entries. Multiplying a matrix by a column vector forms one output per row by summing products. This represents a linear transformation when the entries are fixed.

See the mathematics
vAvequal axis scale
vAvequal axis scale
(1201)(34)=(114)\begin{pmatrix}1&2\\0&1\end{pmatrix}\binom34=\binom{11}4
Starter reference. The map shears (3, 4) into (11, 4). Its vertical coordinate is unchanged.

SymPy Matrix uses * for matrix multiplication, while NumPy array * multiplies elements in matching positions. Dimensions must agree: the matrix’s column count matches the vector’s row count. Keep the coordinate order attached to both input and output vectors.

The example shears a two-dimensional vector and then compares two orders of matrix transformations. In general ABAB and BABA differ. An exact symbolic calculation can reveal that order dependence without rounding or a plot.

Will swapping two matrix transformations always leave the same result?

Write a prediction (optional)

Exact symbolic investigation

Select Run Python with the code unchanged.

Tools
About Python

Python and the course packages can load while you read. Each run starts with fresh user variables; imported modules stay loaded. Stop replaces the worker. Runtime details ↗

Ctrl+Enter or ⌘+Enter runs Python.

Compare with the worked example

Executed from the published Python during the site build. Your own run appears above. Build environment ↗

A
[1201]\left[\begin{matrix}1 & 2\\0 & 1\end{matrix}\right]
Input vector
[34]\left[\begin{matrix}3\\4\end{matrix}\right]
A acting on v
[114]\left[\begin{matrix}11\\4\end{matrix}\right]
A then B
[2223]\left[\begin{matrix}22\\23\end{matrix}\right]
B then A
[3615]\left[\begin{matrix}36\\15\end{matrix}\right]
Worked text output
A: Matrix([[1, 2], [0, 1]])
Input vector: Matrix([[3], [4]])
A acting on v: Matrix([[11], [4]])
A then B: Matrix([[22], [23]])
B then A: Matrix([[36], [15]])

Read the starter result

Read A acting on v and compare A then B with B then A. In a product applied to a vector, the transformation nearest the vector acts first.

Edit and compare

Replace v = sp.Matrix([3,4]) with v = sp.Matrix([1,0]) and select Run Python. Then use v = sp.Matrix([0,1]) and select Run Python again. Match each A acting on v vector to a column of A.

Return to the editor

Scope. A matrix model needs meaningful coordinates and units; multiplication alone does not establish a real transformation’s validity.

Try a fresh case

For a 2×3 matrix multiplied by a column vector, what input size is required?

Choose an answer
Need a hint?
Hint 1

Match the inner dimensions.

Hint 2

The output size follows the number of matrix rows.

Your notesNotes save in this browser when storage is available.