## Least Sequare Fit to an Exponential Relationship

Suppose we have variables
$x, \: y$
exponentially related, so that  y=Ae^{Bx}

, and we have data points
$\{(x_1,y_1),(x_2,y_2),....,(x_n,y_n) \}$
from which we wish to find estimates for
$A, \: B$
.
We can estimate
$ln(A), \: B$
by transforming to a straight line and using the least square methid, then transforming back. Taking logs gives
$ln(y)=Bx+ln(A)$
.
The ith error is
$e_i=ln(y_i)-(Bx_i+ln(A)$
.
Squaring these and adding them gives
$E=\sum^n_{i=1}e^2_-=\sum^n_{i=1}(ln(y_i)-(Bx_i+ln(A))^2$

Differentiate with respect to
$ln(A), \: B$
in turn, and equating to zero gives
$\frac{\partial E}{\partial ln(A)}=2 \sum^n_i ln(y_i)-2B \sum^n_{i=1} x_i -2n ln(A)Fsum =0$

$\frac{\partial E}{\partial B}=2 \sum^n_{i=1} ln(y_i)x_i- 2B\sum^n_{i=1} x^2_i -2ln(A) \sum^n_{i=1}x_i=0$

Dividing by 2 and rearranging into matrix form gives
$\left( \begin{array}{ccc}\sum^n_{i=1} x_i & n \\ \sum^n_{i=1} x^2_i & \sum^n_{i=1}x_i \end{array} \right) \begin{pmatrix}B\\ln(A)\end{pmatrix}=\begin{pmatrix}\sum^n_i ln(y_i) \\ \sum^n_{i=1} ln(y_i)x_i \end{pmatrix}$

Hence
$\begin{pmatrix}B\\ln(A)\end{pmatrix}={\left( \begin{array}{ccc}\sum^n_{i=1} x_i & n \\ \sum^n_{i=1} x^2_i & \sum^n_{i=1}x_i \end{array} \right)}^{-1} \begin{pmatrix}\sum^n_i ln(y_i) \\ \sum^n_{i=1} ln(y_i)x_i \end{pmatrix}$

Suppose we have the data points
$(1,1.00),(2,1.20),(3,1.80),(4,2.50),(5,3.60),(6, 4.70),(7,6.60),(8,10)$
$\sum^n_{i=1}x_i=1+2+3+4+5+6+7+8=36$

$\sum^n_{i=1}x^2_i=1^2+2^2+3^2+4^2+5^2+6^2+7^2+8^2=204$

$\sum^n_{i=1}y_i=ln(1.00)+ln(1.20)+ln(1.80)+ln(2.50)+ln(3.60)+ln(4,70)+ln(6.60)+ln(9.10)=8.62$

$\sum^n_{i=1}y_ix_i=ln(1.00)+2ln(1.20)+3ln(1.80)+4ln(2.50)+5ln(3.60)+6ln(4,70)+7ln(6.60)+8ln(9.10)=52.42$

The system becomes
$\begin{pmatrix}B\\ln(A)\end{pmatrix}={\left( \begin{array}{ccc}36 & 8 \\ 204 & 36 \end{array} \right)}^{-1} \begin{pmatrix}8.62\\ 52.42 \end{pmatrix}= \begin{pmatrix}0.325\\ -0.383 \end{pmatrix}$

Then
$A=e^{-0.383}=0.68$
.
The relationship is
$y=0.68e^{0.325x}$
.