\documentclass[twoside]{article}

\usepackage{palatino}
\usepackage{camnum}

\textheight=22.5cm
\textwidth=15cm
\topmargin=-1cm
\oddsidemargin=0.5cm
\evensidemargin=0.5cm
\parindent=0pt
\parskip=6pt

\begin{document}
\begin{center}
  {\large \textbf{Mathematical Tripos Part IB: Easter 2001}}

  {\Large \textbf{Numerical Analysis -- Detailed Example
      7\footnote{Corrections and suggestions to these notes should
        be emailed to \texttt{a.shadrin@damtp.cam.ac.uk}. All handouts
        are available on the WWW at the URL 
        \texttt{http://www.damtp.cam.ac.uk/user/na/PartIB/Handouts.html}.}}}

  \vspace{8pt}
  \textbf{\textit{\LARGE Least squares}}
\end{center}

We wish to find $\MM{x}\in\BB{R}^3$ that minimizes
$\|A\MM{x}-\MM{b}\|$, where
\begin{displaymath}
  A=\left[
    \begin{array}{rrr}
      5 &    3 &    9\\
      -7  &  -2 &   -1\\
      5  &   6 &   -3\\
      1  &  -2 &   -6\\
      0   &  3 &    4\\
      7  &   5  &   4
    \end{array}\right],\qquad \MM{b}=\left[
    \begin{array}{r}
      1\\  1\\ -7\\  1\\  1\\ -5
    \end{array}\right].
\end{displaymath}
We QR-factorize,
\begin{Eqnarray*}
  Q&=&\left[
    \begin{array}{rrrrrr}
      -0.4096 &   0.0159 &   0.6347 &   0.3490 &  -0.2690 &  -0.4847\\
      0.5735 &  -0.4226 &   0.0308 &   0.4934  & -0.4720  &  0.1592\\
      -0.4096 &  -0.5301 &  -0.6075 &  -0.0280 &  -0.2158 &  -0.3671\\
      -0.0819 &   0.4763 &  -0.4294 &   0.7352 &   0.1955 &  -0.0566\\
      0.0000 &   -0.5460 &   0.1933 &   0.2609 &   0.7723 &  -0.0055\\
      -0.5735 &  -0.1234 &   0.0728 &   0.1591 &  -0.1536 &   0.7757
    \end{array}\right]\\
  R&=&\left[
    \begin{array}{rrr}
       -12.2066  & -7.5369 &  -4.8335\\
       0.0000 &   -5.4950 &  -3.3795\\
       0.0000 & 0.0000 &  11.1452\\
       0.0000 & 0.0000 & 0.0000\\
       0.0000 & 0.0000 & 0.0000\\
       0.0000 & 0.0000 & 0.0000
    \end{array}\right].
\end{Eqnarray*}
We thus need to solve $\tilde{R}\MM{x}=\tilde{\MM{b}}$, where 
\begin{displaymath}
  \tilde{R}=\left[
    \begin{array}{rrr}
       -12.2066  & -7.5369 &  -4.8335\\
       0.0000 &   -5.4950 &  -3.3795\\
       0.0000 & 0.0000 &  11.1452
     \end{array}\right]
\end{displaymath}
is the upper $3\times 3$ block of $R$ and 
\begin{displaymath}
  \tilde{\MM{b}}=\left[
    \begin{array}{r}
      5.8165\\    3.8510\\  4.3183
    \end{array}\right]
\end{displaymath}
is made out of the three top elements of $Q^{\CC{T}}\MM{b}$. The
outcome is
\begin{displaymath}
  \MM{x}=\left[
  \begin{array}{r}
    -0.0501\\-0.9391\\ 0.3875
  \end{array}\right].
\end{displaymath}


\end{document}
%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
