Matrix decomposition exercises

Contents

6.7. Matrix decomposition exercises#

Exercise 6.1

Using pen and paper, solve the following system of linear equations using LU decomposition.

\[\begin{split}\begin{align*} 2 x_1 + 3 x_2 - x_3 &= 4,\\ 4 x_1 + 9 x_2 - x_3 &= 18,\\ 3 x_2 + 2 x_3 &= 11. \end{align*} \end{split}\]
Solution
\[\begin{split} \begin{align*} L &= \begin{pmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 0 & 1 & 1 \end{pmatrix}, & U &= \begin{pmatrix} 2 & 3 & -1 \\ 0 & 3 & 1 \\ 0 & 0 & 1 \end{pmatrix}, & \mathbf{x} &= \begin{pmatrix} -2 \\ 3 \\ 1 \end{pmatrix} \end{align*} \end{split}\]

Exercise 6.2

Using pen and paper, solve the following system of linear equations using LU decomposition with partial pivoting.

\[\begin{split} \begin{align*} x_1 + 3x_2 + 2x_3 &= 16, \\ 2x_1 + x_2 &= 0, \\ 3x_1 + x_2 - x_3 &= -5. \end{align*} \end{split}\]
Solution
\[\begin{split} \begin{align*} L &= \begin{pmatrix} 1 & 0 & 0 \\ \frac{1}{3} & 1 & 0 \\ \frac{2}{3} & \frac{1}{8} & 1 \end{pmatrix}, \qquad U &= \begin{pmatrix} 3 & 1 & -1 \\ 0 & \frac{8}{3} & \frac{7}{3} \\ 0 & 0 & \frac{3}{8} \end{pmatrix}, \qquad \mathbf{x} &= \begin{pmatrix} -2 \\ 4 \\ 3 \end{pmatrix} \end{align*} \end{split}\]

Exercise 6.3

Using pen and paper, solve the following systems of linear equations using Cholesky decomposition.

\[\begin{split} \begin{align*} 16x_1 +16x_2 +4x_3 &=-8,\\ 16x_1 +25x_2 +10x_3 &=-47,\\ 4x_1 +10x_2 +6x_3 &=-30. \end{align*} \end{split}\]
Solution
\[\begin{split} \begin{align*} L = \begin{pmatrix} 4 & 0 & 0 \\ 4 & 3 & 0 \\ 1 & 2 & 1 \end{pmatrix}, \qquad \mathbf{x} = \begin{pmatrix} 3 \\ 3 \\ -2 \end{pmatrix} \end{align*} \end{split}\]

Exercise 6.4

Use Python or MATLAB to check your solutions to Exercise 6.1, Exercise 6.2 and Exercise 6.3.

Exercise 6.5

Using pen and paper, calculate the QR decomposition using the Gram-Schmidt process of the following matrices:

(a)   \( \begin{pmatrix} 1 & 1 \\ -1 & 0 \end{pmatrix}\);

Solution

(a)   \(Q = \begin{pmatrix} \frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2} \\ - \frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2} \end{pmatrix}\),   \(R = \begin{pmatrix} \sqrt{2} & \frac{\sqrt{2}}{2} \\ 0 & \frac{\sqrt{2}}{2} \end{pmatrix}\);

(b)   \(\begin{pmatrix} 6 & 6 & 1 \\ 3 & 6 & 1 \\ 2 & 1 & 1 \end{pmatrix}\);

Solution

(b)   \(Q = \begin{pmatrix} \frac{6}{7} & -\frac{2}{7} & -\frac{3}{7} \\ \frac{3}{7} & \frac{6}{7} & \frac{2}{7} \\ \frac{2}{7} & -\frac{3}{7} & \frac{6}{7} \end{pmatrix}\),   \(R = \begin{pmatrix} 7 & 8 & \frac{11}{7} \\ 0 & 3 & \frac{1}{7} \\ 0 & 0 & \frac{5}{7} \end{pmatrix}\);

(c)   \(\begin{pmatrix} 1 & 2 & 1 \\ 1 & 4 & 3 \\ 1 & -4 & 6 \\ 1 & 2 & 1 \end{pmatrix}\).

Solution

(c)   \(Q = \begin{pmatrix} \frac{1}{2} & \frac{1}{6} & -\frac{\sqrt{18}}{9} \\ \frac{1}{2} & \frac{1}{2} & \frac{\sqrt{18}}{6} \\ \frac{1}{2} & -\frac{5}{6} & \frac{\sqrt{18}}{18} \\ \frac{1}{2} & \frac{1}{6} & -\frac{\sqrt{18}}{9} \end{pmatrix}\) and \(R = \begin{pmatrix} 2 & 2 & \frac{11}{2} \\ 0 & 6 & -\frac{19}{6} \\ 0 & 0 & \frac{11\sqrt{18}}{18} \end{pmatrix}\)

Exercise 6.6

Using pen and paper, calculate the QR decomposition using the Householder transformations of the following matrices:

(a)   \( \begin{pmatrix} 3 & 0 \\ 4 & 5 \end{pmatrix}\);

Solution

(a)   \(Q = \begin{pmatrix} \frac{3}{5} & -\frac{4}{5} \\ \frac{4}{5} & \frac{3}{5} \end{pmatrix}\) and \(R = \begin{pmatrix} 5 & 4 \\ 0 & 3 \end{pmatrix}\)

(b)   \(\begin{pmatrix} 1 & 2 & 4 \\ 0 & 0 & 5 \\ 0 & 3 & 6 \end{pmatrix}\);

Solution

(b)   \(Q = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}\) and \(R = \begin{pmatrix} 1 & 2 & 4 \\ 0 & 3 & 6 \\ 0 & 0 & 5 \end{pmatrix}\)

Exercise 6.7

Use Python or MATLAB to check your solutions to Exercise 6.5 and Exercise 6.6.


6.7.1. Solutions#

The solutions to these exercises downloaded below: