\documentclass[11pt,preprint]{aastex}
%\documentstyle[11pt,psfig,aaspp4]{article}
\begin{document}

\def\simlt{\lower.5ex\hbox{$\; \buildrel < \over \sim \;$}}
\def\simgt{\lower.5ex\hbox{$\; \buildrel > \over \sim \;$}}

\title {2D BRUTE-FORCE FITTING FOR LAB 3 BASELINE DETERMINATION \\ \today}

This is a recap of the recommended `brute-force' fitting procedure to
find the baselines $B_{ew}$ and $B_{ns}$, which is equivalent to finding
$Q_{ew}$ and $Q_{ns}$ (defined in the first few lines of section 8.4 in
lab3 writeup).

\noindent {\bf 1.} Follow the first few lines of section 8.4.3 to find the best value
for $Q_{ew}$ assuming that $Q_{ns} = 0$. That is, generate a series of
`guessed values' for $Q_{ew}$. For each one, least-squares fit for the
unknown coefficients (A, B) in eqn 12 and derive the sum-of-squared
residuals $S^2$. Plot $S^2$ vs $Q_{ew}$; the least-squares fit for
$Q_{ew}$ is that value for which $S^2$ is minimized.

Issues: Cover a large enough range of $Q_{ew}$ in your guesses so that you
find the true minimum, not just a local minimum. Also, make the
guessed values close together enough so that you define the minimum
well.

\noindent {\bf 2.} Repeat the above for a 2-d grid of guessed values for $Q_{ew}$ and
$Q_{ns}$ and find the global minimum for $S^2$ in this 2d space. Call
this minimum value $S_{min}^2$.

The values for $Q_{ew}$ and $Q_{ns}$ at this global minimum are the
best-fit values. Call these $Q_{ew}*$ and $Q_{ns}*$. Define $\Delta
Q_{ew} = Q_{ew}\ - Q_{ew}*$ and $\Delta Q_{ns} = Q_{ns} - Q_{ns}*$.

\noindent {\bf 3.} Deriving the uncertainties in the best-fit values: 

{\bf 3.1.} Convert your 2-d grid of $S^2$ into a 2-d grid of $\Delta S^2$,
where $\Delta S^2 = S^2 - S_{min}^2$. Then the Taylor expansion about
the best-fit values begins with the second-order terms because the
first-order ones are zero at the minimum. So with the second derivatives
evaluated at $S_{min}^2$, we have
%
\begin{equation}
\Delta S^2 = 
       {1 \over 2}{\partial^2 S^2 \over \partial Q_{ew}^2} \Delta Q_{ew}^2 +
       {\partial^2 S^2 \over \partial Q_{ew} \partial Q_{ns}}  \Delta Q_{ew}  \Delta Q_{ns} +
       {1 \over 2}{\partial^2 S^2 \over \partial Q_{ns}^2}  \Delta Q_{ns}^2 
\end{equation}
%
It's much better to write this in matrix notation:
%
\begin{equation}
\Delta S^2 = {\bf \Delta Q^T \cdot [\alpha] \cdot \Delta Q}
\ \ ,
\end{equation}
%
where ${\bf \Delta Q}$ is the column vector of guessed values minus the
best-fit values, i.e.
%
\begin{eqnarray}
{\bf \Delta Q} =  \left[
  \begin{array}{c}
    {\Delta Q_{ew}} \\
    {\Delta Q_{ns}} \\
  \end{array}
  \; \right]
\end{eqnarray}
%
and $[\alpha]$ is the curvature matrix (equation 2.4a in
'least-squares-lite'), which is 2x2 and symmetric so it has 3
independent parameters---2 diagonal and 1 off-diagonal element:
%
\begin{eqnarray}
  \LARGE
      [\alpha] =  \left[
  \begin{array}{cc}
     \vspace*{1em}
     {1 \over 2}{\partial^2 S^2 \over \partial Q_{ew}^2} & {\partial^2 S^2 \over \partial Q_{ew} \partial Q_{ns}} \\
         {\partial^2 S^2 \over \partial Q_{ew} \partial Q_{ns}}  & {1 \over 2}{\partial^2 S^2 \over \partial Q_{ns}^2} \\
  \end{array}
  \; \right]
\end{eqnarray}
%\normalsize
%
{\bf 3.2.} Extract approximate values for the elements of $[\alpha]$ by
hand. Use your native intelligence to do this in an easy
way. Specifically, use your 2d grid of $\Delta S^2$ versus $Q_{ew}$ and
$Q_{ns}$ to numerically find the three second derivative matrix
elements.

{\bf 3.3.} Having found $[\alpha]$, find the covariance matrix by taking its
inverse.

{\bf 3.4.} Derive the uncertainties in $Q_{ew}$ and $Q_{ns}$ using this covariance matrix in equation 3.7 in
'lsfit-lite'.

\end{document}
