\documentclass[a4paper]{article}

\usepackage{fancyhdr}
\usepackage{extramarks}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage[plain]{algorithm}
\usepackage{algpseudocode}
\usepackage{enumitem}
\usepackage{framed}
\usepackage{multicol}

\graphicspath{ {./images/} }

\usetikzlibrary{automata,positioning}

%
% Basic Document Settings
%

\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in
\headsep=0.25in

\linespread{1.1}

\pagestyle{fancy}
\lhead{\hmwkAuthorName}
\chead{\hmwkClass\ : \hmwkTitle}
\rhead{\firstxmark}
\lfoot{\lastxmark}
\cfoot{\thepage}

\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}

\setlength\parindent{0pt}

%
% Create Problem Sections
%

\newcommand{\enterProblemHeader}[1]{
    \nobreak\extramarks{}{Question \arabic{#1} continued on next page\ldots}\nobreak{}
    \nobreak\extramarks{Question \arabic{#1} (continued)}{Question \arabic{#1} continued on next page\ldots}\nobreak{}
}

\newcommand{\exitProblemHeader}[1]{
    \nobreak\extramarks{Question \arabic{#1} (continued)}{Question \arabic{#1} continued on next page\ldots}\nobreak{}
    \stepcounter{#1}
    \nobreak\extramarks{Question \arabic{#1}}{}\nobreak{}
}

\setcounter{secnumdepth}{0}
\newcounter{partCounter}
\newcounter{homeworkProblemCounter}
\setcounter{homeworkProblemCounter}{1}
\nobreak\extramarks{Question \arabic{homeworkProblemCounter}}{}\nobreak{}

\newenvironment{homeworkProblem}[1][-1]{
    \ifnum#1>0
        \setcounter{homeworkProblemCounter}{#1}
    \fi
    \section{Question \arabic{homeworkProblemCounter}}
    \setcounter{partCounter}{1}
    \enterProblemHeader{homeworkProblemCounter}
}{
    \exitProblemHeader{homeworkProblemCounter}
}

\newcommand{\hmwkClass}{INF 1004 Mathematics 2}
\newcommand{\hmwkTitle}{Tutorial\ \#10\ Solutions}
\newcommand{\hmwkAuthorName}{\textbf{Woon Jun Wei}}
\newcommand{\hmwkStudentID}{\textbf{2200624}}

\title{
    \vspace{2in}
    \textmd{\textbf{\hmwkClass \\ \hmwkTitle}}\\
    \vspace{3in}
}

\author{\hmwkAuthorName \\ \hmwkStudentID}
\date{\today}

\renewcommand{\part}[1]{\textbf{\large Part \arabic{partCounter}}\stepcounter{partCounter}\\}

%
% Various Helper Commands
%

% Useful for algorithms
\newcommand{\alg}[1]{\textsc{\bfseries \footnotesize #1}}

% For derivatives
\newcommand{\deriv}[1]{\frac{\mathrm{d}}{\mathrm{d}x} (#1)}

% For partial derivatives
\newcommand{\pderiv}[2]{\frac{\partial}{\partial #1} (#2)}

% Integral dx
\newcommand{\dx}{\mathrm{d}x}

% Alias for the Solution section header
\newcommand{\solution}{\textbf{\large My Solution\\}}
\newcommand{\answer}{\textbf{\large Sample Solutions\\}}

% Probability commands: Expectation, Variance, Covariance, Bias
\newcommand{\E}{\mathrm{E}}
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\newcommand{\Bias}{\mathrm{Bias}}

\begin{document}

\maketitle

\pagebreak

\begin{homeworkProblem}
    Compute $A^\top A$ for
    $$
    \begin{equation*}
        A = \begin{bmatrix}
            2&-3\\
            -6&-9
        \end{bmatrix}
    \end{equation*}

    \begin{equation*}
        A = \begin{bmatrix}
            0&1&-1\\
            2&0&2\\
            4&3&1
        \end{bmatrix}
    \end{equation*}
    $$

    \solution

    \part

    $$
    \begin{align*}
        A &= \begin{bmatrix}
            2&-3\\
            -6&-9
        \end{bmatrix}\\
        A^\top &= \begin{bmatrix}
            2&-6\\
            -3&-9
        \end{bmatrix}\\
        A^\top A &= \begin{bmatrix}
            2&-6\\
            -3&-9
        \end{bmatrix}
        \begin{bmatrix}
            2&-3\\
            -6&-9
        \end{bmatrix}\\
        &= \begin{bmatrix}
            40&48\\
            48&100
        \end{bmatrix}
    \end{align*}
    $$
    
    \part

    $$
    \begin{align*}
        A &= \begin{bmatrix}
            0&1&-1\\
            2&0&2\\
            4&3&1
        \end{bmatrix}\\
        A^\top &= \begin{bmatrix}
            0&2&4\\
            1&0&3\\
            -1&2&1
        \end{bmatrix}\\
        A^\top A &= \begin{bmatrix}
            0&2&4\\
            1&0&3\\
            -1&2&1
        \end{bmatrix}
        \begin{bmatrix}
            0&1&-1\\
            2&0&2\\
            4&3&1
        \end{bmatrix}\\
        &= \begin{bmatrix}
            20&12&8\\
            12&10&2\\
            8&2&6
        \end{bmatrix}
    \end{align*}

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
    Compute the inverse of 
    $$
    \begin{equation*}
        A_0 = \begin{bmatrix}
            -2&-3\\
            -6&-4
        \end{bmatrix}
    \end{equation*}
    $$
    $$
    \begin{equation*}
        A_1 = \begin{bmatrix}
            3&1\\
            -2&2
        \end{bmatrix}
    \end{equation*}
    $$

    Use this inverses to solve

    $$
    \begin{equation*}
        A_0 x = \begin{bmatrix}
            3\\
            1
        \end{bmatrix}
    \end{equation*}
    $$
    $$
    \begin{equation*}
        A_0 x = \begin{bmatrix}
            2\\
            -5
        \end{bmatrix}
    \end{equation*}
    $$

    Note: it is not common to solve $Ax=b$ using matrix inversion.\\

    Reasons:
    \begin{itemize}
        \item $Ax=b$ can be solvable when $A$ is not invertible.
        \item It is often slower / more costly
    \end{itemize}

    \solution

    \part

    \begin{multicols}{2}

    $$
    \begin{align*}
        A^{-1} &\implies \left[ \begin{array}{rr|rr}
            -2&-3&1&0\\
            -6&-4&0&1
        \end{array}\right]\\
        -\frac{1}{2}\rho_1, -\frac{1}{4}\rho_2 &\implies \left[ \begin{array}{rr|rr}
            1&\frac{3}{2}&-\frac{1}{2}&0\\
            \frac{3}{2}&1&0&-\frac{1}{4}
        \end{array}\right]\\
        \frac{3}{2}\rho_1 - \rho_2 &\implies \left[ \begin{array}{rr|rr}
                1&\frac{3}{2}&-\frac{1}{2}&0\\
                0&\frac{5}{4}&-\frac{3}{4}&\frac{1}{4}
        \end{array}\right]\\
                \frac{4}{5} \rho_2 &\implies \left[ \begin{array}{rr|rr}
                1&\frac{3}{2}&-\frac{1}{2}&0\\
                0&1&-\frac{3}{5}&\frac{1}{5}
        \end{array}\right]\\
                \rho_1 - \frac{3}{2}\rho_2 &\implies \left[ \begin{array}{rr|rr}
                        1&0&\frac{2}{5}&-\frac{3}{10}\\
                        0&1&-\frac{3}{5}&\frac{1}{5}
        \end{array}\right]\\\\
    A^{-1} &= \begin{bmatrix}
        \frac{2}{5}&-\frac{3}{10}\\
        \frac{3}{5}&\frac{1}{10}
    \end{bmatrix}\\
    \end{align*}
    $$
    
    \columnbreak

    $$
    \begin{align*}
        A_0 x = \begin{bmatrix}
            3\\
            1
        \end{bmatrix}\\
        A_0^{-1} A_0 x &= A_0^{-1} \begin{bmatrix}
            3\\
            1
        \end{bmatrix}\\
        x &= \begin{bmatrix}
            \frac{2}{5}\\
            \frac{3}{5}
        \end{bmatrix}
        \begin{bmatrix}
            3\\
            1
            \end{bmatrix}\\
        &= \begin{bmatrix}
            0.9\\
            -1.6
        \end{bmatrix}
    \end{align*}
    $$

    \end{multicols}

    \pagebreak


    \part

    \begin{multicols}{2}

    $$
    \begin{align*}
        A^{-1} &\implies \left[ \begin{array}{rr|rr}
            3&1&1&0\\
            -2&2&0&1
        \end{array}\right]\\
        \rho_2 + \rho_1 &\implies \left[ \begin{array}{rr|rr}
            3&1&1&0\\
            1&3&1&1
        \end{array}\right]\\
                \frac{1}{3}\rho_1 &\implies \left[ \begin{array}{rr|rr}
                1&\frac{1}{3}&\frac{1}{3}&0\\
                1&3&1&1
        \end{array}\right]\\
        \rho_1-\rho_2 &\implies \left[ \begin{array}{rr|rr}
                1&\frac{1}{3}&\frac{1}{3}&0\\
                0&1&\frac{1}{4}&\frac{3}{8}
        \end{array}\right]\\
        -\frac{3}{8}\rho_2 &\implies \left[ \begin{array}{rr|rr}
                1&\frac{1}{3}&\frac{1}{3}&0\\
                0&1&\frac{1}{4}&\frac{3}{8}
        \end{array}\right]\\
        \rho_1 - \frac{1}{3}\rho_2 &\implies \left[ \begin{array}{rr|rr}
                1&0&\frac{1}{4}&-\frac{1}{8}\\
                0&1&\frac{1}{4}&\frac{3}{8}
        \end{array}\right]\\
    A^{-1} &= \begin{bmatrix}
        \frac{1}{4}&-\frac{1}{8}\\
        \frac{1}{4}&\frac{3}{8}
    \end{bmatrix}\\
    \end{align*}
    $$

    \columnbreak

    $$
    \begin{align*}
        A_0 x &= \begin{bmatrix}
            2\\
            -5
        \end{bmatrix}\\
        A_0^{-1} A_0 x &= A_0^{-1} \begin{bmatrix}
            2\\
            -5
        \end{bmatrix}\\
        x &= \begin{bmatrix}
            \frac{1}{4}&-\frac{1}{8}\\
            \frac{1}{4}&\frac{3}{8}
        \end{bmatrix}
        \begin{bmatrix}
            2\\
            -5
        \end{bmatrix}\\
        &= \begin{bmatrix}
            \frac{9}{8}\\
            -\frac{11}{8}
        \end{bmatrix}
    \end{align*}
    $$

    \end{multicols}

    \answer

    \begin{multicols}{2}   
    \textbf{A:}\\

    $$
    \begin{align*}
        \det(A_0) &= (-2)(-4)-(-3)(-6) = -10\\
        A_0^{-1} &= \frac{1}{\det(A_0)} \begin{bmatrix}
            -4&3\\
            6&-2
        \end{bmatrix}\\
            x &= A_0^{-1} \begin{bmatrix}
                3\\
                1
            \end{bmatrix}\\
              &= -\frac{1}{10} \begin{bmatrix}
                -4&3\\
                6&-2
            \end{bmatrix}
            \begin{bmatrix}
                3\\
                1
            \end{bmatrix}\\
              &= \begin{bmatrix}
                0.9\\
                -1.6
            \end{bmatrix}
    \end{align*}
    $$

    \columnbreak

    \textbf{B:}\\

    $$
    \begin{align*}
        \det{A_1} &= 3(2) - (-2)(1) = 8\\
        A_1^{-1} &= \frac{1}{8} \begin{bmatrix}
            2&-1\\
            2&3
        \end{bmatrix}\\
        x &= \frac{1}{8} \begin{bmatrix}
            2&-1\\
            2&3
        \end{bmatrix}
        \begin{bmatrix}
            2\\
            -5
        \end{bmatrix}\\
        &= \begin{bmatrix}
            \frac{9}{8}\\
            -\frac{11}{8}
        \end{bmatrix}
    \end{align*}
    $$

    \end{multicols}

    \textbf{FORMULA:}\\

    $$
    A^{-1} = \frac{1}{\det(A)} \begin{bmatrix}
        d&-b\\-c&a
    \end{bmatrix}
    $$


\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
    Compute the determinant of

    $$
    \begin{equation*}
        A = \begin{bmatrix}
            1&2&-1\\
            2&0&2\\
            4&3&1
        \end{bmatrix}
    \end{equation*}
    \begin{equation*}
        A = \begin{bmatrix}
            2&-4&3\\
            1&1&1\\
            3&3&1
        \end{bmatrix}
    \end{equation*}
    \begin{equation*}
        A = \begin{bmatrix}
            1&0&1\\
            2&3&2\\
            -1&3&2
        \end{bmatrix}
    \end{equation*}
    \begin{equation*}
        A = \begin{bmatrix}
            1&2&3\\
            -5&-10&-15\\
            6&12&18
        \end{bmatrix}
    \end{equation*}
    $$

    \begin{itemize}
        \item Are they Invertible?
        \item Which of them has full rank? Which of them has lower rank and which one?
    \end{itemize}

    \textbf{Notes:} \\

    \begin{itemize}
        \item Rank is the number of linearly independent rows or columns.
        \item A matrix is invertible if they have full rank.
    \end{itemize}

    \answer


    \begin{multicols}{2}

    \part

    $$
    \begin{bmatrix}
        1&2&-1\\
        2&0&2\\
        4&3&1
    \end{bmatrix} \rightarrow \begin{bmatrix}
        1&2&-1\\
        0&1&-1\\
        0&0&0
    \end{bmatrix}
    $$
    
    $$
    \begin{align*}
        \det(A) &= 0+16-6-(0+6+4)\\
        &= 0
    \end{align*}
    $$

    This matrix is not invertible. Rank is 2.

    \columnbreak

    \part

    $$
    \begin{bmatrix}
        2&-4&3\\
        1&1&1\\
        3&3&1
    \end{bmatrix} \rightarrow \begin{bmatrix}
        1&1&-1\\0&1&-\frac{5}{6}\\0&0&1
    \end{bmatrix}
    
    $$
    
    $$
    \begin{align*}
        \det(A) &= 2-1+9-9-6+4\\
        &= -12
    \end{align*}
    $$

    This matrix is invertible. Rank is 3.

    \end{multicols}

    \pagebreak  

    \part

    \begin{multicols}{2}

    $$
    \begin{bmatrix}
        1&0&1\\
        2&3&2\\
        -1&3&2
    \end{bmatrix} \rightarrow \begin{bmatrix}
        1&0&1\\
        0&1&1\\
        0&0&1
    \end{bmatrix}
    $$
    
    $$
    \begin{align*}
        \det(A) &= 6+0+6+3-6-0\\
        &= 9
    \end{align*}
    $$

    This matrix is invertible. Rank is 3.

    \columnbreak

    \part

    $$
    \begin{bmatrix}
        1&2&3\\
        -5&-10&-15\\
        6&12&18
    \end{bmatrix} \rightarrow \begin{bmatrix}
        1&2&3\\
        0&0&0\\
        0&0&0
    \end{bmatrix}
    $$
    
    $$
    \begin{align*}
        \det(A) &= -180-180-180+180+180+180\\
        &= 0
    \end{align*}
    $$

    This matrix is not invertible and has rank 1.

    \end{multicols}


\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
    For what value $a$ the matrix is not invertible?

    $$
    \begin{equation*}
        A = \begin{bmatrix}
            1&2&1\\
            2&a&4\\
            -3&1&2
        \end{bmatrix}
    \end{equation*}
    $$

    \solution

    A matrix is not invertible if its determinant is zero.

    $$
    \begin{align*}
        \det(A) &= 2a-24+2+3a-4-8\\
        &= 5a-34\\
        5a-34 &= 0\\
        a &= \frac{34}{5} \approx 6.8
    \end{align*}

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
    Compute and apply the Householder matrix which makes transforms the first column of
    to a multple of the first one-hot vector $\begin{bmatrix}1\\0\\0\end{bmatrix}$ for

    $$
    \begin{equation*}
        A = \begin{bmatrix}
            1&2&-1\\
            2&0&2\\
            2&3&1
        \end{bmatrix}
    \end{equation*}
    $$

    and for (hint: here subtracting is nicer)

    $$
    \begin{equation*}
        A = \begin{bmatrix}
            1&-4&3\\
            3&1&1\\
            \sqrt{6}&3&1
        \end{bmatrix}
    \end{equation*}
    $$

    \textbf{Formula:} \\
    $$
    \begin{align*}
        u &= x \pm \left\lVert x \right\rVert_2 z\\
        H_u &= I - \frac{2}{u \cdot u} uu^T\\
        \text{Properties of H: }\\
        H_ux &= \mp \left\lVert x \right\rVert_2 z \text{ H maps x to $\mp \left\lvert x \right\rvert z$ given $u = x \pm \lvert x \rvert z$}\\
        H_u^\top H_u &= I \text{ H is an orthogonal matrix}\\
        H_u &= H_u^\top \text{ H is a symmetric matrix}\\
    \end{align*}
    $$

    \textbf{Example:}\\

    Here $A = \begin{bmatrix}3&1\\4&4\end{bmatrix}$ 

    $x = \begin{bmatrix}3\\4\end{bmatrix}$

    $\right \lVert x \right \rVert_2 = \sqrt{3^2 + 4^2} = \sqrt{25} = 5$
    
    \begin{multicols}{2}

    $$
    \begin{align*}
        u &= \begin{bmatrix}3\\4\end{bmatrix} \pm 5 \begin{bmatrix}1\\0\end{bmatrix} = \begin{bmatrix}-2\\4\end{bmatrix}\text{ (Choose Minus)}\\
        H &= \begin{bmatrix}1&0\\0&1\end{bmatrix}-\frac{2}{(-2)^2+4^2}\begin{bmatrix}-2\\4\end{bmatrix}\begin{bmatrix}-2&4\end{bmatrix}\\
          &= \begin{bmatrix}1&0\\0&1\end{bmatrix}-\frac{2}{20}\begin{bmatrix}4&-8\\-8&16\end{bmatrix}\\
          &= \begin{bmatrix}0.6&0.8\\0.8&-0.6\end{bmatrix}\\\\
        HA &= \begin{bmatrix}0.6&0.8\\0.8&-0.6\end{bmatrix}\begin{bmatrix}3&1\\4&4\end{bmatrix}\\
           &= \begin{bmatrix}5&3.8\\0&-1.6\end{bmatrix}
    \end{align*}
    $$
    
    \columnbreak

    $$
    \begin{align*}
        u &= \begin{bmatrix}3\\4\end{bmatrix} \pm 5 \begin{bmatrix}1\\0\end{bmatrix} = \begin{bmatrix}8\\4\end{bmatrix}\text{ (Choose Positive Sign)}\\
        H &= \begin{bmatrix}1&0\\0&1\end{bmatrix}-\frac{2}{(8)^2+4^2}\begin{bmatrix}8\\4\end{bmatrix}\begin{bmatrix}8&4\end{bmatrix}\\
          &= \begin{bmatrix}1&0\\0&1\end{bmatrix}-\frac{2}{80}\begin{bmatrix}64&32\\32&16\end{bmatrix}\\
          &= \begin{bmatrix}-0.6&-0.8\\-0.8&0.6\end{bmatrix}\\\\
        HA &= \begin{bmatrix}-0.6&-0.8\\-0.8&0.6\end{bmatrix}\begin{bmatrix}3&1\\4&4\end{bmatrix}\\
           &= \begin{bmatrix}-5&-3.8\\0&-1.6\end{bmatrix}
    \end{align*}
    $$

    \end{multicols}

    \pagebreak

    \part

    \begin{multicols}{2}

    $$
    \begin{align*}
        u &= \begin{bmatrix}1\\2\\2\end{bmatrix} \pm \lVert \begin{pmatrix}1,2,2\end{pmatrix} \rVert \begin{bmatrix}1\\0\\0\end{bmatrix} \\
          &= \begin{bmatrix}1\\2\\2\end{bmatrix} \pm \sqrt{1^2 + 2^2 + 2^2} \begin{bmatrix}1\\0\\0\end{bmatrix}\\
          &= \begin{bmatrix}1\\2\\2\end{bmatrix} - 3 \begin{bmatrix}1\\0\\0\end{bmatrix}\\
          &= \begin{bmatrix}1\\2\\2\end{bmatrix} - \begin{bmatrix}3\\0\\0\end{bmatrix}\\
          &= \begin{bmatrix}-2\\2\\2\end{bmatrix}\\
        H &= I - \frac{2}{12}uu^\top = I - \frac{1}{6}\begin{bmatrix}-2\\2\\2\end{bmatrix} \begin{bmatrix}-2&2&2\end{bmatrix} \\
          &= I - \frac{1}{6}\begin{bmatrix}4&-4&-4\\-4&4&4\\-4&4&4\end{bmatrix}\\
          &= \begin{bmatrix} 1&0&0\\0&1&0\\0&0&1\end{bmatrix} - \frac{1}{6}\begin{bmatrix}4&-4&-4\\-4&4&4\\-4&4&4\end{bmatrix}\\
          &= \begin{bmatrix}\frac{1}{3}&\frac{2}{3}&\frac{2}{3}\\\frac{2}{3}&\frac{1}{3}&\frac{1}{3}\\ \frac{2}{3}&\frac{1}{3}&\frac{1}{3}\end{bmatrix}\\
        HA &= \begin{bmatrix}3&2.67&1.67\\0&-0.67&-0.67\\0&2.33&-1.67\end{bmatrix}
    \end{align*}
    $$

    \columnbreak

    \part

    $$
    \begin{align*}
        u &= x - \lVert x \lVert z = \begin{bmatrix}1\\3\\\sqrt{6}\end{bmatrix} - 4\begin{bmatrix} 1\\0\\0 \end{bmatrix} = \begin{bmatrix} -3\\3\\\sqrt{6}\end{bmatrix}\\
        H &= I - \frac{2}{u\cdot u} uu^\top\\
          &= I - \frac{2}{24}\begin{bmatrix}-3\\3\\\sqrt{6}\end{bmatrix}\begin{bmatrix}-3&3&\sqrt{6}\end{bmatrix}\\
          &= \begin{bmatrix}\frac{1}{4}&\frac{3}{4}&\frac{\sqrt{6}}{4}\\\frac{3}{4}&\frac{1}{4}&-\frac{\sqrt{6}}{4}\\\frac{\sqrt{6}}{4}&-\frac{\sqrt{6}}{4}&\frac{1}{2}\end{bmatrix}\\
        HA &= \begin{bmatrix} 4&*&*\\0&*&*\\0&*&*\end{bmatrix}\\\\
        u &= x + \lVert x \lVert z = \begin{bmatrix}1\\3\\\sqrt{6}\end{bmatrix} + 4\begin{bmatrix} 1\\0\\0 \end{bmatrix} = \begin{bmatrix} 5\\3\\\sqrt{6}\end{bmatrix}\\
        H &= I - \frac{2}{u\cdot u} uu^\top\\
          &= \begin{bmatrix}-\frac{1}{4}&-\frac{3}{4}&-\frac{\sqrt{6}}{4}\\-\frac{3}{4}&\frac{11}{20}&-\frac{3\sqrt{6}}{70}\\-\frac{\sqrt{6}}{4}&-\frac{3\sqrt{6}}{70}&\frac{7}{10}\end{bmatrix}\\
        HA &= \begin{bmatrix} -4&*&*\\0&*&*\\0&*&*\end{bmatrix}
    \end{align*}
    $$


\end{multicols}



    

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
    Verify that

    $$
    \begin{equation*}
        A = \begin{bmatrix}
            1&0&0\\
            0&\cos(\alpha)&-\sin(\alpha)\\
            0&\sin(\alpha)&\cos(\alpha)
        \end{bmatrix}
    \end{equation*}
    $$

    Satisfies being an orthogonal matrix.

    Note: Cannot use determinant to verify.

    \answer

    $$
    \begin{align*}
        A^\top A &= \begin{bmatrix}
            1&0&0\\
            0&\cos(\alpha)&\sin(\alpha)\\
            0&-\sin(\alpha)&\cos(\alpha)
        \end{bmatrix} \begin{bmatrix}
            1&0&0\\
            0&\cos(\alpha)&-\sin(\alpha)\\
            0&\sin(\alpha)&\cos(\alpha)
        \end{bmatrix}\\
                 &= \begin{bmatrix}
            1&0&0\\
            0&\cos^2(\alpha) + \sin^2(\alpha)&-\sin(\alpha)\cos(\alpha) + \sin(\alpha)\cos(\alpha)\\
            0&-\sin(\alpha)\cos(\alpha) + \sin(\alpha)\cos(\alpha)&\sin^2(\alpha) + \cos^2(\alpha)
        \end{bmatrix}\\
        &= \begin{bmatrix}
            1&0&0\\
            0&1&0\\
            0&0&1
        \end{bmatrix}\\
    \end{align*}
    $$
    Thus A is an orthogonal matrix.

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}

    What is the cosine of the angle between

    $$
    \left( 6,-6,-4,\sqrt{12} \right), \left( 6,4,2,\sqrt{25} \right)?
    $$

    \solution

    $$
    \begin{align*}
        \cos(\angle(\vec{a},\vec{b})) &= \frac{\vec{a}\cdot\vec{b}}{\|\vec{a}\|\|\vec{b}\|}\\
        &= \frac{6\cdot6 + (-6)\cdot4 + (-4)\cdot2 + \sqrt{12}\cdot\sqrt{25}}{\sqrt{6^2+(-6)^2+(-4)^2+\sqrt{12}^2}\sqrt{6^2+4^2+2^2+\sqrt{25}^2}}\\
        &= \frac{36-24-8+5\sqrt{12}}{\sqrt{100}\sqrt{81}}\\
        &= \frac{4 + 5\sqrt{12}}{90}\\
        $\approx 0.24
    \end{align*}
\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
    Another $3\times3$ affine system

    \begin{itemize}
        \item show the intermediate result when the first column is the one hot vector $\begin{bmatrix}1&0&0\end{bmatrix}$ for the first time
        \item show that the intermediate result when the matrix has row echelon form for the first time
        \item get the solution
    \end{itemize}

    $$
    \begin{align*}
        2x-3y+2z &=-4\\
        7x+4.5y-1z &=16\\
        4x+3y+z &=2
    \end{align*}
    $$

    \solution

    \begin{multicols}{2}

    $$
    \begin{align*}
    &\left[ \begin{array}{rrr|r}
        2&-3&2&-4\\
        7&4.5&-1&16\\
        4&3&1&2
    \end{array} \right]\\
    \frac{1}{2} \rho_1 &\implies \left[ \begin{array}{rrr|r}
        1&-3/2&1&-2\\
        7&4.5&-1&16\\
        4&3&1&2
    \end{array} \right]\\
            (i) \rho_2 - 7\rho_1, \rho_3 - 4\rho_1 &\implies \left[ \begin{array}{rrr|r}
        1&-3/2&1&-2\\
        0&15&-8&30\\
        0&9&-3&10
    \end{array} \right]\\
    \frac{1}{15} \rho_2, -\frac{1}{3} \rho_3 &\implies \left[ \begin{array}{rrr|r}
        1&-3/2&1&-2\\
        0&1&-8/15&2\\
        0&-3&1&-\frac{10}{3}
    \end{array} \right]\\
    (ii) \rho_3 + 3\rho_2 &\implies \left[ \begin{array}{rrr|r}
        1&-3/2&1&-2\\
        0&1&-8/15&2\\
        0&0&1&-\frac{40}{9}
    \end{array} \right]\\
    \rho_2 + \frac{8}{15}\rho_3 &\implies \left[ \begin{array}{rrr|r}
        1&-3/2&1&-2\\
        0&1&0&-\frac{10}{27}\\
        0&0&1&-\frac{40}{9}
    \end{array} \right]\\
    \rho_1+\frac{3}{2}\rho_2 - \rho_3 &\implies \left[ \begin{array}{rrr|r}
            1&0&0&-\frac{17}{9}\\
        0&1&0&-\frac{10}{27}\\
        0&0&1&-\frac{40}{9}
    \end{array} \right]\\
    \begin{bmatrix}
        x\\
        y\\
        z
        \end{bmatrix} &= \begin{bmatrix}
        -\frac{17}{9}\\
        -\frac{10}{27}\\
        -\frac{40}{9}
    \end{bmatrix}
    \end{align*}
    $$
    \end{multicols}

\end{homeworkProblem}


\end{document}
