Laws of Matrix Algebra

Back to Intro Math for Econ, Matlab Examples, or MEconTools Repositories

6 Old Rules, 5 Still Apply

We had associative, commutative and distributive laws for scalar algebra, we can think of them as the six bullet points below. Only the multiplicative-commutative law no longer works for matrix, the other rules work for matrix as well as scalar algebra.
Associative laws work as in scalar algebra for matrix
Commutative Law works as well for addition
And Distributive Law still applies to matrix

Example for

% Non-Square
A = rand(2,3)
A = 2×3
0.6959 0.6385 0.0688 0.6999 0.0336 0.3196
B = rand(3,4)
B = 3×4
0.5309 0.8200 0.5313 0.6110 0.6544 0.7184 0.3251 0.7788 0.4076 0.9686 0.1056 0.4235
% This is OK
disp(A*B)
0.8154 1.0960 0.5847 0.9516 0.5238 0.9076 0.4166 0.5891
% This does not work
try
B*A
catch ME
disp('does not work! Dimension mismatch')
end
does not work! Dimension mismatch
 
% Square
A = rand(3,3)
A = 3×3
0.0908 0.2810 0.4574 0.2665 0.4401 0.8754 0.1537 0.5271 0.5181
B = rand(3,3)
B = 3×3
0.9436 0.2407 0.6718 0.6377 0.6761 0.6951 0.9577 0.2891 0.0680
% This is OK
A*B
ans = 3×3
0.7030 0.3441 0.2875 1.3704 0.6147 0.5445 0.9773 0.5431 0.5049
% This works, but result differs from A*B
B*A
ans = 3×3
0.2531 0.7252 0.9904 0.3449 0.8432 1.2437 0.1745 0.4322 0.7263

4 New Rules for Transpose

In scalar algebra, transpose does not make sense. Given matrix A, is the transpose matrix of A where each row of A becomes columns in . If A is M by N, then is N by M.
Given matrix A and scalar value r:
For the 4th rule, suppose matrix A is has L rows and M columns, and the matrix B has M rows and Ncolumns. is a L by N matrix, is a N by L matrix. This is equal to , where we have a N by M matrix multiplied by a M by L matrix , and the resulting matrix is N by L.
A = rand(2,3)
A = 2×3
0.2548 0.6678 0.3445 0.2240 0.8444 0.7805
Atranspose = (A')
Atranspose = 3×2
0.2548 0.2240 0.6678 0.8444 0.3445 0.7805