LINEAR TRANSFORMATIONS
 

Identity Matrix
Inverse Matrix
Product of a Matrix and a Vector
Rotations
Rotation-Dilations
Orthogonal Projections
Reflections
Determinant and Inverse of a 2x2 Matrix
Matrix Products
Matrix Products
How to Examples Exercise
How to:
Matrix multiplication is very similar to
multiplication of a matrix and a vector, since a vector is just a special type of matrix.

If we want to perform the multiplication, A*B, where A is an MxN matrix, it is necessary that B be of dimensions NxP. You'll notices that the number of columns in A is EQUAL TO the number of rows in B. The 'M' dimension (rows) of A and the 'P' dimension (columns) of B have no correlation other than their influence on the result. So, if we have an MxN matrix, A and an NxP matrix, B, to multiply them together we type:
     C = A*B
Here, the resulting matrix, C is MxP.
NOTE: In this case, it would not be valid to multiply B*A because the number of columns in B (P) is not equal to the number of rows in A (M).

There's an easy way to understand how matrix multiplication works, assuming you understand matrix-vector multiplication. Think of the second matrix, B in this case, as a collection of column vectors, then we can C as a collection of column vectors resulting from the multiplication of A and the column vectors of B. As you can see:
     C(:, 1) = A*B(:, 1)
     C(:, 2) = A*B(:, 2)
     .
     .
     .
     C(:, P) = A*B(:, P)

Or, breaking down each column vector into its individual entries, we have:
     C(i, j) = A(i, 1)*B(1, j) + A(i, 2)*B(2, j) + ... + A(i, N)*B(N, j)
    

Examples:
Let's take this opportunity to learn more about our identity matrix and how it got its name.
Take a matrix R = [1 4; 5 -2] and an identity matrix of the same size, I = eye(2). Since they are square matrices of the same size, we are able to multiply them in either order:
     S = R*I
     T = I*R
You'll notice that our results, S = T = [1 4; 5 -2] are equal, and furthermore, R = S = T. This is because of our identity matrix.
When multiplying any matrix by an identity matrix (or vice-versa), the result will always be the original matrix.

Now let's work with P = [1 3; 2 5] and its inverse matrix, inv(P) = [-5 3; 2 -1]. Again, these are both the same size so we can multiply in either order:
     F = P*inv(P)
     G = inv(P)*P
You'll notice that both our results, F and G are 2x2 identity matrices. This will always be the case.
When multiply any matrix by its inverse (or vice-versa; assuming the inverse exists), the result will always be an identity matrix of the same dimension as the original.

IMPORTANT NOTE: In both our above examples, the multiplication in one order and then the reverse resulted in the same answer. This is NOT always the case. Even if two matrices are square and of the same size, and able to be multiplied in either order, there is NO GUARANTEE that the results will be equal.


Exercise: