Solutions#

Question 1#

1. Obtain the determinant and the inverses of the following matrices:

1. \(A = \begin{pmatrix} 1 / 5 & 1\\1 & 1\end{pmatrix}\)

import sympy as sym

A = sym.Matrix([[sym.S(1) / 5, 1], [1, 1]])
A.det()
\[\displaystyle - \frac{4}{5}\]
A.inv()
\[\begin{split}\displaystyle \left[\begin{matrix}- \frac{5}{4} & \frac{5}{4}\\\frac{5}{4} & - \frac{1}{4}\end{matrix}\right]\end{split}\]

2. \(B = \begin{pmatrix} 1 / 5 & 1 & 5\\3 & 1 & 6 \\ 1 & 2 & 1\end{pmatrix}\)

B = sym.Matrix([[sym.S(1) / 5, 1, 5], [3, 1, 6], [1, 2, 1]])
B.det()
\[\displaystyle \frac{129}{5}\]
B.inv()
\[\begin{split}\displaystyle \left[\begin{matrix}- \frac{55}{129} & \frac{15}{43} & \frac{5}{129}\\\frac{5}{43} & - \frac{8}{43} & \frac{23}{43}\\\frac{25}{129} & \frac{1}{43} & - \frac{14}{129}\end{matrix}\right]\end{split}\]

3. \(C = \begin{pmatrix} 1 / 5 & 5 & 5\\3 & 1 & 7 \\ a & b & c\end{pmatrix}\)

a, b, c = sym.Symbol("a"), sym.Symbol("b"), sym.Symbol("c")
C = sym.Matrix([[sym.S(1) / 5, 5, 5], [3, 1, 7], [a, b, c]])
C.det()
\[\displaystyle 30 a + \frac{68 b}{5} - \frac{74 c}{5}\]
C.inv()
\[\begin{split}\displaystyle \left[\begin{matrix}\frac{- 35 b + 5 c}{150 a + 68 b - 74 c} & \frac{25 b - 25 c}{150 a + 68 b - 74 c} & - \frac{444}{- 444 a - \frac{5032 b}{25} + \frac{5476 c}{25}}\\\frac{35 a - 15 c}{150 a + 68 b - 74 c} & \frac{- 25 a + c}{150 a + 68 b - 74 c} & - \frac{5032}{- 11100 a - 5032 b + 5476 c}\\\frac{- 5 a + 15 b}{150 a + 68 b - 74 c} & \frac{25 a - b}{150 a + 68 b - 74 c} & - \frac{74}{150 a + 68 b - 74 c}\end{matrix}\right]\end{split}\]

Question 2#

2. Compute the following:

1. \(500\begin{pmatrix} 1 / 5 & 1\\1 & 1\end{pmatrix}\)

A = 500 * sym.Matrix([[sym.S(1) / 5, 1], [1, 1]])
A
\[\begin{split}\displaystyle \left[\begin{matrix}100 & 500\\500 & 500\end{matrix}\right]\end{split}\]

2. \(\pi \begin{pmatrix} 1 / \pi & 2\pi\\3/\pi & 1\end{pmatrix}\)

B = sym.pi * sym.Matrix([[1 / sym.pi, 2 * sym.pi], [3 / sym.pi, 1]])
B
\[\begin{split}\displaystyle \left[\begin{matrix}1 & 2 \pi^{2}\\3 & \pi\end{matrix}\right]\end{split}\]

3. \(500\begin{pmatrix} 1 / 5 & 1\\1 & 1\end{pmatrix} + \pi \begin{pmatrix} 1 / \pi & 2\pi\\3/\pi & 1\end{pmatrix}\)

A + B
\[\begin{split}\displaystyle \left[\begin{matrix}101 & 2 \pi^{2} + 500\\503 & \pi + 500\end{matrix}\right]\end{split}\]

4. \(500\begin{pmatrix} 1 / 5 & 1\\1 & 1\end{pmatrix}\begin{pmatrix} 1 / \pi & 2\pi\\3/\pi & 1\end{pmatrix}\)

C = sym.Matrix([[1 / sym.pi, 2 * sym.pi], [3 / sym.pi, 1]])
A @ C
\[\begin{split}\displaystyle \left[\begin{matrix}\frac{1600}{\pi} & 500 + 200 \pi\\\frac{2000}{\pi} & 500 + 1000 \pi\end{matrix}\right]\end{split}\]

Question 3#

3. The matrix \(A\) is given by \(A=\begin{pmatrix}a & 4 & 2\\ 1 & a & 0\\ 1 & 2 & 1\end{pmatrix}\).

1. Find the determinant of \(A\)

A = sym.Matrix([[a, 4, 2], [1, a, 0], [1, 2, 1]])
determinant = A.det()
determinant
\[\displaystyle a^{2} - 2 a\]

2. Hence find the values of \(a\) for which \(A\) is singular.

\(A\) is singular when the determinant is \(0\) so we solve that equation:

sym.solveset(determinant, a)
\[\displaystyle \left\{0, 2\right\}\]

3. State, giving a brief reason in each case, whether the simultaneous equations

\[\begin{split} \begin{array}{l} a x + 4y + 2z= 3a\\ x + a y = 1\\ x + 2y + z = 3\\ \end{array} \end{split}\]

have any solutions when: 1. \(a = 3\);

When \(a\) is 3 the determinant is none zero, and so the matrix that represents that linear system can be inverted.

2. \(a = 2\)

When \(a\) is 2 the determinant is zero and so the matrix that represents that linear system cannot be inverted.

Question 4#

4. The matrix \(D\) is given by \(D = \begin{pmatrix} a & 2 & 0\\ 3 & 1 & 2\\ 0 & -1 & 1\end{pmatrix}\) where \(a\ne 2\). 1. Find \(D^{-1}\).

D = sym.Matrix([[a, 2, 0], [3, 1, 2], [0, -1, 1]])
D_inverse = D.inv()
D_inverse
\[\begin{split}\displaystyle \left[\begin{matrix}- \frac{9}{18 - 9 a} & \frac{6}{18 - 9 a} & - \frac{12}{18 - 9 a}\\\frac{3}{6 - 3 a} & - \frac{a}{6 - 3 a} & \frac{2 a}{6 - 3 a}\\- \frac{3}{3 a - 6} & \frac{a}{3 a - 6} & \frac{a - 6}{3 a - 6}\end{matrix}\right]\end{split}\]

2. Hence or otherwise, solve the equations:

\[\begin{split} \begin{array}{l} a x + 2y = 3\\ 3x + y + 2z = 4\\ - y + z = 1\\ \end{array} \end{split}\]

This corresponds to calculating: \(D^{-1} \begin{pmatrix}3\\4\\1\end{pmatrix}\)

b = sym.Matrix([[3], [4], [1]])
D_inverse @ b
\[\begin{split}\displaystyle \left[\begin{matrix}- \frac{15}{18 - 9 a}\\- \frac{2 a}{6 - 3 a} + \frac{9}{6 - 3 a}\\\frac{4 a}{3 a - 6} + \frac{a - 6}{3 a - 6} - \frac{9}{3 a - 6}\end{matrix}\right]\end{split}\]