
\documentclass[12pt]{article}
\usepackage{fancyhdr,fancybox,amssymb,epsfig,amsmath,latexsym,bm}
\usepackage{enumerate}
\usepackage{tikz}
\usepackage[all]{xy}
\usepackage[numbers,square,sort&compress]{natbib}
\usepackage{bibentry}
\usepackage{stackrel}
\usepackage[]{hyperref}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\usepackage{url}

\tikzset{big arrow/.style={decoration={markings,mark=at position 0.6
      with {\arrow[scale=2]{>}}}, postaction={decorate}, shorten >=1pt}}

% Code to make an augmented matrix (Usage: \begin{bmatrix}[ccc|c])
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother

\topmargin=-.5in
\headsep=0.2in
\oddsidemargin=0in
\textwidth=6.7in
\textheight=9.2in
\footskip=.5in

\definecolor{faded}{rgb}{.75,.75,.75}
\tikzstyle{f} = [faded]

% Change this line to \def\bold{\mathbf} for ``upright boldface.''
\def\bold{\bm}

\newcommand{\F}{\mathbb{F}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}
\def\0{\bold{0}}
\def\A{\bold{A}}
\def\B{\bold{B}}
\def\C{\bold{C}}
\def\F{\bold{F}}
\def\I{\bold{I}}
\def\M{\mathcal{M}}
\def\N{\bold{N}}
\def\U{\bold{U}}
\def\0{\bold{0}}
\def\b{\bold{b}}
\def\e{\bold{e}}
\def\p{\bold{p}}
\def\s{\bold{s}}
\def\t{\bold{t}}
\def\u{\bold{u}}
\def\v{\bold{v}}
\def\x{\bold{x}}
\def\<{\langle}
\def\>{\rangle}
\def\hat{\widehat}
\newcommand\longto{\longrightarrow}

\def\And{\wedge}
\def\Or{\vee}
\newcommand{\Not}[1]{\overline{#1}}
\DeclareMathOperator{\old}{old}
\DeclareMathOperator{\Span}{Span}
\DeclareMathOperator{\rank}{rank}
\newcommand{\vv}[2]{\begin{bmatrix} #1 \\ #2 \end{bmatrix}}
\newcommand{\vvv}[3]{\begin{bmatrix} #1 \\ #2 \\ #3 \end{bmatrix}}

\newcommand{\ds}{\displaystyle}

\renewcommand{\footrulewidth}{1pt}
\newenvironment{proof}[1][Proof.]{\smallskip\begin{trivlist}
    \item[\hskip \labelsep {\sffamily #1}]}{\qed\end{trivlist}\bigskip}
\newenvironment{sol}[1][Solution.]{\smallskip\begin{trivlist}
    \item[\hskip \labelsep {\sffamily #1}]}{\qed\end{trivlist}\bigskip}
\newenvironment{fminipage}
{\setlength{\fboxsep}{15pt}\begin{Sbox}\begin{minipage}}
{\end{minipage}\end{Sbox}\fbox{\TheSbox}}
\newcommand{\qed}{\hfill \ensuremath{\Box}}
\newcommand{\disp}{\displaystyle}



\setlength{\headheight}{15pt}
\lhead{{\sf Bridge course (Algebra)}: Thursday July 3}
\chead{}\rhead{\thepage}
\lfoot{Due Monday, July 7 2025}
\cfoot{}\rfoot{Written by M.~Macauley}
  \pagestyle{fancy}

\begin{document}

\noindent \textbf{Topics}: Projection and least squares. \\

\noindent \textbf{Do}: Answer the following questions, and feel free to use a computer to solve \emph{any} systems of equations you encounter throughout this problem.

\begin{enumerate}

%%--------------------------------------------------------------------- 

\item Consider the four data points $(t_i,b_i)=(0,0)$, $(1,8)$,
  $(3,8)$, and $(4,20)$. Let $\t=(0,1,3,4)$ be the vector of inputs
  and $\b=(0,8,8,20)$ the vector of outputs.

  \begin{enumerate}
  \item If there were a straight line $b=C+Dt$ through these four
    points, then a certain equation $\A\x=\b$ would have a solution,
    where $\x=(C,D)$. Write this equation in matrix form (that is,
    find $\A$).
    
  \item Instead, we wish to find the ``best fit'' line, which means
    we need to solve $\A\hat{\x}=\p$, where $\p$ is the projection of
    $\b$ onto the column space of $\A$. Write down the \emph{normal
      equations} $\A^T\A\hat{\x}=\A^T\b$, where
    $\hat{\x}=(\hat{C},\hat{D})$, and solve for $\hat{\x}$.
    
  \item Check that $\e=\b-\p$ is orthogonal to both columns of
    $\A$. Compute $||\e||$, which is the shortest distance from $\b$
    to the column space of $\A$. Sketch a diagram of $\e$, $\b$,
    $\p$, and the orthogonal subspaces $C(\A)$ and $N(\A^T)$ to illustrate
    this.
    
  \item Plot the four data points in $\R^2$ (on the $tb$-plane) and
    sketch the best fit line through them that you just found. Clearly
    mark what the vectors $\b=(b_1,b_2,b_3,b_4)$,
    $\e=(e_1,e_2,e_3,e_4)$, and $\p=(p_1,p_2,p_3,p_4)$ represent.

  \item Write down $E:=||\A\x-\b||^2$ as a sum of four squares--the
    last one is $(C+4D-20)^2$, and compute $\partial E/\partial C$ and
    $\partial E/\partial D$. Set these derivatives equal to zero, and
    obtain scalars of the normal equations $\A^T\A\hat{\x}=\A^T\b$.

  \item The method above found the best fit degree-$1$ polynomial
    (line). Now, find the best fit degree-$0$ polynomial (horizontal
    line) $b=C$. Note that this will be a $4\times 1$ system instead
    of a $4\times 2$ system. Compute the vectors $\p$ and $\e$, and
    the (squared) error $||\e||^2$.

  \item Find the best fit parabola (degree-$2$ polynomial)
    $b=C+Dt+Et^2$. On a new set of axes, plot the four data points
    and this parabola. Compute the vectors $\p$ and $\e$, and
    the (squared) error $||\e||^2$.

  \item Find the best fit cubic (degree-$3$ polynomial)
    $b=C+Dt+Et^2+Ft^3$. On a new set of axes, plot the four data
    points and this cubic. Compute the vectors $\p$ and $\e$, and the
    (squared) error $||\e||^2$.
  \end{enumerate}

  \end{enumerate}


\end{document}


  
%%---------------------------------------------------------------------  
