Differential Equations for EngineersXYZ Homework Edition

⇩ Download ▾

A.2 Matrix Algebra

One-by-One Matrices

Let us motivate what we want to achieve with matrices. Real-valued linear mappings of the real line, linear functions that eat numbers and spit out numbers, are just multiplications by a number. Consider a mapping defined by multiplying by a number. Let’s call this number α\alpha. The mapping then takes xx to αx\alpha x. We can add such mappings: If we have another mapping β\beta, then

αx+βx=(α+β)x.\alpha x + \beta x = (\alpha + \beta) x. \nonumber

We get a new mapping α+β\alpha+\beta that multiplies xx by, well, α+β\alpha+\beta. If DD is a mapping that doubles its input, Dx=2xDx = 2x, and TT is a mapping that triples, Tx=3xTx = 3x, then D+TD+T is a mapping that multiplies by 55, (D+T)x=5x(D+T)x = 5x.

Similarly we can compose such mappings, that is, we could apply one and then the other. We take xx, we run it through the first mapping α\alpha to get α\alpha times xx, then we run αx\alpha x through the second mapping β\beta. In other words,

β(αx)=(βα)x.\beta ( \alpha x ) = (\beta \alpha) x. \nonumber

We just multiply those two numbers. Using our doubling and tripling mappings, if we double and then triple, that is T(Dx)T(Dx) then we obtain 3(2x)=6x3(2x) = 6x. The composition TDTD is the mapping that multiplies by 66. For larger matrices, composition also ends up being a kind of multiplication.

Matrix Addition and Scalar Multiplication

The mappings that multiply numbers by numbers are just 1×11 \times 1 matrices. The number α\alpha above could be written as a matrix [α][\alpha]. Perhaps we would want to do to all matrices the same things that we did to those 1×11 \times 1 matrices at the start of this section above. First, let us add matrices. If we have a matrix AA and a matrix BB that are of the same size, say m×nm \times n, then they are mappings from n{\mathbb{R}}^n to m{\mathbb{R}}^m. The mapping A+BA+B should also be a mapping from n{\mathbb{R}}^n to m{\mathbb{R}}^m, and it should do the following to vectors:

(A+B)x=Ax+Bx.(A+B) \vec{x} = A\vec{x} + B \vec{x}. \nonumber

It turns out you just add the matrices element-wise: If the ijthij^{\text{th}} entry of AA is aija_{ij}, and the ijthij^{\text{th}} entry of BB is bijb_{ij}, then the ijthij^{\text{th}} entry of A+BA+B is aij+bija_{ij} + b_{ij}. If

A=[a11a12a13a21a22a23]andB=[b11b12b13b21b22b23],A = \begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \end{bmatrix} \qquad \text{and} \qquad B = \begin{bmatrix} b_{11} & b_{12} & b_{13} \\ b_{21} & b_{22} & b_{23} \end{bmatrix}, \nonumber

then

A+B=[a11+b11a12+b12a13+b13a21+b21a22+b22a23+b23].A+B = \begin{bmatrix} a_{11} + b_{11} & a_{12} + b_{12} & a_{13} + b_{13} \\ a_{21} + b_{21} & a_{22} + b_{22} & a_{23} + b_{23} \end{bmatrix}. \nonumber

Let us illustrate on a more concrete example:

[123456]+[78910111]=[1+72+83+94+105+1161]=[8101214165].\begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \end{bmatrix} + \begin{bmatrix} 7 & 8 \\ 9 & 10 \\ 11 & -1 \end{bmatrix} = \begin{bmatrix} 1+7 & 2+8 \\ 3+9 & 4+10 \\ 5+11 & 6-1 \end{bmatrix} = \begin{bmatrix} 8 & 10 \\ 12 & 14 \\ 16 & 5 \end{bmatrix}. \nonumber

Let’s check that this does the right thing to a vector. Let’s use some of the vector algebra that we already know, and regroup things:

[ 1 2 3 4 5 6 ] [ 2 1 ] + [ 7 8 9 10 11 1 ] [ 2 1 ] = ( 2 [ 1 3 5 ] [ 2 4 6 ] ) + ( 2 [ 7 9 11 ] [ 8 10 1 ] ) = 2 ( [ 1 3 5 ] + [ 7 9 11 ] ) ( [ 2 4 6 ] + [ 8 10 1 ] ) = 2 [ 1 + 7 3 + 9 5 + 11 ] [ 2 + 8 4 + 10 6 1 ] = 2 [ 8 12 16 ] [ 10 14 5 ] = [ 8 10 12 14 16 5 ] [ 2 1 ] ( = [ 2 ( 8 ) 10 2 ( 12 ) 14 2 ( 16 ) 5 ] = [ 6 10 27 ] ) . \begin{align}\begin{aligned} \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \end{bmatrix} \begin{bmatrix} 2 \\ -1 \end{bmatrix} + \begin{bmatrix} 7 & 8 \\ 9 & 10 \\ 11 & -1 \end{bmatrix} \begin{bmatrix} 2 \\ -1 \end{bmatrix} & = \left( 2 \begin{bmatrix} 1 \\ 3 \\ 5 \end{bmatrix} - \begin{bmatrix} 2 \\ 4 \\ 6 \end{bmatrix} \right) + \left( 2 \begin{bmatrix} 7 \\ 9 \\ 11 \end{bmatrix} - \begin{bmatrix} 8 \\ 10 \\ -1 \end{bmatrix} \right) \\ & = 2 \left( \begin{bmatrix} 1 \\ 3 \\ 5 \end{bmatrix} + \begin{bmatrix} 7 \\ 9 \\ 11 \end{bmatrix} \right) - \left( \begin{bmatrix} 2 \\ 4 \\ 6 \end{bmatrix} + \begin{bmatrix} 8 \\ 10 \\ -1 \end{bmatrix} \right) \\ & = 2 \begin{bmatrix} 1+7 \\ 3+9 \\ 5+11 \end{bmatrix} - \begin{bmatrix} 2+8 \\ 4+10 \\ 6-1 \end{bmatrix} = 2 \begin{bmatrix} 8 \\ 12 \\ 16 \end{bmatrix} - \begin{bmatrix} 10 \\ 14 \\ 5 \end{bmatrix} \\ & = \begin{bmatrix} 8 & 10 \\ 12 & 14 \\ 16 & 5 \end{bmatrix} \begin{bmatrix} 2 \\ -1 \end{bmatrix} \quad \left( = \begin{bmatrix} 2(8)- 10 \\ 2(12) - 14 \\ 2(16) - 5 \end{bmatrix} = \begin{bmatrix} 6 \\ 10 \\ 27 \end{bmatrix} \right). \end{aligned}\end{align} \nonumber

If we replaced the numbers by letters that would constitute a proof! You’ll notice that we didn’t really have to even compute what the result is to convince ourselves that the two expressions were equal.

If the sizes of the matrices do not match, then addition is not defined. If AA is 3×23 \times 2 and BB is 2×52 \times 5, then we cannot add these matrices. We don’t know what that could possibly mean.

It is also useful to have a matrix that when added to any other matrix does nothing. This is the zero matrix, the matrix of all zeros:

[1234]+[0000]=[1234].\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} + \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}. \nonumber

We often denote the zero matrix by 00 without specifying size. We would then just write A+0A + 0, where we just assume that 00 is the zero matrix of the same size as AA.

There are really two things we can multiply matrices by. We can multiply matrices by scalars or we can multiply by other matrices. Let us first consider multiplication by scalars. For a matrix AA and a scalar α\alpha, we want αA\alpha A to be the matrix that accomplishes

(αA)x=α(Ax).(\alpha A) \vec{x} = \alpha (A \vec{x}). \nonumber

That is just scaling the result by α\alpha. If you think about it, scaling every term in AA by α\alpha achieves just that: If

A=[a11a12a13a21a22a23],thenαA=[αa11αa12αa13αa21αa22αa23].A = \begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \end{bmatrix}, \qquad\text{then} \qquad \alpha A = \begin{bmatrix} \alpha a_{11} & \alpha a_{12} & \alpha a_{13} \\ \alpha a_{21} & \alpha a_{22} & \alpha a_{23} \end{bmatrix}. \nonumber

For example,

2[123456]=[24681012].2 \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} = \begin{bmatrix} 2 & 4 & 6 \\ 8 & 10 & 12 \end{bmatrix}. \nonumber

Let us list some properties of matrix addition and scalar multiplication. Denote by 00 the zero matrix, by α\alpha, β\beta scalars, and by AA, BB, CC matrices. Then:

A+0=A=0+A,A+B=B+A,(A+B)+C=A+(B+C),α(A+B)=αA+αB,(α+β)A=αA+βA.\begin{align}\begin{aligned} A + 0 & = A = 0 + A, \\ A + B & = B + A, \\ (A + B) + C & = A + (B + C), \\ \alpha(A+B) & = \alpha A+\alpha B, \\ (\alpha+\beta)A & = \alpha A + \beta A.\end{aligned}\end{align} \nonumber

These rules should look very familiar.

Matrix Multiplication

As we mentioned above, composition of linear mappings is also a multiplication of matrices. Suppose AA is an m×nm \times n matrix, that is, AA takes Rn{\mathbb R}^n to Rm{\mathbb R}^m, and BB is an n×pn \times p matrix, that is, BB takes Rp{\mathbb R}^p to Rn{\mathbb R}^n. The composition ABAB should work as follows

ABx=A(Bx).AB\vec{x} = A(B\vec{x}). \nonumber

First, a vector x\vec{x} in Rp{\mathbb R}^p gets taken to the vector BxB\vec{x} in Rn{\mathbb R}^n. Then the mapping AA takes it to the vector A(Bx)A(B\vec{x}) in Rm{\mathbb R}^m. In other words, the composition ABAB should be an m×pm \times p matrix. In terms of sizes we should have

"[m×n][n×p]=[m×p].""\quad [m\times n]\: [n\times p]=[m\times p].\quad " \nonumber

Notice how the middle size must match.

OK, now we know what sizes of matrices we should be able to multiply, and what the product should be. Let us see how to actually compute matrix multiplication. We start with the so-called dot product (or inner product) of two vectors. Usually this is a row vector multiplied with a column vector of the same size. Dot product multiplies each pair of entries from the first and the second vector and sums these products. The result is a single number. For example,

[a1a2a3]·[b1b2b3]=a1b1+a2b2+a3b3.\begin{bmatrix} a_1 & a_2 & a_3 \end{bmatrix} \cdot \begin{bmatrix} b_1 \\ b_2 \\ b_3 \end{bmatrix} = a_1 b_1 + a_2 b_2 + a_3 b_3. \nonumber

And similarly for larger (or smaller) vectors. A dot product is really a product of two matrices: a 1×n1 \times n matrix and an n×1n \times 1 matrix resulting in a 1×11 \times 1 matrix, that is, a number.

Armed with the dot product we define the product of matrices. We denote by rowi(A)\operatorname{row}_i(A) the ithi^{\text{th}} row of AA and by columnj(A)\operatorname{column}_j(A) the jthj^{\text{th}} column of AA. For an m×nm \times n matrix AA and an n×pn \times p matrix BB we can compute the product ABAB: The matrix ABAB is an m×pm \times p matrix whose ijthij^{\text{th}} entry is the dot product

rowi(A)·columnj(B).\operatorname{row}_i(A) \cdot \operatorname{column}_j(B). \nonumber

For example, given a 2×32 \times 3 and a 3×23 \times 2 matrix we should end up with a 2×22 \times 2 matrix:

[a11a12a13a21a22a23][b11b12b21b22b31b32]=[a11b11+a12b21+a13b31a11b12+a12b22+a13b32a21b11+a22b21+a23b31a21b12+a22b22+a23b32],\label{eq:1} \begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \end{bmatrix} \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \\ b_{31} & b_{32} \end{bmatrix} = \begin{bmatrix} a_{11} b_{11} + a_{12} b_{21} + a_{13} b_{31} & & a_{11} b_{12} + a_{12} b_{22} + a_{13} b_{32} \\ a_{21} b_{11} + a_{22} b_{21} + a_{23} b_{31} & & a_{21} b_{12} + a_{22} b_{22} + a_{23} b_{32} \end{bmatrix},

(9.2.1)
or with some numbers:

[123456][127011]=[1·(1)+2·(7)+3·11·2+2·0+3·(1)4·(1)+5·(7)+6·14·2+5·0+6·(1)]=[121332].\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} \begin{bmatrix} -1 & 2 \\ -7 & 0 \\ 1 & -1 \end{bmatrix} = \begin{bmatrix} 1\cdot (-1) + 2\cdot (-7) + 3 \cdot 1 & & 1\cdot 2 + 2\cdot 0 + 3 \cdot (-1) \\ 4\cdot (-1) + 5\cdot (-7) + 6 \cdot 1 & & 4\cdot 2 + 5\cdot 0 + 6 \cdot (-1) \end{bmatrix} = \begin{bmatrix} -12 & -1 \\ -33 & 2 \end{bmatrix}. \nonumber

A useful consequence of the definition is that the evaluation AxA \vec{x} for a matrix AA and a (column) vector x\vec{x} is also matrix multiplication. That is really why we think of vectors as column vectors, or n×1n \times 1 matrices. For example,

[1234][21]=[1·2+2·(1)3·2+4·(1)]=[02].\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \begin{bmatrix} 2 \\ -1 \end{bmatrix} = \begin{bmatrix} 1 \cdot 2 + 2 \cdot (-1) \\ 3 \cdot 2 + 4 \cdot (-1) \end{bmatrix} = \begin{bmatrix} 0 \\ 2 \end{bmatrix}. \nonumber

If you look at the last section, that is precisely the last example we gave.

You should stare at the computation of multiplication of matrices ABAB and the previous definition of AyA\vec{y} as a mapping for a moment. What we are doing with matrix multiplication is applying the mapping AA to the columns of BB. This is usually written as follows. Suppose we write the n×pn \times p matrix B=[b1b2bp]B = [ \vec{b}_1 ~ \vec{b}_2 ~ \cdots ~ \vec{b}_p ], where b1,b2,,bp\vec{b}_1, \vec{b}_2, \ldots, \vec{b}_p are the columns of BB. Then for an m×nm \times n matrix AA,

AB=A[b1b2bp]=[Ab1Ab2Abp].AB = A [ \vec{b}_1 ~ \vec{b}_2 ~ \cdots ~ \vec{b}_p ] = [ A\vec{b}_1 ~ A\vec{b}_2 ~ \cdots ~ A\vec{b}_p ]. \nonumber

The columns of the m×pm \times p matrix ABAB are the vectors Ab1,Ab2,,AbpA\vec{b}_1, A\vec{b}_2, \ldots, A\vec{b}_p. For example, in (9.2.1), the columns of

[a11a12a13a21a22a23][b11b12b21b22b31b32]\begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \end{bmatrix} \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \\ b_{31} & b_{32} \end{bmatrix} \nonumber

are

[a11a12a13a21a22a23][b11b21b31]and[a11a12a13a21a22a23][b12b22b32].\begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \end{bmatrix} \begin{bmatrix} b_{11} \\ b_{21} \\ b_{31} \end{bmatrix} \qquad \text{and} \qquad \begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \end{bmatrix} \begin{bmatrix} b_{12} \\ b_{22} \\ b_{32} \end{bmatrix}. \nonumber

This is a very useful way to understand what matrix multiplication is. It should also make it easier to remember how to perform matrix multiplication.

Rules of Matrix Algebra

For multiplication we want an analogue of a 1. That is, we desire a matrix that just leaves everything as it found it. This analogue is the so-called identity matrix. The identity matrix is a square matrix with 1s on the main diagonal and zeros everywhere else. It is usually denoted by II. For each size we have a different identity matrix and so sometimes we may denote the size as a subscript. For example, I3I_3 is the 3×33 \times 3 identity matrix

I=I3=[100010001].I = I_3 = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}. \nonumber

Let us see how the matrix works on a smaller example,

[a11a12a21a22][1001]=[a11·1+a12·0a11·0+a12·1a21·1+a22·0a21·0+a22·1]=[a11a12a21a22].\begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} = \begin{bmatrix} a_{11} \cdot 1 + a_{12} \cdot 0 & & a_{11} \cdot 0 + a_{12} \cdot 1 \\ a_{21} \cdot 1 + a_{22} \cdot 0 & & a_{21} \cdot 0 + a_{22} \cdot 1 \end{bmatrix} = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}. \nonumber

Multiplication by the identity from the left looks similar, and also does not touch anything.

We have the following rules for matrix multiplication. Suppose that AA, BB, CC are matrices of the correct sizes so that the following make sense. Let α\alpha denote a scalar (number). Then

A(BC)=(AB)C(associative law),A(B+C)=AB+AC(distributive law),(B+C)A=BA+CA(distributive law),α(AB)=(αA)B=A(αB),IA=A=AI(identity).\begin{align}\begin{aligned} A(BC) & = (AB)C & & \text{(associative law)}, \\ A(B+C) & = AB + AC & & \text{(distributive law)}, \\ (B+C)A & = BA + CA & & \text{(distributive law)}, \\ \alpha(AB) & = (\alpha A)B = A(\alpha B), & & \\ IA & = A = AI & & \text{(identity)}.\end{aligned}\end{align} \nonumber

A multiplication rule, one you have used since primary school on numbers, is quite conspicuously missing for matrices. That is, matrix multiplication is not commutative. Firstly, just because ABAB makes sense, it may be that BABA is not even defined. For example, if AA is 2×32 \times 3, and BB is 3×43 \times 4, the we can multiply ABAB but not BABA.

Even if ABAB and BABA are both defined, does not mean that they are equal. For example, take A=[1111]A = \left[ \begin{smallmatrix} 1 & 1 \\ 1 & 1 \end{smallmatrix} \right] and B=[1002]B = \left[ \begin{smallmatrix} 1 & 0 \\ 0 & 2 \end{smallmatrix} \right]:

AB=[1111][1002]=[1212]=[1122]=[1002][1111]=BA.AB = \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 \\ 0 & 2 \end{bmatrix} = \begin{bmatrix} 1 & 2 \\ 1 & 2 \end{bmatrix} \qquad \not= \qquad \begin{bmatrix} 1 & 1 \\ 2 & 2 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 2 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} = BA. \nonumber

Inverse

A couple of other algebra rules you know for numbers do not quite work on matrices:

  1. AB=ACAB = AC does not necessarily imply B=CB=C, even if AA is not 0.
  2. AB=0AB = 0 does not necessarily mean that A=0A=0 or B=0B=0.

For example:

[0100][0100]=[0000]=[0100][0200].\begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} \begin{bmatrix} 0 & 2 \\ 0 & 0 \end{bmatrix}. \nonumber

To make these rules hold, we do not just need one of the matrices to not be zero, we would need to by a matrix. This is where the matrix inverse comes in. Suppose that AA and BB are n×nn \times n matrices such that

AB=I=BA.AB = I = BA. \nonumber

Then we call BB the inverse of AA and we denote BB by A1A^{-1}. Perhaps not surprisingly, (A1)1=A{(A^{-1})}^{-1} = A, since if the inverse of AA is BB, then the inverse of BB is AA. If the inverse of AA exists, then we say AA is invertible. If AA is not invertible, we say AA is singular.

If A=[a]A = [a] is a 1×11 \times 1 matrix, then A1A^{-1} is a1=1aa^{-1} = \frac{1}{a}. That is where the notation comes from. The computation is not nearly as simple when AA is larger.

The proper formulation of the cancellation rule is:

If AA is invertible, then AB=ACAB = AC implies B=CB=C.

The computation is what you would do in regular algebra with numbers, but you have to be careful never to commute matrices:

AB=AC,A1AB=A1AC,IB=IC,B=C.\begin{align}\begin{aligned} AB & = AC, \\ A^{-1}AB & = A^{-1}AC, \\ IB & = IC, \\ B & = C.\end{aligned}\end{align} \nonumber

And similarly for cancellation on the right:

If AA is invertible, then BA=CABA = CA implies B=CB=C.

The rule says, among other things, that the inverse of a matrix is unique if it exists: If AB=I=ACAB = I = AC, then AA is invertible and B=CB=C.

We will see later how to compute an inverse of a matrix in general. For now, let us note that there is a simple formula for the inverse of a 2×22 \times 2 matrix

[abcd]1=1adbc[dbca].\begin{bmatrix} a & b \\ c & d \end{bmatrix}^{-1} = \frac{1}{ad-bc} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}. \nonumber

For example:

[1124]1=11·41·2[4121]=[212112].\begin{bmatrix} 1 & 1 \\ 2 & 4 \end{bmatrix}^{-1} = \frac{1}{1\cdot 4-1 \cdot 2} \begin{bmatrix} 4 & -1 \\ -2 & 1 \end{bmatrix} = \begin{bmatrix} 2 & \frac{-1}{2} \\ -1 & \frac{1}{2} \end{bmatrix}. \nonumber

Let’s try it:

[1124][212112]=[1001]and[212112][1124]=[1001].\begin{bmatrix} 1 & 1 \\ 2 & 4 \end{bmatrix} \begin{bmatrix} 2 & \frac{-1}{2} \\ -1 & \frac{1}{2} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \qquad \text{and} \qquad \begin{bmatrix} 2 & \frac{-1}{2} \\ -1 & \frac{1}{2} \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 2 & 4 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}. \nonumber

Just as we cannot divide by every number, not every matrix is invertible. In the case of matrices however we may have singular matrices that are not zero. For example,

[1122]\begin{bmatrix} 1 & 1 \\ 2 & 2 \end{bmatrix} \nonumber

is a singular matrix. But didn’t we just give a formula for an inverse? Let us try it:

[1122]1=11·21·2[2121]=?\begin{bmatrix} 1 & 1 \\ 2 & 2 \end{bmatrix}^{-1} = \frac{1}{1\cdot 2-1 \cdot 2} \begin{bmatrix} 2 & -1 \\ -2 & 1 \end{bmatrix} =? \nonumber

We get into a bit of trouble; we are trying to divide by zero.

So a 2×22 \times 2 matrix AA is invertible whenever

adbc=0ad - bc \not= 0 \nonumber

and otherwise it is singular. The expression adbcad-bc is called the determinant and we will look at it more carefully in a later section. There is a similar expression for a square matrix of any size.

Diagonal Matrices

A simple (and surprisingly useful) type of a square matrix is a so-called diagonal matrix. It is a matrix whose entries are all zero except those on the main diagonal from top left to bottom right. For example a 4×44 \times 4 diagonal matrix is of the form

[d10000d20000d30000d4].\begin{bmatrix} d_1 & 0 & 0 & 0 \\ 0 & d_2 & 0 & 0 \\ 0 & 0 & d_3 & 0 \\ 0 & 0 & 0 & d_4 \end{bmatrix}. \nonumber

Such matrices have nice properties when we multiply by them. If we multiply them by a vector, they multiply the kthk^{\text{th}} entry by dkd_k. For example,

[100020003][456]=[1·42·53·6]=[41018].\begin{bmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \end{bmatrix} \begin{bmatrix} 4 \\ 5 \\ 6 \end{bmatrix} = \begin{bmatrix} 1 \cdot 4 \\ 2 \cdot 5 \\ 3 \cdot 6 \end{bmatrix} = \begin{bmatrix} 4 \\ 10 \\ 18 \end{bmatrix}. \nonumber

Similarly, when they multiply another matrix from the left, they multiply the kthk^{\text{th}} row by dkd_k. For example,

[200030001][111111111]=[222333111].\begin{bmatrix} 2 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & -1 \end{bmatrix} \begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix} = \begin{bmatrix} 2 & 2 & 2 \\ 3 & 3 & 3 \\ -1 & -1 & -1 \end{bmatrix}. \nonumber

On the other hand, multiplying on the right, they multiply the columns:

[111111111][200030001]=[231231231].\begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix} \begin{bmatrix} 2 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & -1 \end{bmatrix} = \begin{bmatrix} 2 & 3 & -1 \\ 2 & 3 & -1 \\ 2 & 3 & -1 \end{bmatrix}. \nonumber

And it is really easy to multiply two diagonal matrices together—we multiply the entries:

[100020003][200030001]=[1·20002·30003·(1)]=[200060003].\begin{bmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \end{bmatrix} \begin{bmatrix} 2 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & -1 \end{bmatrix} = \begin{bmatrix} 1 \cdot 2 & 0 & 0 \\ 0 & 2 \cdot 3 & 0 \\ 0 & 0 & 3 \cdot (-1) \end{bmatrix} = \begin{bmatrix} 2 & 0 & 0 \\ 0 & 6 & 0 \\ 0 & 0 & -3 \end{bmatrix}. \nonumber

For this last reason, they are easy to invert, you simply invert each diagonal element:

[d1000d2000d3]1=[d11000d21000d31].\begin{bmatrix} d_1 & 0 & 0 \\ 0 & d_2 & 0 \\ 0 & 0 & d_3 \end{bmatrix}^{-1} = \begin{bmatrix} d_1^{-1} & 0 & 0 \\ 0 & d_2^{-1} & 0 \\ 0 & 0 & d_3^{-1} \end{bmatrix}. \nonumber

Let us check an example

[200030004]1A1[200030004]A=[120001300014]A1[200030004]A=[100010001]I.\underbrace{ \begin{bmatrix} 2 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & 4 \end{bmatrix}^{-1} }_{A^{-1}} \underbrace{ \begin{bmatrix} 2 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & 4 \end{bmatrix} }_{A} = \underbrace{ \begin{bmatrix} \frac{1}{2} & 0 & 0 \\ 0 & \frac{1}{3} & 0 \\ 0 & 0 & \frac{1}{4} \end{bmatrix} }_{A^{-1}} \underbrace{ \begin{bmatrix} 2 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & 4 \end{bmatrix} }_{A} = \underbrace{ \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} }_{I}. \nonumber

It is no wonder that the way we solve many problems in linear algebra (and in differential equations) is to try to reduce the problem to the case of diagonal matrices.

Transpose

Vectors do not always have to be column vectors, that is just a convention. Swapping rows and columns is from time to time needed. The operation that swaps rows and columns is the so-called transpose. The transpose of AA is denoted by ATA^T. Example:

[123456]T=[142536].\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}^T = \begin{bmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{bmatrix}. \nonumber

Transpose takes an m×nm \times n matrix to an n×mn \times m matrix.

A key feature of the transpose is that if the product ABAB makes sense, then BTATB^TA^T also makes sense, at least from the point of view of sizes. In fact, we get precisely the transpose of ABAB. That is:

(AB)T=BTAT.{(AB)}^T = B^TA^T. \nonumber

For example,

([123456][011022])T=[012102][142536].{\left( \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} \begin{bmatrix} 0 & 1 \\ 1 & 0 \\ 2 & -2 \end{bmatrix} \right)}^T = \begin{bmatrix} 0 & 1 & 2 \\ 1 & 0 & -2 \end{bmatrix} \begin{bmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{bmatrix}. \nonumber

It is left to the reader to verify that computing the matrix product on the left and then transposing is the same as computing the matrix product on the right.

If we have a column vector x\vec{x} to which we apply a matrix AA and we transpose the result, then the row vector xT\vec{x}^T applies to ATA^T from the left:

(Ax)T=xTAT.{(A\vec{x})}^T = \vec{x}^TA^T. \nonumber

Another place where transpose is useful is when we wish to apply the dot product1 to two column vectors:

x·y=yTx.\vec{x} \cdot \vec{y} = \vec{y}^T \vec{x}. \nonumber

That is the way that one often writes the dot product in software.

We say a matrix AA is symmetric if A=ATA = A^T. For example,

[123245356]\begin{bmatrix} 1 & 2 & 3 \\ 2 & 4 & 5 \\ 3 & 5 & 6 \end{bmatrix} \nonumber

is a symmetric matrix. Notice that a symmetric matrix is always square, that is, n×nn \times n. Symmetric matrices have many nice properties2, and come up quite often in applications.

Footnotes

[1] As a side note, mathematicians write yTx\vec{y}^T\vec{x} and physicists write xTy\vec{x}^T\vec{y}. Shhh…don’t tell anyone, but the physicists are probably right on this.

[2] Although so far we have not learned enough about matrices to really appreciate them.

Adapted from Differential Equations for Engineers by Jiří Lebl (https://www.jirka.org/diffyqs/), © Jiří Lebl, licensed under CC BY-SA 4.0. Changes were made. License: CC-BY-SA-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.