%====================================================================
% This is a LaTeX-2e document
%====================================================================

\documentclass[12pt]{article}
\parindent=0pt \parskip=8pt

\usepackage{amssymb,amsmath,amsthm}
\usepackage[mathscr]{eucal}

\usepackage{makeidx}
%\numberwithin{equation}{subsection}
\numberwithin{equation}{section}
%\input{isomath}
%\input{mathenv}
\input{syms}
\usepackage{graphicx}
\usepackage{psfrag}

\usepackage{hyperref}
\usepackage{ifpdf}

\ifpdf
\pdfinfo{
/Author (John Kerl)
/Title  (Notes for corrected power-law fit)
}
\fi

%--------------------------------------------------------------------
\begin{document}
\title{Notes for corrected power-law fit}
\author{John Kerl}
\date{\today}

%\maketitle

We start with
\begin{align*}
	c(N) &= a \mu^N N^b
\end{align*}
where $\mu \approx 2.61987$.  We have $a=a(\theta)$; $\mu$ and $b$
are independent of $\theta$.  Choices:
(1) do a least-squares fit to find $a$ and $b$;
(2) consider ratio of $c$'s for differing $\theta$ and same $N$, which will
cancel out the $\mu$ and $b$ parts.
First I will do (1).

\begin{align*}
	c_i &= a \mu^{N_i} {N_i}^b,  \qquad 1=1, \ldots, n \\
	\log c_i &= \log a + N_i \log \mu + b \log N_i \\
	e_i &= \log c_i - \log a - N_i \log \mu - b \log N_i \\
	E &= \sum_{i=1}^n e_i^2 =
		\sum_{i=1}^n (\log c_i - \log a - N_i \log \mu - b \log N_i)^2 \\
	%
	\frac{\partial E}{\partial \log a}
		&= -2 \sum ( \log c_i - \log a - N_i \log \mu - b \log N_i) \\
	\frac{\partial E}{\partial b}
		&= -2 \sum ( \log c_i - \log a - N_i \log \mu - b \log N_i)
			\log N_i \\
		&= -2 \sum ( \log c_i \log N_i - \log a \log N_i
			- N_i \log N_i \log \mu - b \log^2 N_i) \\
	%
	0 &= \sum \log c_i - n \log a - \log \mu \sum N_i
		- b \sum \log N_i \\
	0 &=
	\sum
	\log c_i \log N_i
	- \log a \sum \log N_i
			- \log\mu \sum  N_i \log N_i - b \sum \log^2 N_i
\end{align*}

\begin{align*}
	n \log a + b \sum \log N_i
		&= \sum \log c_i - \log \mu \sum N_i \\
	\log a \sum \log N_i + b \sum \log^2 N_i
		&= \sum \log c_i \log N_i
		- \log\mu \sum  N_i \log N_i
\end{align*}

\begin{align*}
	\bcmatrix{
		n   & \sum \log N_i \\
		\sum \log N_i & \sum \log^2 N_i  \\
	}
	\bcmatrix{ \log a \\ b }
	&=
	\bcmatrix{
		\sum \log c_i - \log \mu \sum N_i \\
		\sum \log c_i \log N_i - \log\mu \sum  N_i \log N_i
	}
\end{align*}

\begin{align*}
	\bcmatrix{ \log a \\ b }
	&=
	\bcmatrix{
		n   & \sum \log N_i \\
		\sum \log N_i & \sum \log^2 N_i  \\
	}^{-1}
	\bcmatrix{
		\sum \log c_i - \log \mu \sum N_i \\
		\sum \log c_i \log N_i - \log\mu \sum  N_i \log N_i
	}
\end{align*}

\end{document}
