An archive of Mark's Spring 2018 Numerical Analysis course.

Exponential least squares

mark

I’ve got the following data set:

\begin{array}{c|c} x & y \\ \hline -2 & 0.376956 \\ -1 & 0.344568 \\ 0 & 1.11581 \\ 1 & 1.87512 \\ 2 & 3.89654 \\ 3 & 7.8263 \\ \end{array}

I’d like to find a least squares fit to this data with an exponential function f(x)=a e^{rx} as shown in the figure below on the left.

Problem 1

Write down the function that I’d need to minimize to accomplish this task.

Problem 2

Since the function above leads to a non-linear system, I apply the logarithm to the y-coordinates to obtain data that should be nearly linear as shown in the figure on the right. I find the function

\ell(x)=0.0244 + 0.656 x.

Write down the exponential function that fits the original data.

anonymous_user

The nonlinear function that we need to minimize is

\sum_{i=1}^n(ae^{rx_i}-y_i)^2.

We are now given the affine function \ell(x), which is parameterized according to the logarithm of y, so if we exponentiate this function we will have a function related to y.

\log(y) \approx 0.0244 + 0.656x \Rightarrow y \approx e^{0.0244+0.656x} = e^{0.0244}e^{0.656x}.

This is our least squares fit exponential function f(x) as desired, with a=e^{0.0244} and r=0.656.