Exercise 11.3

Exercise 11.3#

Question 1#

Consider the matrix:

\[\begin{split} \begin{pmatrix} 1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8\\ 9 & 10 & 11 & 12\\ 13 & 14 & 15 & 16 \end{pmatrix} \end{split}\]

Enter this matrix into your script and preform the following tasks:

  1. Extract the second column.

  2. Extract the central \(2\times2\) block.

  3. Find the transpose of the matrix.

Question 2#

Consider the matrix equation: \(\mathbf{A}\mathbf{x} = \mathbf{B}\), where \(\mathbf{A}\) and \(\mathbf{B}\) are known matrices and \(\mathbf{x}\) is an unknown matrix. Write a program which solves this equation for \(\mathbf{x}\), assuming \(A\) is a square matrix. Test it with the following example:

\[\begin{split} A = \begin{pmatrix} 2 & 6\\ 8 & 3\\ \end{pmatrix} \text{ and } B = \begin{pmatrix} 7\\ 3 \end{pmatrix} \text{ which gives } x = \begin{pmatrix} -0.0714 \\ 1.1905 \end{pmatrix} \end{split}\]

Bonus: Can you write a program which solves this for non-square matrices? (see numpy.linalg.lstsq).

Test it on the following example:

\[\begin{split} A = \begin{pmatrix} 5.3 & 4.2 & 2.9\\ 3.4 & 2.7 & 12.1 \end{pmatrix} \text{ and } B = \begin{pmatrix} 7.4 \\ 1.7 \end{pmatrix} \text{ which gives } x = \begin{pmatrix} 0.9580\\ 0.7587\\ -0.2980 \end{pmatrix} \end{split}\]