Skip to main content
This material has been adapted from material by Fergus Cooper and others from the "Essential Mathematics" module at the Doctoral Training Centre, University of Oxford.

This material has been adapted from material by Fergus Cooper and others from the "Essential Mathematics" module at the Doctoral Training Centre, University of Oxford.

Creative Commons License
This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1

This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1

Creative Commons License

Linear algebra 1


YouTube lecture recording from October 2020

A recording of this lecture from October 2020; the material has changed a little since.
Youtube lecture thumbnail

Why matrices?

Many problems give us several equations that must all hold at once. For example, the steady state of a model with several interacting chemicals or species is where all of their rates of change are zero at the same time, and the currents in an electrical circuit must balance at every junction at once.
When the equations are linear, matrices let us write any number of them as a single equation, Ax=bA\mathbf{x} = \mathbf{b}, and solve them all in the same way: by hand for small systems, and with Python for large ones.
In this lecture we learn how to add, multiply and invert matrices, and use them to solve simultaneous equations.

Simultaneous equations

Consider 2 simultaneous equations:
a1x+b1y=c1,(1)a2x+b2y=c2,(2)\begin{aligned} a_1x+b_1y &= c_1, &&\text{(1)}\\ a_2x+b_2y &= c_2, &&\text{(2)} \end{aligned}
where the values xx and yy are to be found, and a1a_1, b1b_1, a2a_2, b2b_2, c1c_1 and c2c_2 are given constants.
(1)×b2:b2a1x+b2b1y=b2c1,(3)(2)×b1:b1a2x+b1b2y=b1c2,(4)(3)−(4):(a1b2−a2b1)x=b2c1−b1c2.\begin{aligned} (1) \times b_2: &\qquad b_2a_1x+b_2b_1y = b_2c_1, &&\text{(3)}\\ (2) \times b_1: &\qquad b_1a_2x+b_1b_2y = b_1c_2, &&\text{(4)}\\ (3) - (4): &\qquad (a_1b_2-a_2b_1)x = b_2c_1-b_1c_2. \end{aligned}
Thus:
x=b2c1−b1c2a1b2−a2b1,x=\frac{b_2c_1-b_1c_2}{a_1b_2-a_2b_1},
and similarly:
y=a1c2−a2c1a1b2−a2b1.y=\frac{a_1c_2-a_2c_1}{a_1b_2-a_2b_1}.
This works, provided that a1b2−a2b1≠0.a_1b_2-a_2b_1\neq 0.
While the algebraic manipulation is straightforward when solving two equations, it can get really messy when solving large systems.
What we want is a way to be able to easily manipulate linear systems, regardless of how big they are.

Two equations, two lines

Each of the two equations is a straight line in the (x,y)(x, y) plane, and the solution is the point where the two lines cross. For example, take
x+5y=11,ax+5y=9,\begin{aligned} x + 5y &= 11, \\ ax + 5y &= 9, \end{aligned}
for which a1b2−a2b1=5−5aa_1b_2 - a_2b_1 = 5 - 5a. With a=−1a = -1 the lines cross at x=1x = 1, y=2y = 2 (we solve this system with matrices later in the lecture):
Plot of the lines x + 5y = 11 and -x + 5y = 9, crossing at (1, 2)
As aa approaches 11, the second line turns until it is parallel to the first, and the point where they cross moves off to infinity. At a=1a = 1, a1b2−a2b1=0a_1b_2 - a_2b_1 = 0: the lines are parallel and never cross, so there is no solution. If the two lines had been the same line (e.g. if the second equation were x+5y=11x + 5y = 11 too), every point on it would be a solution, so there would be infinitely many. Either way, there is no single solution when a1b2−a2b1=0a_1b_2 - a_2b_1 = 0.

The matrix

Matrices are a structure that allow us to more easily manipulate linear systems.
Consider the original system
a1x+b1y=c1,a2x+b2y=c2.\begin{aligned} a_1x+b_1y &= c_1, \\ a_2x+b_2y &= c_2. \end{aligned}
We collect the coefficients into a matrix, and the unknowns and the right-hand sides into columns, and rewrite the system in the form of a matrix as:
(a1b1a2b2)(xy)=(c1c2).\left(\begin{matrix}a_1&b_1\\ a_2&b_2\end{matrix}\right) \left(\begin{matrix}x\\y\end{matrix}\right) =\left(\begin{matrix}c_1\\ c_2 \end{matrix}\right).
We will see why this is the same system once we know how to multiply matrices.

What is a matrix?

A matrix is a rectangular array of numbers, such as
A=(123456).A = \left(\begin{matrix}1&2&3\\ 4&5&6\end{matrix}\right).
A matrix with mm rows and nn columns has size m×nm\times n (rows first), so AA is a 2×32\times 3 matrix.
The element in row ii and column jj of a matrix AA is written aija_{ij}, using the lower-case letter. Here, for example, a11=1a_{11} = 1, a23=6a_{23} = 6 and a21=4a_{21} = 4.
A matrix with as many rows as columns is square, and an n×nn\times n matrix has order (dimension) nn.
A matrix with a single column is a column vector, and we write vectors in bold. For example,
x=(xy)\mathbf{x} = \left(\begin{matrix}x\\y\end{matrix}\right)
is a 2×12\times 1 matrix. Similarly, a matrix with a single row is a row vector.

Addition, subtraction, and scalar multiplication

We can add or subtract two matrices as long as they have the same size, by adding or subtracting the elements in the same positions:
(213−4)+(6−51−7)=(8−44−11)\left(\begin{matrix} 2&1 \\ 3&-4 \end{matrix}\right) +\left(\begin{matrix} 6&-5 \\ 1&-7 \end{matrix}\right)= \left(\begin{matrix} 8&-4 \\ 4&-11\end{matrix}\right)
We can multiply a matrix by a scalar, by multiplying every element:
5×(213−4)=(10515−20)5\times\left(\begin{matrix} 2&1\\ 3&-4 \end{matrix}\right)=\left(\begin{matrix}10&5\\ 15&-20\end{matrix}\right)

Matrix multiplication

To multiply two matrices, we multiply each row in the first matrix by each column in the second one, and put the results into a new matrix.
A row and column are multiplied by summing up each element in the row, multiplied by the corresponding element in the column.
(1234)(5678)=(1×5+2×71×6+2×83×5+4×73×6+4×8)=(19224350)\left(\begin{matrix} 1&2 \\ 3&4 \end{matrix}\right) \left(\begin{matrix} 5&6\\7&8\end{matrix}\right) = \left(\begin{matrix} 1 \times 5 + 2 \times 7 & 1 \times 6 + 2 \times 8 \\ 3 \times 5 + 4 \times 7 & 3 \times 6 + 4\times 8\end{matrix}\right) = \left(\begin{matrix} 19&22\\43&50\end{matrix}\right)
For example, the element in row 2 and column 1 of the product is row 2 of the first matrix, (3,4)(3, 4), multiplied by column 1 of the second, (5,7)(5, 7): 3×5+4×7=433\times 5 + 4\times 7 = 43.
(12345678)(123456789101112)=(708090158184210)\left(\begin{matrix} 1&2&3&4\\ 5&6&7&8 \end{matrix}\right) \left(\begin{matrix} 1&2&3\\ 4&5&6\\ 7&8&9\\ 10&11&12 \end{matrix}\right) = \left(\begin{matrix} 70&80&90\\ 158&184&210 \end{matrix}\right) (abc)(pqrsvw)=(ap+br+cvaq+bs+cw).\left(\begin{matrix} a & b & c \end{matrix}\right) \left(\begin{matrix} p & q \\ r & s \\ v & w \end{matrix}\right) = \left(\begin{matrix} ap+br+cv & aq+bs+cw \end{matrix}\right).
If the number of columns in the first matrix doesn't match the number of rows in the second, they cannot be multiplied.
(2312−13)(10−1−4)=???\left(\begin{matrix} 2 & 3 & 1 \\ 2 & -1 & 3\end{matrix}\right)\left(\begin{matrix} 1 & 0 \\ -1 & -4\end{matrix}\right) = ???
Here each row of the first matrix has three elements, but each column of the second has only two, so there is nothing to pair the third element with. In general, an m×nm\times n matrix times an n×pn\times p matrix gives an m×pm\times p matrix: the inner sizes must match, and the outer sizes give the size of the product.

Back to the matrix form

Now we can multiply out the matrix form of our two simultaneous equations:
(a1b1a2b2)(xy)=(a1x+b1ya2x+b2y).\left(\begin{matrix}a_1&b_1\\ a_2&b_2\end{matrix}\right) \left(\begin{matrix}x\\y\end{matrix}\right) = \left(\begin{matrix}a_1x+b_1y\\ a_2x+b_2y\end{matrix}\right).
Each row gives back the left-hand side of one of the equations, so Ax=cA\mathbf{x} = \mathbf{c} is exactly the original system, with
A=(a1b1a2b2),x=(xy),c=(c1c2).A = \left(\begin{matrix}a_1&b_1\\ a_2&b_2\end{matrix}\right), \qquad \mathbf{x} = \left(\begin{matrix}x\\y\end{matrix}\right), \qquad \mathbf{c} = \left(\begin{matrix}c_1\\ c_2 \end{matrix}\right).
The same works for any number of equations and unknowns: AA has one row per equation and one column per unknown.

Matrix multiplication is not commutative

In general ABAB is not the same as BABA: the order matters. This can be easily seen from the fact that multiplying different sized matrices doesn't always work:
(3×2 matrix)×(2×2 matrix)=(3×2 matrix)(2×2 matrix)×(3×2 matrix)=???\begin{aligned} (3\times 2 \text{ matrix}) \times (2\times 2 \text{ matrix}) &= (3\times 2 \text{ matrix}) \\ (2\times 2 \text{ matrix}) \times (3\times 2 \text{ matrix}) &= ??? \end{aligned}
However, even when sizes match, the product is usually not the same:
(1234)(0110)=(2143),(0110)(1234)=(3412).\begin{aligned} \left(\begin{matrix} 1&2 \\ 3&4 \end{matrix}\right) \left(\begin{matrix} 0&1\\1&0\end{matrix}\right) &= \left(\begin{matrix} 2&1\\4&3\end{matrix}\right), \\ \left(\begin{matrix} 0&1\\1&0\end{matrix}\right) \left(\begin{matrix} 1&2 \\ 3&4 \end{matrix}\right) &= \left(\begin{matrix} 3&4\\1&2\end{matrix}\right). \end{aligned}
Multiplying by this matrix on the right swaps the columns, while multiplying by it on the left swaps the rows.

Laws of matrix multiplication

Matrix multiplication is not commutative, but it does obey two laws we know from numbers (whenever the products are defined):
  • it is associative: (AB)C=A(BC)(AB)C = A(BC), so we can write ABCABC without brackets;
  • it is distributive: A(B+C)=AB+ACA(B+C) = AB + AC and (A+B)C=AC+BC(A+B)C = AC + BC.
We need both forms of the distributive law, because A(B+C)A(B+C) and (B+C)A(B+C)A are not the same. For the same reason, when we multiply both sides of a matrix equation by a matrix, we must multiply both sides on the same side (both on the left, or both on the right).

The identity matrix

II is the identity matrix, which has the property that:
AI=IA=AA I = I A = A
for a square matrix AA of the same size. It is the matrix equivalent of multiplying by 1.
It has 1s on the leading diagonal (from top left to bottom right) and 0s everywhere else. The 2x2 identity matrix is:
I2=(1001).I_2 = \left(\begin{matrix} 1 & 0 \\ 0 & 1 \end{matrix}\right).
The 3x3 identity matrix is:
I3=(100010001).I_3 = \left(\begin{matrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{matrix}\right).
and so on for higher dimensions.

Inverting matrices

To solve a matrix equation, we need the matrix equivalent of dividing: the inverse.

The inverse of a matrix

For a number a≠0a \neq 0, its inverse a−1=1/aa^{-1} = 1/a satisfies a a−1=a−1a=1a\,a^{-1} = a^{-1}a = 1. There is no matrix division, but the inverse of a matrix plays the same role.
If AA and BB are square matrices with
AB=BA=I,AB = BA = I,
then BB is the inverse of AA, written B=A−1B = A^{-1}, and AA is the inverse of BB, A=B−1A = B^{-1}.
For a 2x2 matrix there is a formula for the inverse: if
A=(pqrs)A = \left(\begin{matrix} p & q \\ r & s\end{matrix}\right)
then:
A−1=1ps−qr(s−q−rp).A^{-1} = \frac{1}{ps-qr} \left(\begin{matrix} s & -q \\ -r & p\end{matrix}\right).
That is, swap the two elements on the leading diagonal, change the sign of the other two, and divide by ps−qrps - qr. We can check that this works by multiplying out:
AA−1=1ps−qr(pqrs)(s−q−rp)=1ps−qr(ps−qr00ps−qr)=I2.AA^{-1} = \frac{1}{ps-qr}\left(\begin{matrix} p & q \\ r & s\end{matrix}\right)\left(\begin{matrix} s & -q \\ -r & p\end{matrix}\right) = \frac{1}{ps-qr}\left(\begin{matrix} ps-qr & 0 \\ 0 & ps-qr\end{matrix}\right) = I_2.

The determinant

The formula for A−1A^{-1} only works if ps−qr≠0ps-qr \neq 0. This number is the determinant of AA, written ∣A∣|A| or det⁡A\det A:
∣A∣=ps−qr|A| = ps-qr
That is, (top left ×\times bottom right) - (top right ×\times bottom left).
If ∣A∣=0|A| = 0, AA is said to be singular, and it has no inverse.
For our two simultaneous equations, the determinant of the matrix of coefficients is
∣a1b1a2b2∣=a1b2−a2b1,\left|\begin{matrix}a_1&b_1\\ a_2&b_2\end{matrix}\right| = a_1b_2 - a_2b_1,
which is the number we had to divide by when we solved them at the start of the lecture. When it is zero, the two lines are parallel, and there is no single solution.
Larger square matrices have determinants too, and the same holds: a square matrix has an inverse exactly when its determinant is not zero. We won't need to calculate them by hand in this course.

Note

The determinant as an area
Multiplying by a 2x2 matrix AA moves every point of the plane: the point (x,y)(x, y) goes to A(xy)A\left(\begin{smallmatrix}x\\y\end{smallmatrix}\right). The corners (1,0)(1, 0) and (0,1)(0, 1) of the unit square go to the two columns of AA, so the unit square goes to the parallelogram with those columns as its sides.
Its area is ∣det⁡A∣\lvert\det A\rvert, and if det⁡A<0\det A < 0 the square is also flipped over. For example, with
A=(2112),A = \left(\begin{matrix} 2 & 1 \\ 1 & 2\end{matrix}\right),
the arrows below show the columns (2,1)(2, 1) (orange) and (1,2)(1, 2) (blue), and the parallelogram has area det⁡A=4−1=3\det A = 4 - 1 = 3:
The unit square and its image under A, a parallelogram with sides (2, 1) and (1, 2) and area 3
If det⁡A=0\det A = 0, the square is squashed flat onto a line (or a point), so different points end up in the same place. Then there is no way to undo the transformation, which is why a singular matrix has no inverse.

Example of inverting a 2x2 matrix

Let us take a matrix
A=(2−3−24).A=\left(\begin{matrix}2&-3\\ -2&4\end{matrix}\right).
First, calculate its determinant:
∣A∣=(2×4)−(−3×−2)=8−6=2.|A|=(2\times 4)-(-3\times-2)=8-6=2.
This is not zero, so AA has an inverse, and from the formula:
A−1=12(4322)A^{-1}=\frac{1}{2}\left(\begin{matrix}4&3\\ 2&2\end{matrix}\right)
As a check, calculate A−1AA^{-1}A:
A−1A=12(4322)(2−3−24)=12(2002)=(1001)=I2.\begin{aligned} A^{-1}A &= \frac{1}{2}\left(\begin{matrix}4&3\\ 2&2\end{matrix}\right)\left(\begin{matrix}2&-3\\ -2&4\end{matrix}\right) \\ &= \frac{1}{2}\left(\begin{matrix}2&0\\ 0&2\end{matrix}\right) \\ &= \left(\begin{matrix}1&0\\ 0&1\end{matrix}\right) \\ &=I_2. \end{aligned}

The transpose of a matrix

ATA^T, the transpose of AA, swaps the rows and columns: row ii of AA becomes column ii of ATA^T, so that (AT)ij=aji(A^T)_{ij} = a_{ji}. For a square matrix, this reflects the elements across the leading diagonal:
A=(2121461−12)AT=(21114−1262)\begin{aligned} A &=\left(\begin{matrix}2&1&2\\ 1&4&6\\ 1&-1&2\end{matrix}\right) \\ A^T &=\left(\begin{matrix}2&1&1\\ 1&4&-1\\ 2&6&2\end{matrix}\right) \end{aligned}

Solving a linear system using matrices

To solve the matrix equation Ax=bA\mathbf{x} = \mathbf{b} for the unknown vector x\mathbf{x}, we multiply both sides on the left by A−1A^{-1}:
A−1Ax=A−1bIx=A−1bx=A−1b\begin{aligned} A^{-1}A\mathbf{x} &= A^{-1}\mathbf{b} \\ I\mathbf{x} &= A^{-1}\mathbf{b} \\ \mathbf{x} &= A^{-1}\mathbf{b} \end{aligned}
We must multiply on the left on both sides, because the order of multiplication matters: bA−1\mathbf{b}A^{-1} is not even defined when b\mathbf{b} is a column vector.
To find x\mathbf{x}:
  • for a 2x2 matrix, use the formula for A−1A^{-1} and calculate x=A−1b\mathbf{x} = A^{-1}\mathbf{b};
  • for larger matrices by hand, use Gaussian elimination, which is the elimination we used at the start of the lecture, done systematically one unknown at a time (not in this course);
  • in practice, use a linear algebra package such as NumPy or SymPy, which does this for us.

Example of solving a 2x2 linear system

Let's take an example:
x+5y=11,−x+5y=9\begin{aligned} x+5y &= 11, \\ -x+5y &= 9 \end{aligned}
In matrix form, this gives:
(15−15)(xy)=(119)\left(\begin{matrix}1 &5\\ -1&5\end{matrix}\right) \left(\begin{matrix}x\\ y\end{matrix}\right) = \left(\begin{matrix}11\\ 9\end{matrix}\right)
The determinant is ∣A∣=(1×5)−(5×−1)=10|A| = (1\times 5) - (5\times -1) = 10, so from the formula:
A−1=110(5−511)A^{-1}= \frac{1}{10} \left(\begin{matrix}5 &-5\\ 1&1 \end{matrix}\right)
Thus:
(xy)=110(5−511)(119)=110(1020)=(12)\left(\begin{matrix}x\\ y\end{matrix}\right) = \frac{1}{10}\left(\begin{matrix}5 &-5\\ 1&1\end{matrix}\right)\left(\begin{matrix}11\\ 9\end{matrix}\right) =\frac{1}{10} \left(\begin{matrix}10\\ 20\end{matrix}\right) =\left(\begin{matrix}1\\ 2\end{matrix}\right)
And x=1,y=2x=1, y=2: the point where the two lines cross in the figure above.
This process seems like more effort than it's worth for small systems. But it allows for a much more systematic approach when dealing with large systems.
As the size of the matrix grows, this process can be easily performed with Python (or other tools).

Example: solving a 4x4 system in Python

x+5y+3z−w=5,x−2y+z+4w=2,−3x+y−z+2w=−5,x+y+z=0.\begin{aligned} x + 5y + 3z - w &= 5, \\ x - 2y + z + 4w &= 2, \\ -3x + y - z + 2w &= -5, \\ x + y + z &= 0. \end{aligned}
In matrix form, this gives:
(153−11−214−31−121110)(xyzw)=(52−50).\left(\begin{matrix} 1 & 5 & 3 & -1 \\ 1 & -2 & 1 & 4 \\ -3 & 1 & -1 & 2\\ 1 & 1 & 1 & 0 \end{matrix}\right) \left(\begin{matrix} x \\ y \\ z \\ w\end{matrix}\right) = \left(\begin{matrix} 5 \\ 2 \\ -5 \\ 0\end{matrix}\right).

Numerically, using NumPy

In Python, we store matrices and vectors as NumPy arrays, and np.linalg.solve solves Ax=bA\mathbf{x} = \mathbf{b}. We could instead calculate the inverse of AA with np.linalg.inv and multiply, but solving directly is faster and more accurate. The @ operator multiplies matrices, so we can check the answer by calculating AxA\mathbf{x}:
import numpy as np A = np.array([[1, 5, 3, -1], [1, -2, 1, 4], [-3, 1, -1, 2], [1, 1, 1, 0]]) b = np.array([5, 2, -5, 0]) # Solve A x = b directly: faster and more accurate than finding A^-1 x = np.linalg.solve(A, b) print(x) # Check: A x should give back b print(A @ x)
[-5.94444444 -5.11111111 11.05555556 -3.33333333] [ 5.0000000e+00 2.0000000e+00 -5.0000000e+00 -8.8817842e-16]
The last entry of AxA\mathbf{x} is −8.9×10−16-8.9\times 10^{-16}, not 00. Computers store numbers to about 16 significant figures, so tiny rounding errors like this appear in almost every numerical calculation.

Symbolically, using SymPy

SymPy works with exact fractions instead, so there are no rounding errors:
import sympy as sp A = sp.Matrix([[1, 5, 3, -1], [1, -2, 1, 4], [-3, 1, -1, 2], [1, 1, 1, 0]]) b = sp.Matrix([5, 2, -5, 0]) A.solve(b)
[−10718−46919918−103]\def\arraystretch{1.8}\left[\begin{matrix}- \frac{107}{18}\\- \frac{46}{9}\\\frac{199}{18}\\- \frac{10}{3}\end{matrix}\right]

Introductory problems

Tip

For more practice, an AI tool can write new problems like the ones below. Ask it for problems of the same type and difficulty, or for problems set in your own field. For example, you could ask it to "write five engineering problems on matrices and simultaneous equations, at the level of these ones". Work them on paper first, then ask the tool to check your answers and to explain any step you are unsure of.

Introductory problems 1

Write the following system of equations:
x+y+z=72x−y+z=2x−2y+2z=5\begin{aligned} x + y + z &= 7\\ 2x - y + z &= 2\\ x - 2y + 2z &= 5 \end{aligned}
in the form
  1. Ax=bA\mathbf{x} = \mathbf{b}
  2. yB=c\mathbf{y}B = \mathbf{c}
Where AA and BB are 3×33\times3 matrices, and x\mathbf{x}, y\mathbf{y}, b\mathbf{b} and c\mathbf{c} are vectors whose size and shape you should carefully indicate.
Check that your answers make sense by expanding your expressions to ensure you get back to the original equations.

Introductory problems 2

Given
A=(2134),B=(1472),C=(3−1−52),D=(13),E=(2−1)\begin{gathered} A = \begin{pmatrix} 2 & 1 \\ 3 & 4 \end{pmatrix}, \quad B = \begin{pmatrix} 1 & 4 \\ 7 & 2 \end{pmatrix}, \quad C = \begin{pmatrix} 3 & -1 \\ -5 & 2 \end{pmatrix}, \\ D = \begin{pmatrix} 1 \\ 3 \end{pmatrix}, \quad E = \begin{pmatrix} 2 & -1 \end{pmatrix} \end{gathered}
  1. Write down a21a_{21}, b12b_{12} and c22c_{22}
  2. Calculate:
    • A+AA + A
    • A−BA - B
    • 4C4C
  3. Calculate, where possible, or explain why the product is not defined:
    • ABAB
    • CDCD
    • DCDC
    • EEEE
  4. Do A and B commute? Do A and C commute?
  5. Does (AB)C=A(BC)(AB)C = A(BC)? Does this either prove or disprove that matrix multiplication is associative?
  6. Does AC+BC=(A+B)CAC + BC = (A+B)C? Does this either prove or disprove the distributive property of matrices?

Main problems

Main problems 1

If
A=12(1111),A = \frac{1}{2}\left(\begin{array}{cc} 1 & 1 \\ 1 & 1 \end{array}\right),
find A2A^2 and A3A^3 and comment on your results.

Main problems 2

Given
A=(2133−21−101);B=(0−11−52−1302)A = \begin{pmatrix} 2 & 1 & 3 \\ 3 & -2 & 1 \\ -1 & 0 & 1 \end{pmatrix}; \qquad B = \begin{pmatrix} 0 & -1 & 1 \\ -5 & 2 & -1 \\ 3 & 0 & 2 \end{pmatrix}
Find:
  • ABAB
  • BABA
  • ATBT{A}^T {B}^T
  • BTAT{B}^T {A}^T
  • (AB)T{(AB)^T}
  • (BA)T{(BA)^T}
Comment on your results.

Main problems 3

Find the determinant, ∣A∣|A|, of the following matrices:
  1. A=(1216)A = \begin{pmatrix} 1 & 2 \\ 1 & 6 \end{pmatrix}
  2. A=(1−12−4)A = \begin{pmatrix} 1 &-1 \\ 2 &-4 \end{pmatrix}

Main problems 4

Find the inverse, A−1A^{-1}, of the following matrices:
  1. A=(25−14)A = \begin{pmatrix} 2 & 5 \\-1 & 4 \end{pmatrix}
  2. A=(−32−17)A = \begin{pmatrix} -3 & 2 \\-1 & 7 \end{pmatrix}

Main problems 5

Use Python's numpy.linalg.solve to solve the following systems of equations:
  1. x+2y−3z=9,2x−y+z=0,4x−y+z=4.\begin{aligned} x + 2y - 3z &= 9,\\ 2x - y + z &= 0,\\ 4x - y + z &= 4. \end{aligned}
  2. x+5y+3z=17,5x+y−2z=4,x+2y+z=7.\begin{aligned}x + 5y + 3z &= 17,\\ 5x + y - 2z &= 4,\\ x + 2y + z &= 7. \end{aligned}
  3. 2y+z=−8,x−2y−3z=0,−x+y+2z=3.\begin{aligned} 2y + z &= -8,\\ x - 2y - 3z &= 0,\\ -x + y + 2z &= 3. \end{aligned}
# hint import numpy as np A = np.array([[1,2,-3], [2,-1,1], [4,-1,1]]) b = np.array([9,0,4]) x = np.linalg.solve(A, b) print(x)

Main problems 6

X=(1234);Y=(5678)X = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}; \qquad Y = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}
Calculate:
  • XYXY
  • YXYX
  • X−1X^{-1}
  • Y−1Y^{-1}
  • X−1Y−1X^{-1}Y^{-1}
  • Y−1X−1Y^{-1}X^{-1}
  • (XY)−1(XY)^{-1}
  • (YX)−1(YX)^{-1}
Comment on your results.

Main problems 7

Write each of the following systems in the form Ax=bA\mathbf{x} = \mathbf{b}, and solve it by hand by finding A−1A^{-1} and calculating x=A−1b\mathbf{x} = A^{-1}\mathbf{b}:
  1. 3x−2y=4,x+y=3.\begin{aligned} 3x - 2y &= 4,\\ x + y &= 3. \end{aligned}
  2. 2x+3y=1,4x−y=9.\begin{aligned} 2x + 3y &= 1,\\ 4x - y &= 9. \end{aligned}
Check your answers using Python's numpy.linalg.solve.

Extension problems

Extension problems 1

Show that
(3113)(1212)=λ1(1212)(3113)(12−12)=λ2(12−12)\begin{aligned} \begin{pmatrix} 3 & 1 \\ 1 & 3 \end{pmatrix} \begin{pmatrix} \frac{1}{\sqrt 2} \\ \frac{1}{\sqrt 2} \end{pmatrix} &= \lambda_1 \begin{pmatrix} \frac{1}{\sqrt 2} \\ \frac{1}{\sqrt 2} \end{pmatrix} \\ \begin{pmatrix} 3 & 1 \\ 1 & 3 \end{pmatrix} \begin{pmatrix} \frac{1}{\sqrt 2} \\ \frac{-1}{\sqrt 2} \end{pmatrix} &= \lambda_2 \begin{pmatrix} \frac{1}{\sqrt 2} \\ \frac{-1}{\sqrt 2} \end{pmatrix} \end{aligned}
where λ1\lambda_1 and λ2\lambda_2 are constants to be determined.