Definition 1. Matrices of the same shape can be added and subtracted.
Let A and B be r × c matrices with A = [aij] and B = [bij]. Then A + B is an r × c matrix with A + B = [aij + bij] and A – B is an r × c matrix with A – B = [aij – bij].
Definition 2: A matrix can be multiplied (or divided) by a scalar. A scalar can also be added to (or subtracted from) a matrix.
Let A be an r × c matrix with A = [aij] and let b be a scalar. Then bA and A + b are r × c matrices where bA = [b · aij] and A + b = [aij + b]. We can define Ab and b + A in a similar fashion. Clearly, b + A = A + b and Ab = bA. Division and subtraction of matrices by scalars can be defined similarly.
Definition 3: Two matrices can also be multiplied, but only if they have compatible shape.
Let A be a p × m matrix with A = [aij], and let B be an m × n matrix with B = [bjk]. Then AB is an p × n matrix with AB = [cik] where
Observation: For the multiplication AB to be valid, the number of columns in A must equal the number of rows in B. The resulting matrix will have the same number of rows as A and the same number of columns as B.
The associative law holds, namely (AB)C = A(BC), i.e. it doesn’t matter whether you multiply A by B and then multiply the result by C or first multiply B by C and then multiply A by the result. It is essential that the matrices have compatible shape. Thus if A is p × m, B is m × n and C is n × s then ABC will have shape p × s. The distributive laws, namely A(B + C) = AB + BC and (A + B)C = AC + BC, also hold.
The commutative law of addition holds, namely A + B = B + A, but the commutative law of multiplication does not hold even when the matrices have suitable shape; thus, even for two n x n matrices A and B, AB is not necessarily equal to BA. For square matrices the trace of AB is equal to the trace of BA though.
Property 0: For square matrices A and B of the same size and shape and scalar c:
- Trace(A+B) = Trace(B+A)
- Trace(cA) = c Trace(A)
- Trace(AB) = Trace(BA)
Proof: The proofs are straightforward, based on the definition of trace and matrix addition and multiplication.
Definition 4: The transpose of an r × c matrix A = [aij] is the c × r matrix AT = [aji].
A (square) matrix A is symmetric if A = AT
- (AT)T = A
- (AB)T = BTAT
- If A and B are symmetric and AB = BA then AB is symmetric
- Trace(A) = Trace(AT)
Proof: We prove (c). Assume that A and B are symmetric. By Definition 4 and Property 1b, AB = ATBT = (BA)T = (AB)T
Observation: If A is a column vector then ATA is a scalar. In fact, ATA = ‖A‖. Thus, a column vector A is a unit vector if and only if ATA = 1.
Definition 5: An n × n matrix A is invertible (also called non-singular) if there is a matrix B such that AB = BA = In. A-1 is the inverse of A provided AA-1 = A-1A = In. A matrix which is not invertible is called singular.
Property 2: If A is invertible, then the inverse is unique.
Proof: Suppose B and C are inverses of A. Then by the associative law, C = IC = (BA)C = B(AC) = BI = B, and so C = B.
Observation: In fact, if there is a matrix such that AB = In or BA = In then A is invertible and A-1 = B.
Property 3: If A and B are invertible, then (A-1)-1 = A and (AB)-1 = B-1 A-1
Proof: The first assertion results from the first assertion of Property 2.
Since (AB)(B-1A-1) = A(BB-1)A-1,= AIA-1 = AA-1 = I the second assertion follows from the second assertion of Property 2.
Property 4: If A is invertible, then so is its transpose and (AT)-1 = (A-1)T
Proof: By Property 1b, AT(A-1)T = (A-1A)T = IT = I. Similarly, (A-1)TAT = (AA-1)T = IT = I.
Property 5: A is symmetric if and only if A-1 is also symmetric
Proof: Assume A is symmetric, then by Property 4, (A-1)T = (AT)-1 = A-1, and so A-1 is also symmetric. For the converse, assume that A-1 is symmetric, then from the above, it follows that (A-1)-1 is symmetric, but by Property 3, this means that A is symmetric.
Example 1: Find the inverse of
Since the inverse of A takes the form
where AA-1 = I2, it follows that
Thus we need to solve the following four linear equations in four unknowns:
Solving these equations yields a = 2/3, b = -1/3, c = 1/3, d=1/3, and so it follows that
Excel Functions: Excel provides the following array functions to carry out the various matrix operations described above (where we conflate the arrays A and B with the ranges in an Excel worksheet that contain these arrays).
MMULT(A, B): If A is an p × m array and B is an m × n array, then MMULT(A, B) = the p × n matrix AB. Note that since this is an array function, you must first highlight a p × n range before entering =MMULT(A, B) and then you must press Ctrl-Shft-Enter.
MINVERSE(A): If A is an n × n square array, then MINVERSE(A) = A-1. This is an array function and so you must highlight an n × n range before entering =MINVERSE(A) and then pressing Ctrl-Shft-Enter.
TRANSPOSE(A): If A is an m × n array, then TRANSPOSE(A) = AT. This is an array function and so you must highlight an n × m range before entering =TRANSPOSE(A) and then pressing Ctrl-Shft-Enter.
Excel 2013 and Excel 2016 also provide the array function MUNIT(n) which returns the n × n identity matrix.
You can also transpose an array A in Excel by copying the array (i.e. by highlighting the array and pressing Ctrl-C), clicking where you want AT located (i.e. the cell at the upper left corner of AT) and then selecting Home > Clipboard|Paste and choosing the Transpose option.
In addition, if A and B are defined as arrays (e.g. they are named arrays or entities such as B5:F8 or they are the results of matrix operations such as TRANSPOSE, INVERSE or MMULT, then they can be manipulated using the +, -, *, / and ^ operators. These operations are done on a cell by cell basis.
For example, suppose range B2:C3 contains
If you highlight range D7:E8, enter =2*B2:C3+TRANSPOSE(B2:C3) and then press Ctrl-Shft-Enter, D7:E8 will contain
Note that D7:E8 must have the same shape as B2:C3 or an error will result. Note too that
Note too that if A is an m × n matrix and B is a 1 × n matrix (i.e. a row vector) then A + B is a valid operation in Excel and gives the same result as A + C where C is an m × n matrix all of whose rows contain the same data as B. Similarly you can calculate A – B, A*B and A/B. Also, you can calculate A + B, A – B, A*B and A/B where B is an m × 1 column vector.
E.g. Suppose B2:C3 contains and E2:E3 contains . If you highlight F4:G5, enter =B2:C3–E2:E3 and then press Crtl-Shft-Enter, F4:G5 will contain .
Real Statistics Data Analysis Tool: The Real Statistics Resource Pack provides the Matrix Operations data analysis tool, which supports a number of matrix operations. These work just like the corresponding worksheet array functions TRANSPOSE, MINVERSE, etc., except that you don’t need to specify the shape and size of the matrix since these are determined automatically from the shape and size of the input matrix.
Example 2: Perform all the operations supported by the Matrix data analysis tool for the data in Figure 1.
Figure 1 – Data for Example 2
After pressing Ctrl-m and selecting the Matrix option, a dialog box appears. Click on the options shown in Figure 2 when the dialog box appears.
Figure 2 – Dialog box for Example 2
Note that we didn’t select the Eigenvalues/vectors option since the matrix in Figure 1 is not symmetric and so that option is not useful. Instead we chose the Eigenpairs (non-sym) option which will display the eigenvalues and eigenvectors for the matrix in Figure 1 even though it is not symmetric.
The result is shown in Figure 3 and 4 (slightly reformatted).
Figure 3 – Output from Matrix data analysis tool (part 1)
Figure 4 – Output from Matrix data analysis tool (part 2)
Definition 6: Vectors X1, …, Xk of the same size and shape are independent if for any scalar values b1, … bk, if b1 X1 +⋯+ bk Xk = 0, then b1 = … = bk = 0.
Vectors X1, …, Xk are dependent if they are not independent, i.e. there are scalars b1, … bk, at least one of which is non-zero, such that b1 X1 +⋯+ bk Xk = 0.
Observation: If X1, …, Xk are independent, then Xj ≠ 0 for all j.
Property 6: X1, …, Xk are dependent if and only if at least one of the vectors can be expressed as a linear combination of the others.
Proof: Suppose X1, …, Xk are dependent. Then there are scalars b1, … bk, at least one of which is non-zero such that b1 X1 +⋯+ bk Xk = 0. Say bi ≠ 0. Then
Now suppose that Xi = . Then b1 X1 +⋯+ bk Xk = 0, where bi = -1, and so X1, …, Xk are dependent.
Definition 7: The dot product of two vectors X = [xi] and Y = [yj] of the same shape is defined to be the scalar
Observation: If X and Y are n × 1 column vectors, then X∙Y = XTY = YTX. Also ||X|| = √X·X.
Excel Function: If R1 is the range containing the data in X and R2 is the range containing the data in Y then X · Y = SUMPRODUCT(R1, R2).
Definition 8: Two non-null vectors of the same shape are orthogonal if their dot product is 0.