Recall tutorial 1 where we talked about the condition number of a function, $f(x)$. As the error in $x$ increases, how does the error in $f(x)$ increase with it?
Imagine we have a system of linear equations $Ax = b$. As the error in $b$ increases, how does the error in $x$ increase? This can also be quantified with the condition number of $A$.
$$cond(A) = \frac{\sigma_{max}}{\sigma_{min}}$$
Question 1: Find the condition number for matrices $A_1$ and $A_2$.
Question 2: (From the 2014 test) The eigenvectors of $A^TA$ are $v_1 = \begin{bmatrix} 1 \\ 1 \end{bmatrix}$ and $v_2 = \begin{bmatrix} -1 \\ 1 \end{bmatrix}$. Find the eigenvalues.
Question 3: With help form the linalg library, find the amount of $a_1$ in the direction of the first principal component ($u_1$) and the second principal component ($u_2$). Remember to centre $A$ first.
There are three files on the tutorial page. sheev.pgm is a $150\times 200$ pgm file, code.txt is a $150\times 2561$ matrix which contains a hidden code, and tutorial3Q4.ipynb contains some useful functions.
Question 4: Find the secret code in matrix $C$ (code.txt). First, find the principal component matrix $U$ of the $A$ matrix (sheev.pgm). Then, find $U_2$ - the matrix which contains the first two principal components of $A$. Finally, apply $U_2$ to code.txt to project the code.txt onto the first two principal components of sheev.pgm. This will give a 2×2561 matrix. Plot these two rows using the plot_first_2_rows(mat) function.