Addition, scalar multiplication, matrix-vector products, and dimension checks.
Matrix operations look like ordinary arithmetic, but they have one extra rule: shape matters first. Before adding or multiplying, always check the dimensions.
What you should be able to do
By the end of this lesson, you should be able to:
add matrices of the same shape;
multiply a matrix by a scalar;
decide whether matrix products are defined;
compute matrix-vector products by row dot products;
read a matrix-vector product as a combination of columns;
verify calculations with edumath, NumPy, and SymPy.
Matrix addition
You can add matrices only when they have the same shape. Add matching entries:
So a matrix-vector product is a linear combination of the columns of the matrix. This idea becomes very important when studying systems and transformations.
Matrix-matrix multiplication
A product \(AB\) is defined when the number of columns of \(A\) equals the number of rows of \(B\):
\[
(m\times n)(n\times p) = m\times p.
\]
For example, a \(2\times3\) matrix times a \(3\times4\) matrix produces a \(2\times4\) matrix.
WarningCommon pitfall
Matrix multiplication is not entry-by-entry multiplication. It uses rows of the left matrix and columns of the right matrix. Also, \(AB\) and \(BA\) may be different or one of them may not even be defined.
Worked example: check dimensions first
Can a \(3\times2\) matrix multiply a vector with 2 entries?
The matrix has 2 columns.
The vector has 2 entries.
The inner dimensions match, so the product is defined.
The result has 3 entries because the matrix has 3 rows.
Can a \(3\times2\) matrix multiply a vector with 3 entries? No. The matrix has 2 columns, but the vector has 3 entries.
Checkpoint. Decide whether \(\begin{bmatrix}1&2&3\\4&5&6\end{bmatrix}\) can be added to \(\begin{bmatrix}1&2\\3&4\\5&6\end{bmatrix}\). Explain using shape.
Lab 2: multiply every entry by a scalar
Guess first. If a matrix has one negative entry, can scalar multiplication make it positive?
\((3\times4)(2\times3)\) is not defined because the inner dimensions \(4\) and \(2\) do not match.
Matrix-operation guessing game
Use this game to practice dimension checks and matrix-vector products.
Using this lesson with edumath and SymPy
NumPy is the standard numeric array library in Python. SymPy is better when you want exact symbolic or fractional answers. The edumath helpers keep examples short for lessons.