---
jupytext:
  formats: md:myst
  text_representation:
    extension: .md
    format_name: myst
    format_version: '0.8'
    jupytext_version: 1.4.1+dev
kernelspec:
  display_name: Python 3
  language: python
  name: python3
---

+++

(section:uge7S-extra)=
# Extra (optional) exercises -- Long Day

+++

These exercises are optional extra material for students who have finished the exercises of the day and have the time and interest for more.

+++

## Extra exercise 1: Uniqueness of the inverse matrix

+++

Definition 7.3.1 in the textbook tells that the inverse matrix of a square matrix $\mathbf A$ is denoted by $\mathbf A^{-1}$, if it exists. It is implicit in this notation that a square matrix has only *one* inverse matrix. Let us show that this indeed is true.

For a given square matrix $\mathbf A \in \mathbb F^{n \times n}$, where $n$ is a natural number, assume that there exist two matrices $\mathbf B$ and $\mathbf C$ such that 

$$\mathbf A\cdot\mathbf B=\mathbf B\cdot\mathbf A=\mathbf I_n$$ 

and

$$\mathbf A \cdot\mathbf C=\mathbf C\cdot\mathbf A=\mathbf I_n.$$ 

Show that $\mathbf B=\mathbf C$ then follows. Conclude that if a matrix has an inverse, then this inverse is uniquely determined. 

+++

## Extra exercise 2: Calculation of matrix products

+++

Given an invertible matrix $\mathbf A \in \mathbb F^{n \times n}$ and a matrix $\mathbf B \in \mathbb F^{n \times m}$, we form an $n \times (n+m)$ matrix $[\mathbf A | \mathbf B]$ by placing the columns of $\mathbf B$ next to (to the right of) the columns of $\mathbf A$. With the two example matrices 

$$\mathbf A = \left[
  \begin{array}{ccc} 
1  &  1 & 2\\ 
0  & 2 & 1 \\ 
2  & 0 & 4\\ 
\end{array}
\right] 
\quad \text{ and } \quad 
\mathbf B = \left[
  \begin{array}{cccc} 
2  &  0 & 0 & 2\\ 
-2  & 0 & 1 & 3\\ 
0 & 3 & 1 & -1\\ 
\end{array}
\right],
$$

this construction forms the new matrix

$$[\mathbf {A} | \mathbf{B}]=\left[
  \begin{array}{ccccccc} 
1  &  1 & 2 & 2  &  0 & 0 & 2\\ 
0  & 2 & 1 & -2  & 0 & 1 & 3\\ 
2  & 0 & 4 & 0 & 3 & 1 & -1\\ 
\end{array}
\right].$$

+++

### Question a

+++

Explain generally why the reduced row-echelon form of the matrix $[\mathbf A | \mathbf B]$ has the form $[\mathbf  I_n | \mathbf C]$ for some $n \times m$ matrix $\mathbf C$.


```{hint}
:class: dropdown
Remember that we were given an invertible matrix $\mathbf A$. What does that mean for the reduced row-echelon form of $\mathbf A$?
```

+++

### Question b

+++

Find a formula for the matrix $\mathbf C$ from the previous question.

```{hint}
:class: dropdown
If $\mathbf B$ consists of just one column (that is, if $m=1$), what is then the solution to the system of linear equations $\mathbf A \cdot \mathbf x=\mathbf B$? 
```

```{admonition} Answer
:class: dropdown
$\mathbf C={\mathbf A}^{-1}\cdot {\mathbf B}.$

A special case is the following: if $\mathbf B = \mathbf I_n$, then $\mathbf C={\mathbf A}^{-1}$, which agrees with the procedure for calculating $\mathbf A^{-1}$ in Section 7.3 in the textbook.
```

+++

### Question c

+++

We are now given an invertible matrix $\mathbf A \in \mathbb F^{n \times n}$ as before and matrices $\mathbf B_1 \in \mathbb F^{n \times m_1}, \mathbf B_2 \in \mathbb F^{n \times m_2}, \dots, \mathbf B_r \in \mathbb F^{n \times m_r}$. Show that by finding the reduced row-echelon form of the matrix $[\mathbf A | \mathbf B_1 | \mathbf B_2 | \dots | \mathbf B_r]$, we can determine the matrices $\mathbf A^{-1}\cdot \mathbf B_1, \mathbf A^{-1}\cdot \mathbf B_2, \dots, \mathbf A^{-1}\cdot \mathbf B_r$ in one go.