499 lines
14 KiB
TeX
499 lines
14 KiB
TeX
\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}{Revision\ Tutorial\ 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}}
|
|
|
|
\def\therefore{\boldsymbol{\text{ }
|
|
\leavevmode
|
|
\lower0.4ex\hbox{$\cdot$}
|
|
\kern-.5em\raise0.7ex\hbox{$\cdot$}
|
|
\kern-0.55em\lower0.4ex\hbox{$\cdot$}
|
|
\thinspace\text{ }}}
|
|
|
|
\begin{document}
|
|
|
|
\maketitle
|
|
|
|
\pagebreak
|
|
|
|
\begin{homeworkProblem}
|
|
Remove vector $u=(-1,3,-4,2)$ from vector $v=(-2,2,2.5,6)$\\
|
|
|
|
\answer
|
|
|
|
$$v_{new} = v - \frac{v\cdot u}{u\cdot u}u$$
|
|
|
|
$$
|
|
\begin{align*}
|
|
u\cdot u &= (-1,3,-4,2)\cdot (-1,3,-4,2) = 30\\
|
|
v\cdot u &= (-2,2,2.5,6)\cdot (-1,3,-4,2) = 10\\
|
|
\end{align*}
|
|
$$
|
|
|
|
$$
|
|
\begin{align*}
|
|
v_{new} &= (-2,2,2.5,6) - \frac{10}{30}(-1,3,-4,2) \\
|
|
&= (-2,2,2.5,6) +(\frac{1}{3},-1,\frac{4}{3}, -\frac{2}{3})\\
|
|
&= (-\frac{5}{3},1,\frac{13}{6},\frac{16}{3})
|
|
\end{align*}
|
|
$$
|
|
|
|
You can check:
|
|
$$
|
|
v_{new}\cdot u = (-\frac{5}{3},1,\frac{13}{6},\frac{16}{3})\cdot (-1,3,-4,2) = 0
|
|
$$
|
|
|
|
\end{homeworkProblem}
|
|
|
|
\pagebreak
|
|
|
|
\begin{homeworkProblem}
|
|
Note the difference in the order between remove from and project onto.\\
|
|
Project vector $u=(-1,-3,-4,2)$ onto vector $v=(3,-3,-1,1)$\\
|
|
|
|
\answer
|
|
|
|
$$u_{new} = \frac{u\cdot v}{v\cdot v}v$$
|
|
|
|
$$
|
|
\begin{align*}
|
|
u_{new} &= \frac{(-1,-3,-4,2)\cdot (3,-3,-1,1)}{(3,-3,-1,1)\cdot (3,-3,-1,1)}(3,-3,-1,1)\\
|
|
&= \frac{12}{20}(3,-3,-1,1)\\
|
|
\end{align*}
|
|
$$
|
|
|
|
|
|
\end{homeworkProblem}
|
|
|
|
\pagebreak
|
|
|
|
\begin{homeworkProblem}
|
|
|
|
$$
|
|
\begin{align*}
|
|
x+4y+2z &=5.5\\
|
|
-5x-22y-5z &= -45.5\\
|
|
2x+4y+14z &=-25
|
|
\end{align*}
|
|
$$
|
|
|
|
\begin{itemize}
|
|
\item Show as an itermediate step the augmented matrix when for the first time the zeroth coulmn became a one-hot vector after performing transformations
|
|
\item Show as an intermediate step the augmented matrix when for the first time the augmented matrix is in row echelon form.
|
|
\item Write the set of all solutions as a single vector or a combination of vectors, None if there is no solution
|
|
\end{itemize}
|
|
|
|
\solution
|
|
|
|
$$
|
|
\begin{align*}
|
|
&\left[
|
|
\begin{array}{ccc|c}
|
|
1 & 4 & 2 & 5.5\\
|
|
-5 & -22 & -5 & -45.5\\
|
|
2 & 4 & 14 & -25
|
|
\end{array} \right] \\
|
|
\rho_2+5\rho_1, \rho_3-2\rho_1 &\rightarrow \left[
|
|
\begin{array}{ccc|c}
|
|
1 & 4 & 2 & 5.5\\
|
|
0 & -2 & 5 & -18\\
|
|
0 & -4 & 10 & -36
|
|
\end{array} \right] \\
|
|
\rho_3-2\rho_2 &\rightarrow \left[
|
|
\begin{array}{ccc|c}
|
|
1 & 4 & 2 & 5.5\\
|
|
0 & -2 & 5 & -18\\
|
|
0 & 0 & 0 & 0
|
|
\end{array} \right] \\
|
|
-\frac{1}{2}\rho_2&\rightarrow \left[
|
|
\begin{array}{ccc|c}
|
|
1 & 4 & 2 & 5.5\\
|
|
0 & 1 & -2.5 & 9\\
|
|
0 & 0 & 0 & 0
|
|
\end{array} \right] \\
|
|
\rho_1+4\rho_2 &\rightarrow \left[
|
|
\begin{array}{ccc|c}
|
|
1 & 0 & 12 & -30.5\\
|
|
0 & 1 & -2.5 & 9\\
|
|
0 & 0 & 0 & 0
|
|
\end{array} \right] \\
|
|
\end{align*}
|
|
$$
|
|
|
|
$$
|
|
\begin{align*}
|
|
x + 12z &= -30.5\\
|
|
y - 2.5z &= 9\\\\
|
|
\therefore x &= -30.5 - 12z\\
|
|
\therefore y &= 9 + 2.5z\\
|
|
\therefore z &= 0 + 1z\\\\
|
|
\begin{bmatrix} x\\ y\\ z \end{bmatrix} &= \begin{bmatrix}
|
|
-30.5\\9\\0\end{bmatrix} + \begin{bmatrix} -12\\2.5\\1\end{bmatrix}z
|
|
\end{align*}
|
|
$$
|
|
|
|
\end{homeworkProblem}
|
|
|
|
\pagebreak
|
|
|
|
\begin{homeworkProblem}
|
|
|
|
$$
|
|
\begin{align*}
|
|
x+3y-5z &=2.75\\
|
|
3x+12y-13z &=-9.75\\
|
|
-4x-6y+25z &=-46.25
|
|
\end{align*}
|
|
$$
|
|
|
|
\begin{itemize}
|
|
\item Show as an itermediate step the augmented matrix when for the first time the zeroth coulmn became a one-hot vector after performing transformations
|
|
\item Show as an intermediate step the augmented matrix when for the first time the augmented matrix is in row echelon form.
|
|
\item Write the set of all solutions as a single vector or a combination of vectors, None if there is no solution
|
|
\end{itemize}
|
|
|
|
\answer
|
|
|
|
|
|
$$
|
|
\left[ \begin{array}{ccc|c}
|
|
1 & 3 & -5 & 2.75\\
|
|
3 & 12 & -13 & -9.75\\
|
|
-4 & -6 & 25 & -46.25
|
|
\end{array} \right] \\
|
|
$$
|
|
|
|
$$
|
|
\begin{align*}
|
|
\rho_2-3\rho_1, \rho_3+4\rho_1 &\rightarrow \left[ \begin{array}{ccc|c}
|
|
1 & 3 & -5 & 2.75\\
|
|
0 & 3 & 2 & -18\\
|
|
0 & 6 & 5 & -35.25
|
|
\end{array} \right] \\
|
|
\rho_3-2\rho_2 &\rightarrow \left[ \begin{array}{ccc|c}
|
|
1 & 3 & -5 & 2.75\\
|
|
0 & 3 & 2 & -18\\
|
|
0 & 0 & 1 & 0.75
|
|
\end{array} \right] \\
|
|
\frac{1}{3}\rho_2-2\rho_1 &\rightarrow \left[ \begin{array}{ccc|c}
|
|
1 & 3 & -5 & 2.75\\
|
|
0 & 1 & 0 & -6.5\\
|
|
0 & 0 & 1 & 0.75
|
|
\end{array} \right] \\
|
|
\rho_1-3\rho_2+5\rho_1 &\rightarrow \left[ \begin{array}{ccc|c}
|
|
1 & 0 & 0 & 26\\
|
|
0 & 1 & 0 & -6.5\\
|
|
0 & 0 & 1 & 0.75
|
|
\end{array} \right] \\
|
|
\end{align*}
|
|
$$
|
|
|
|
$$
|
|
\begin{align*}
|
|
\text{first time one hot:}& \left [ \begin{array}{ccc|c}
|
|
1 & 3&-5 & 2.75\\
|
|
0 & 3 & 2 & -18\\
|
|
0 & 6 & 5 & -35.25
|
|
\end{array} \right ] \\
|
|
\text{first time row echelon form:}& \left [ \begin{array}{ccc|c}
|
|
1&3&-5&2.75\\
|
|
0&1&\frac{2}{3}&6\\
|
|
0&0&1&0.75
|
|
\end{array} \right ] \\
|
|
\text{Reduced row echelon form:}& \left[ \begin{array}{ccc|c}
|
|
1&0&0&26\\
|
|
0&1&0&-6.5\\
|
|
0&0&1&0.75
|
|
\end{array} \right ] \\
|
|
\end{align*}
|
|
$$
|
|
|
|
\end{homeworkProblem}
|
|
|
|
\pagebreak
|
|
|
|
\begin{homeworkProblem}
|
|
Compute the inverse of
|
|
$$
|
|
\begin{align*}
|
|
A_0 &= \begin{bmatrix}9&-2\\3&-4\end{bmatrix}\\
|
|
A_1 &= \begin{bmatrix}10&3\\8&4\end{bmatrix}\\
|
|
\end{align*}
|
|
$$
|
|
Use these inverses to Solve
|
|
$$
|
|
\begin{align*}
|
|
A_0x &= \begin{bmatrix}1\\-2\end{bmatrix}\\
|
|
A_1x &= \begin{bmatrix}-7\\4\end{bmatrix}\\
|
|
\end{align*}
|
|
$$
|
|
|
|
\answer
|
|
|
|
\begin{multicols}{2}
|
|
|
|
$$
|
|
\begin{align*}
|
|
A_0 &= \begin{bmatrix}9&-2\\3&-4\end{bmatrix}\\
|
|
\det(A_0) &= 9\cdot(-4) - (-2)\cdot3 =-36+6 = -30\\
|
|
A_0^{-1} &= \frac{1}{-30}\begin{bmatrix}-4&2\\-3&-9\end{bmatrix}\\
|
|
&= \begin{bmatrix}\frac{2}{15}&-\frac{1}{15}\\\frac{1}{10}&-\frac{3}{10}\end{bmatrix}\\
|
|
x &= A_0^{-1}\begin{bmatrix}1\\-2\end{bmatrix}\\
|
|
&= \begin{bmatrix}\frac{2}{15}&-\frac{1}{15}\\\frac{1}{10}&-\frac{3}{10}\end{bmatrix}\begin{bmatrix}1\\-2\end{bmatrix}\\
|
|
&= \begin{bmatrix}\frac{2}{15}+\frac{2}{15}\\\frac{1}{10}+\frac{6}{10}\end{bmatrix}\\
|
|
&= \begin{bmatrix}\frac{4}{15}\\\frac{7}{10}\end{bmatrix}\\
|
|
\end{align*}
|
|
$$
|
|
|
|
\columnbreak
|
|
|
|
$$
|
|
\begin{align*}
|
|
A_1 &= \begin{bmatrix}10&3\\8&4\end{bmatrix}\\
|
|
\det(A_1) &= 10\cdot4 - 3\cdot8 = 40-24 = 16\\
|
|
A_1^{-1} &= \frac{1}{16}\begin{bmatrix}4&-3\\-8&10\end{bmatrix}\\
|
|
&= \begin{bmatrix}\frac{1}{4}&-\frac{3}{16}\\\frac{-1}{2}&\frac{5}{8}\end{bmatrix}\\
|
|
x &= \begin{bmatrix}\frac{1}{4}&-\frac{3}{16}\\\frac{-1}{2}&\frac{5}{8}\end{bmatrix} \begin{bmatrix}-7\\4\end{bmatrix}\\
|
|
&= \begin{bmatrix}-\frac{10}{4}\\6\end{bmatrix}\\
|
|
\end{align*}
|
|
$$
|
|
|
|
\end{multicols}
|
|
|
|
\end{homeworkProblem}
|
|
\pagebreak
|
|
|
|
\begin{homeworkProblem}
|
|
Compute the determinant of
|
|
$$
|
|
\begin{align*}
|
|
A &= \begin{bmatrix}3&-1&4\\5&2.5&3\\1&8&-6\end{bmatrix}\\
|
|
A &= \begin{bmatrix}3&-2&0.5\\2.5&-3&1\\3&2&4\end{bmatrix}\\
|
|
A &= \begin{bmatrix}2&-2&2\\8&3&-2\\10&-4.5&5\end{bmatrix}\\
|
|
\end{align*}
|
|
$$
|
|
|
|
\begin{itemize}
|
|
\item Are they invertible?
|
|
\item Which of them has full rank? Which one of them has lower rank and which one?
|
|
\end{itemize}
|
|
|
|
\answer
|
|
|
|
\begin{multicols}{3}
|
|
|
|
$$
|
|
\begin{align*}
|
|
A &= \begin{bmatrix}3&-1&4\\5&2.5&3\\1&8&-6\end{bmatrix}\\
|
|
\det{A} &= 0 (\text{not invertible})\\
|
|
\text{rank} &= 2\\
|
|
\end{align*}
|
|
$$
|
|
|
|
$$
|
|
\begin{align*}
|
|
A &= \begin{bmatrix}3&-2&0.5\\2.5&-3&1\\3&2&4\end{bmatrix}\\
|
|
\det{A} &= -21 (\text{invertible})\\
|
|
\text{rank} &= 3\\
|
|
\end{align*}
|
|
$$
|
|
|
|
$$
|
|
\begin{align*}
|
|
A &= \begin{bmatrix}2&-2&2\\8&3&-2\\10&-4.5&5\end{bmatrix}\\
|
|
\det{A} &= 0 (\text{not invertible})\\
|
|
\text{rank} &= 2\\
|
|
\end{align*}
|
|
$$
|
|
|
|
\end{multicols}
|
|
|
|
\end{homeworkProblem}
|
|
\pagebreak
|
|
|
|
\begin{homeworkProblem}
|
|
What is the determinant of this matrix? Write it as a polynomial in $c$.\\
|
|
For what value $c$ the matrix is not invertible?
|
|
|
|
$$
|
|
A = \begin{bmatrix}6&-3&c\\5&2&2\\-2&-6&-2\end{bmatrix}
|
|
$$
|
|
|
|
\answer
|
|
|
|
$$
|
|
\begin{align*}
|
|
\det(A) &= 30-30c+4c\\
|
|
&= 30-26c\\
|
|
\det(A) &= 0\\
|
|
\therefore c &= \frac{30}{26}\\
|
|
\end{align*}
|
|
|
|
\end{homeworkProblem}
|
|
|
|
\pagebreak
|
|
|
|
\begin{homeworkProblem}
|
|
\textbf{Compute and apply} the Householder matrix which makes transforms the first column of $A$ to a multipile of the first one-hot vector for
|
|
|
|
$$
|
|
A = \begin{bmatrix}8&1&2\\4&-1&3\\-8&4&2\end{bmatrix}
|
|
$$
|
|
and for (Subtracting is nicer)\\
|
|
|
|
$$
|
|
A = \begin{bmatrix}3&-4&3\\\sqrt{2}&6&4\\\sqrt{5}&3&2\end{bmatrix}
|
|
$$
|
|
|
|
\answer
|
|
|
|
\begin{multicols}{2}
|
|
|
|
\part
|
|
|
|
$$
|
|
\begin{align*}
|
|
x &=\begin{bmatrix}8\\4\\-8\end{bmatrix}\\
|
|
u &= \begin{bmatrix}8\\4\\-8\end{bmatrix} \pm \lVert \begin{bmatrix}8,4,-8\end{bmatrix}\rVert \begin{bmatrix}1\\0\\0\end{bmatrix}\\
|
|
&= \begin{bmatrix}-4\\4\\-8\end{bmatrix} \text{ Subtract}\\
|
|
H_u &= I - \frac{2}{\lVert [-4,4,-8]\rVert_2^2}\begin{bmatrix}8\\4\\-8\end{bmatrix}\begin{bmatrix}8&4&8\end{bmatrix}\\
|
|
&= \begin{bmatrix}\frac{2}{3}&\frac{1}{3}&-\frac{2}{3}\\\frac{1}{3}&\frac{2}{3}&\frac{2}{3}\\-\frac{2}{3}&\frac{2}{3}&-\frac{1}{3}\end{bmatrix}\\
|
|
HA &= \begin{bmatrix}12 &-2.44 & 1\\0 & 2.33 & 4\\0&-2.7&0\end{bmatrix}\\
|
|
\end{align*}
|
|
$$
|
|
|
|
\columnbreak
|
|
|
|
\part
|
|
|
|
$$
|
|
\begin{align*}
|
|
x &= \begin{bmatrix}3\\\sqrt{2}\\ \sqrt{5}\end{bmatrix}\\
|
|
u &= \begin{bmatrix}3\\\sqrt{2}\\ \sqrt{5}\end{bmatrix} \pm \lVert \begin{bmatrix}3,\sqrt{2},\sqrt{5}\end{bmatrix}\rVert \begin{bmatrix}1\\0\\0\end{bmatrix}\\
|
|
&= \begin{bmatrix}-1\\\sqrt{2}\\ \sqrt{5}\end{bmatrix} \text{ Subtract}\\
|
|
H_u &= I - \frac{2}{\lVert [-1,\sqrt{2},\sqrt{5}]\rVert_2^2}\begin{bmatrix}-1\\\sqrt{2}\\\sqrt{5}\end{bmatrix}\begin{bmatrix}-1&\sqrt{2}&\sqrt{5}\end{bmatrix}\\
|
|
&= \begin{bmatrix}\frac{3}{4}&\frac{\sqrt{2}}{4}&\frac{\sqrt{5}}{4}\\\frac{\sqrt{2}}{4}&\frac{1}{2}&-\frac{\sqrt{2}\sqrt{5}}{4}\\\frac{\sqrt{5}}{4}&-\frac{\sqrt{5}\sqrt{2}}{4}&-\frac{1}{4}\end{bmatrix}\\
|
|
HA &= \begin{bmatrix}4&0.8&4.78\\0&-0.79&1.48\\0&-7.73&-1.99\end{bmatrix}\\
|
|
\end{align*}
|
|
$$
|
|
|
|
\end{multicols}
|
|
|
|
\end{homeworkProblem}
|
|
\pagebreak
|
|
|
|
\end{document}
|