Appendix A Computer Software
Then each element of C is given by ci j = ai j ±bi j . Matrix addition and subtraction are both commutative, A± B = B± A, and associative, (A± B)±C = A± (B± C). Matrix multiplication is much more complicated though. Suppose we wish to multiply two matrices A and B:
C = A B (A.5) This operation is valid only when the number of columns of A is equal to the number of rows of B (i.e., A and B must be conformable). The resulting matrix C will have rows equal to the number of rows of A and columns equal to the number of columns of B. Thus, if A has dimension m×n and B has dimension n× p, then C will have dimension m× p. The ci j element of C can be determined by
for all i = 1, 2, . . . , m and j = 1, 2, . . . , p. Matrix multiplication is associative, A (B C) = (A B)C , and distributive, A (B+C) = A B+ A C , but not commutative in general, A B = B A. In some cases though if A B = B A, then A and B are said to commute.