Section5.7Practice Problems in Numerical Linear Algebra
You will turn in 1 MATLAB file to Moodle that contains all of the code to solve the problems in this section. Be sure to also submit all current support codes to the dropbox as well.
Find a least squares solution to the equation \(A \bx = \bb\) in two different ways with \begin{equation*} A = \begin{pmatrix}1 \amp 3 \amp 5 \\ 4 \amp -2 \amp 6 \\ 4 \amp 7 \amp 8 \\ 3 \amp 7 \amp 19 \end{pmatrix} \text{ and } \bb = \begin{pmatrix}5 \\ 2 \\ -2 \\ 8 \end{pmatrix} . \end{equation*}
Find the largest eigenvalue of the matrix \(A\) WITHOUT using the built in “eig” or “eigs” commands in MATLAB. \begin{equation*} A = \begin{pmatrix}1 \amp 2 \amp 3 \amp 4 \\ 5 \amp 6 \amp 7 \amp 8 \\ 9 \amp 0 \amp 1 \amp 2 \\ 3 \amp 4 \amp 5 \amp 6 \end{pmatrix} \end{equation*}
Find a least square cubic function that best fits the following data. Solve this problem with Excel and with MATLAB using the normal equations.
\(x\) | \(y\) |
0 | 1.0220 |
0.0500 | 1.0174 |
0.1000 | 1.0428 |
0.1500 | 1.0690 |
0.2000 | 1.0505 |
0.2500 | 1.0631 |
0.3000 | 1.0458 |
0.3500 | 1.0513 |
0.4000 | 1.0199 |
0.4500 | 1.0180 |
0.5000 | 1.0156 |
0.5500 | 0.9817 |
0.6000 | 0.9652 |
0.6500 | 0.9429 |
0.7000 | 0.9393 |
0.7500 | 0.9266 |
0.8000 | 0.8959 |
0.8500 | 0.9014 |
0.9000 | 0.8990 |
0.9500 | 0.9038 |
1.0000 | 0.8989 |
(Coding Challenge) The following iterative sequence is defined for the set of positive integers: \begin{align*} \amp n \to \frac{n}{2} \text{ (n is even) }\\ \amp n \to 3n + 1 \text{ (n is odd) } \end{align*}
Using the rule above and starting with \(13\), we generate the following sequence: \begin{equation*} 13 \to 40 \to 20 \to 10 \to 5 \to 16 \to 8 \to 4 \to 2 \to 1 \end{equation*}
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.
Write code to determine which starting number, under one million, produces the longest chain? NOTE: Once the chain starts the terms are allowed to go above one million