\documentclass[11pt, a4paper, english]{NTNUoving}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepackage{blkarray, enumitem, amsthm}
%\pgfplotsset{compat=1.9}
\usepackage{tikz}
\usetikzlibrary{automata,arrows,positioning,calc, tikzmark}
\pgfplotsset{compat=1.17}


\newcounter{exercisenumber}
\newcommand\exnum{\stepcounter{exercisenumber}\theexercisenumber}

\newif\ifLF 
\LFfalse

\ovingnr{11}
\semester{}
\fag{MA1201 Linear Algebra and Geometry }
\institutt{Department of Mathematical Sciences }
\def\centerfoot{}
\begin{document}

\section*{Compulsory exercises}
Hand in your solutions to these exercises. All answers must be justified.

\subsection*{Chapter 6.3 - Gram-Schmidt}
{\bf Exercise \exnum} Do exercise 1 in chapter 6.3 of Elementary Linear Algebra.

\ifLF{
  (a), (b) and (d) are orthogonal. (b) is also orthonormal.
}\fi

{\bf Exercise \exnum} Do exercise 7 in chapter 6.3 of Elementary Linear Algebra.

\ifLF{
  A quick computation verifies that $\mathbf v_1 \cdot \mathbf v_2 = \mathbf v_1 \cdot \mathbf v_3 = \mathbf v_2 \cdot \mathbf v_3 = 0$ and that $\|\mathbf v_1\| = \|\mathbf v_2\| = \|\mathbf v_3\| = 1$, thus they form an orthonormal basis.

  We use the formula from Theorem 6.3.2(b):
  \begin{align*}
    \mathbf u &= \langle \mathbf u, \mathbf v_1 \rangle\mathbf v_1 + \langle \mathbf u, \mathbf v_2 \rangle\mathbf v_2 + \langle \mathbf u, \mathbf v_3 \rangle\mathbf v_3\\
    \mathbf u &= -\frac{11}{5}\mathbf v_1 -\frac25 \mathbf v_2 + 2\mathbf v_3
  \end{align*}
}\fi

{\bf Exercise \exnum} Do exercise 15 in chapter 6.3 of Elementary Linear Algebra.

\ifLF{
  \begin{enumerate}[label=(\alph*)]
    \item \begin{align*}
      \operatorname{proj}_{\mathbf v}(\mathbf u) &= \frac{\langle \mathbf u, \mathbf v \rangle}{\|\mathbf v\|^2}\mathbf v \\
      &= \frac{21/5}{1}\begin{bmatrix}
        3/5\\4/5
      \end{bmatrix}\\
      &= \frac{1}{25}\begin{bmatrix}
        63\\84
      \end{bmatrix}
    \end{align*}
    \item The orthogonal component is given by
    \begin{align*}
      \operatorname{proj}_{\mathbf v^\perp}(\mathbf u) &= \mathbf u - \operatorname{proj}_{\mathbf v}(\mathbf u)\\
      &= \frac{1}{25}\begin{bmatrix}
        -88\\ 66
      \end{bmatrix}
    \end{align*}
  \end{enumerate}
}\fi

{\bf Exercise \exnum} Do exercise 27 in chapter 6.3 of Elementary Linear Algebra.

\ifLF{
  We perform the Gram-Schmidt process:
  \begin{align*}
    \mathbf v_1 &= \mathbf u_1 = \begin{bmatrix}
      1\\-3
    \end{bmatrix}\\
    \mathbf v_2 &= \mathbf u_2 - \frac{\langle \mathbf u_2, \mathbf v_1 \rangle}{\|\mathbf v_1\|^2}\mathbf v_1\\
    &= \begin{bmatrix}
      2\\2
    \end{bmatrix} - \frac{-4}{10}\begin{bmatrix}
      1\\-3
    \end{bmatrix}\\
    &= \begin{bmatrix}
      12/5 \\ 4/5
    \end{bmatrix}
  \end{align*} 
  Then $\{\mathbf v_1, \mathbf v_2\}$ becomes an orthogonal basis. In order to get an orthonormal basis we normalize the vectors and get the bais:
  \begin{align*}
    \left\lbrace \frac{\mathbf v_1}{\|\mathbf v_1\|}, \frac{\mathbf v_2}{\|\mathbf v_2\|} \right\rbrace = 
    \left\lbrace \begin{bmatrix} 
      1/\sqrt{10}\\ -3/\sqrt{10}
    \end{bmatrix}
      ,  
    \begin{bmatrix}
      3/\sqrt{10}\\ 1/\sqrt{10}
    \end{bmatrix}\right\rbrace
  \end{align*}
}\fi

{\bf Exercise \exnum} Do exercise 29 in chapter 6.3 of Elementary Linear Algebra.

\ifLF{
  We perform the Gram-Schmidt process:
  \begin{align*}
    \mathbf v_1 &= \mathbf u_1 = \begin{bmatrix}
      1\\1\\1
    \end{bmatrix}\\
    \mathbf v_2 &= \mathbf u_2 - \frac{\langle \mathbf u_2, \mathbf v_1 \rangle}{\|v_1\|^2}\mathbf v_1 =
    \begin{bmatrix}
      -1\\1\\0
    \end{bmatrix}\\
    \mathbf v_3 &= \mathbf u_3 - \frac{\langle \mathbf u_3, \mathbf v_1 \rangle}{\|v_1\|^2}\mathbf v_1 - \frac{\langle \mathbf u_3, \mathbf v_2 \rangle}{\|v_2\|^2}\mathbf v_2\\
    &= \begin{bmatrix}
      1/6\\1/6\\-1/3
    \end{bmatrix}
  \end{align*}
  After we normalize we get the orthonormal basis
  \begin{align*}
    \left\lbrace \frac{1}{\sqrt{3}}\begin{bmatrix}
      1\\1\\1
    \end{bmatrix},
    \frac{1}{\sqrt{2}}
    \begin{bmatrix}
      1\\-1\\0
    \end{bmatrix},
    \frac{1}{\sqrt{6}}\begin{bmatrix}
      1\\1\\ -2
    \end{bmatrix}
    \right\rbrace
  \end{align*}
}\fi

{\bf Exercise \exnum} Continuing off of the previous exercise let $W$ be the plane spanned by $\mathbf u_1$ and $\mathbf u_2$, and let $\mathbf b = (1,2,3)$. Find vectors $\mathbf w_1 \in W$ and $\mathbf w_2 \in W^\perp$ such that $\mathbf b = \mathbf w_1 + \mathbf w_2$.

\ifLF{
  Since $\mathbf u_1 \cdot \mathbf u_2 = 0$ they form an orthogonal basis for $W$. Then we can calculate $\mathbf w_1$ as the projection of $\mathbf b$ onto $W$.
  \begin{align*}
    \mathbf w_1 &= \frac{\langle \mathbf b, \mathbf u_1 \rangle}{\|\mathbf u_1\|}\mathbf u_1 + \frac{\langle \mathbf b, \mathbf u_2 \rangle}{\|\mathbf u_2\|}\mathbf u_2\\
    &= \frac{6}{3}\mathbf u_1 + \frac{1}{2}\mathbf u_2\\
    &= \begin{bmatrix}
      3/2 \\ 5/2\\ 2
    \end{bmatrix}\\
    &\\
    \mathbf w_2 &= \mathbf b - \mathbf w_1\\
    &= \begin{bmatrix}
      -1/2\\-1/2\\1
    \end{bmatrix}
  \end{align*}
  We can also verify that $\mathbf w_2 \cdot \mathbf u_1 = \mathbf w_2 \cdot \mathbf u_2 = 0$.
}\fi

\end{document}

