EXERCISES 4.1
\(\def\ds{\displaystyle} \)
1(a) To solve the normal equations we first calculate
\[A^TA =
\left[\begin{array}{rr}
5&4\\4&6\\
\end{array}\right]
\text{ and }
A^Tb =
\left[\begin{array}{r}
5\\8\\
\end{array}\right].\]
Solving \(A^TAx=A^Tb\) yields the least squares solution \(\overline{x}=[-1/7,10/7]^T\).
The residual error is \(e=b-A\overline{x}=[2/7, -3/7, -1/7]\) with 2-norm \(||e||_2 = \sqrt{\frac{4}{49}
+\frac{9}{49}+\frac{1}{49}} = \sqrt{14}/7\).
1 (b) The normal equations are \(A^TAx=A^Tb\) where
\[A^TA =
\left[\begin{array}{cc}
14&6\\6&3\\
\end{array}\right]
\text{ and }
A^Tb =
\left[\begin{array}{r}
5\\3\\
\end{array}\right].\]
Solving the normal equations gives the least squares solution \(\overline{x}=[-1/2,2]^T\).
The residual error is \(e=b-A\overline{x}=[-1/2, 1, -1/2]\) with 2-norm \(||e||_2 = \sqrt{\frac{1}{4}
+1+\frac{1}{4}} = \sqrt{6}/2\).
1 (c) The normal equations are \(A^TAx=A^Tb\) where
\[A^TA =
\left[\begin{array}{cc}
10&9\\9&10\\
\end{array}\right]
\text{ and }
A^Tb =
\left[\begin{array}{r}
16\\16\\
\end{array}\right].\]
The normal equations give \(\overline{x}=[16/19,16/19]^T\).
The residual error is \(e=b-A\overline{x}=[9/19,25/19,9/19,-26/19]\) with 2-norm \(||e||_2 \approx 2.013\).
3(a) The normal equations are \(A^TAx=A^Tb\) where
\[A^TA =
\left[\begin{array}{cc}
3&3\\3&5\\
\end{array}\right]
\text{ and }
A^Tb =
\left[\begin{array}{r}
9\\13
\end{array}\right].\]
The normal equations give \(\overline{x}=[1,2]^T\).
The residual error is \(e=b-A\overline{x}=[-1,7,3] - [1,3,5]=[-2,4,2]\) with
RMSE \( = \sqrt{((-2)^2+4^2+(-2)^2)/3} = \sqrt{8}\).
3(b) The normal equations are \(A^TAx=A^Tb\) where
\[A^TA =
\left[\begin{array}{cc}
3&6\\6&14\\
\end{array}\right]
\text{ and }
A^Tb =
\left[\begin{array}{r}
9\\22
\end{array}\right].\]
The normal equations give \(\overline{x}=[-1,2]^T\).
The residual error is \(e=b-A\overline{x}=[-1,7,3] - [1,3,5]=[-2,4,2]\) with
RMSE \( = \sqrt{((-2)^2+4^2+(-2)^2)/3} = \sqrt{8}\).
3(c) The normal equations are \(A^TAx=A^Tb\) where
\[A^TA =
\left[\begin{array}{ccc}
4&0&0\\0&6&0\\0&0&14\\
\end{array}\right]
\text{ and }
A^Tb =
\left[\begin{array}{r}
5\\9\\14
\end{array}\right].\]
The normal equations give \(\overline{x}=[5/4,3/2,1]^T\).
The residual error is \(e=b-A\overline{x}=[6,1,-1,-1] - [19/4,11/4,-3/4,-7/4]=
[5/4,-7/4,-1/4,3/4]\) with
RMSE \( = \sqrt{21/16}\).
3(d) The normal equations are \(A^TAx=A^Tb\) where
\[A^TA =
\left[\begin{array}{ccc}
4&0&0\\0&6&0\\0&0&56\\
\end{array}\right]
\text{ and }
A^Tb =
\left[\begin{array}{r}
10\\-3\\-14
\end{array}\right].\]
The normal equations give \(\overline{x}=[5/2,-1/2,-1/4]^T\).
The residual error is \(e=b-A\overline{x}=[1,2,3,4] - [1,2,3,4]=
[0,0,0,0]\) with
RMSE \( = 0\).
5 The normal equations are \(A^TAx=A^Tb\), or
\[
\left[\begin{array}{cc}
3&0\\0&0\\
\end{array}\right]
\left[\begin{array}{r}
x_0\\x_1\\
\end{array}\right]=
\left[\begin{array}{r}
12\\0\\
\end{array}\right].\]
Solving the normal equations gives \(x_0=4\) and \(x_1\) arbitrary. Therefore there are
infinitely many least squares solutions \(\overline{x}=[4,x_1]\).
7 The three properties:
(i) \(||x||_2\geq 0\) is guaranteed by the
definition \(||x||_2=\sqrt{x_0^2+\ldots+x_{n-1}^2}\), and if \(||x||_2=0\), all components
\(x_i\) must be zero.
(ii) For a scalar \(\alpha\),
\begin{eqnarray*}
||\alpha x||_2 &=&\sqrt{\alpha^2 x_0^2+\ldots+\alpha^2 x_{n-1}^2}\\
&=& |\alpha|\sqrt{x_0^2+\ldots+x_{n-1}^2}\\
&=& |\alpha|\cdot||x||_2
\end{eqnarray*}
(iii) Given two vectors \(x\) and \(y\),
\begin{eqnarray*}
||x+y||_2^2&=&(x_0+y_0)^2+\ldots+(x_{n-1}+x_{n-1})^2\\
&=&x_0^2+\ldots+x_{n-1}^2+y_0^2+\ldots+x_{n-1}^2+2(x_0y_0+\ldots+x_{n-1}x_{n-1})\\
&\leq& ||x||_2^2+||y||_2^2+2||x||_2||y||_2 = (||x||_2+||y||_2)^2
\end{eqnarray*}
where the Cauchy-Schwarz inequality was used to obtain the last line.
Taking square roots proves the triangle inequality for the 2-norm.
9 (a) Substituting the data points \((t,y)\) into the model \(y=c_0+c_1t\) gives the
five equations
\begin{eqnarray*}
c_0+c_1(-3)&=&\ \ \ 3\\
c_0+c_1(-1)&=&\ \ \ 2\\
c_0+c_1(0)&=&\ \ \ 1\\
c_0+c_1(1)&=&-1\\
c_0+c_1(3)&=&-4.
\end{eqnarray*}
Converting to matrix form,
\[Ax =
\left[\begin{array}{rr}
1&-3\\1&-1\\1&0\\1&1\\1&3\\
\end{array}\right]
\left[\begin{array}{r}
c_0\\c_1\\
\end{array}\right]=
\left[\begin{array}{r}
3\\2\\1\\-1\\-4\\
\end{array}\right]=b.\]
The normal equations are
\[\left[\begin{array}{cc}
5&0\\0&20\\
\end{array}\right]
\left[\begin{array}{r}
c_0\\c_1\\
\end{array}\right]=
\left[\begin{array}{r}
1\\-24\\
\end{array}\right]\]
and the least squares solution is \(\overline{c}=[1/5, -6/5]^T\), corresponding to the line
\(y=\frac{1}{5}-\frac{6}{5}t\). The residual error is \(e=[-4/5, 3/5, 4/5, 0, -3/5]^T\), which has RMSE
\[\frac{\sqrt{(-\frac{4}{5})^2+(\frac{3}{5})^2+(\frac{4}{5})^2+(-\frac{3}{5})^2}}{\sqrt{5}}
= \sqrt{\frac{2}{5}}.\]
7 (b) Similar to (a). The model \(y=c_0+c_1t\) leads to the system
\[Ax =
\left[\begin{array}{rr}
1&1\\1&1\\1&2\\1&2\\1&4\\
\end{array}\right]
\left[\begin{array}{r}
c_0\\c_1\\
\end{array}\right]=
\left[\begin{array}{r}
1\\2\\2\\3\\3\\
\end{array}\right]=b.\]
The normal equations are
\[\left[\begin{array}{cc}
5&10\\10&26\\
\end{array}\right]
\left[\begin{array}{r}
c_0\\c_1\\
\end{array}\right]=
\left[\begin{array}{r}
11\\25\\
\end{array}\right]\]
and the least squares solution is \(\overline{c}=[6/5, 1/2]^T\),
corresponding to the line
\(y=6/5+t/2\). The residual error is \(e=[-0.7, 0.3, -0.2, 0.8, -0.2]^T\),
which has RMSE = \(\sqrt{26}/10\).
11 (a) Substituting the four data points into the model \(y=c_0+c_1t+c_2t^2\)
results in the system of equations
\[\left[\begin{array}{ccc}
1&0&0\\
1&1&1\\
1&2&4\\
1&5&25\\
\end{array}\right]
\left[\begin{array}{r}
c_0\\c_1\\c_2\\
\end{array}\right]=
\left[\begin{array}{r}
0\\3\\3\\6\\
\end{array}\right]\]
The normal equations are
\[\left[\begin{array}{ccc}
4&8&30\\
8&30&134\\
30&134&642\\
\end{array}\right]
\left[\begin{array}{r}
c_0\\c_1\\c_2\\
\end{array}\right]=
\left[\begin{array}{c}
12\\39\\165\\
\end{array}\right].\]
Solving for \(c_0,c_1, c_2\) leads to the least squares parabola
\(y=0.3481+1.9475t-0.1657t^2\). The RMSE is \(0.5519\), compared to
\(0.6944\) for the least squares line fit in Exercise 8(a).
11 (b) Substituting the four data points into the model \(y=c_0+c_1t+c_2t^2\)
results in the system of equations
\[\left[\begin{array}{ccc}
1&1&1\\
1&3&9\\
1&4&16\\
1&6&36\\
\end{array}\right]
\left[\begin{array}{r}
c_0\\c_1\\c_2\\
\end{array}\right]=
\left[\begin{array}{r}
2\\2\\1\\3\\
\end{array}\right]\]
Solving the normal equations for \(c_0, c_1, c_2\) yields the best parabola
\(y=2.9615-1.0128t+0.1667t^2\). The RMSE is \(0.4160\), compared to \(0.6504\)
for the best line in Exercise 8(b).
11 (c) Substituting into the model parabola gives the system of
equations
\[\left[\begin{array}{ccc}
1&0&0\\
1&1&1\\
1&2&4\\
1&3&9\\
\end{array}\right]
\left[\begin{array}{r}
c_0\\c_1\\c_2\\
\end{array}\right]=
\left[\begin{array}{r}
5\\3\\3\\1\\
\end{array}\right].\]
The normal equations are
\[\left[\begin{array}{ccc}
4&6&14\\
6&14&36\\
14&36&98\\
\end{array}\right]
\left[\begin{array}{r}
c_0\\c_1\\c_2\\
\end{array}\right]=
\left[\begin{array}{r}
12\\12\\24\\
\end{array}\right]\]
Solving the normal equations gives \(c_0=4.8, c_1= -1.2, c_2=0.\)
Therefore the best fit polynomial of degree two or less is the
line \(y=4.8-1.2t\). The RMSE is \(0.4472\).
13 Substituting the data points into the given model
\(h=a+bt-4.905t^2\) results in the system
\begin{eqnarray*}
a+b(1)-4.905(1)^2&=& 135\\
a+b(2)-4.905(2)^2&=& 265\\
a+b(3)-4.905(3)^2&=& 385\\
a+b(4)-4.905(4)^2&=& 485
\end{eqnarray*}
which leads to the inconsistent system
\[\left[\begin{array}{ccc}
1&1\\
1&2\\
1&3\\
1&4\\
\end{array}\right]
\left[\begin{array}{r}
a\\b\\
\end{array}\right]=
\left[\begin{array}{r}
135+4.905\\
265+(4)4.905\\
385+(9)4.905\\
485+(16)4.905\\
\end{array}\right]\]
Solving the normal equations for \(a,b\) yields \(a=0.475, b=141.525\).
The best model is the height \(h(t) = 0.475+141.525t-4.905t^2\).
The maximum height occurs when \(0=h'(t)=141.525-9.81t\), or approximately
\(t=14.4\) seconds.
The corresponding height is 1021 meters. The rocket returns to earth
at time \(28.9\) seconds, found from the quadratic formula.