# Find parameters for exponential function fitting to datapoints

I have a set of datapoints, in this case the temperature of an object adjusting to the environment temperature over time. Because I know these kind of processes take the form of $$f(x)=Ae^{x/B}+C$$ I think it should be very well possible to predict the near future for this process if I can find these $A$, $B$ and $C$ in the equation. And this is exactly my question.
I know the method of applying linear regression to the log of the data and it works perfectly well, but only to find $A$ and $B$ if the constant $C$ is zero and this is not true in my case. In fact, it's one of the most important things I want to find from the data as it would indicate the environment temperature.
Something tells me that this should be pretty straightforward to do but I just can't get to it.

-
–  faleichik Feb 8 '12 at 15:17
I have seen these, but I won't be able to use matlab so the answers there don't help me. Also I think there should be a solution much simpeler than Levenberg-Marquardt. –  Daniel Reus Feb 8 '12 at 15:27

This is a non-linear system of equations, so, in general, it is a mess (analytically).

However, as I discovered many years ago, in the case where you have three equally spaced $x$ values, you can solve it directly.

Suppose $y_i = a e^{b x_i} + c$ for $i = 1, 2, 3$ and $x_2-x_1 = x_3-x_2 = d$.

Then $y_2-y_1 = a(e^{b x_2}- e^{b x_1}) = a e^{b x_1}(e^{b(x_2-x_1)}-1) = a e^{b x_1}(e^{bd}-1)$.

Similarly, $y_3-y_2 = a e^{b x_2}(e^{bd}-1)$.

Therefore $\frac{y_3-y_2}{y_2-y_1} = e^{b(x_2-x_1)} = e^{bd}$.

This determines $b$. Either of the equations for $y_{i+1}-y_i$ then determines $a$, and any of the original equations determines $c$.

-
Thanks, this is what I was looking for! –  Daniel Reus Jan 25 '13 at 12:33

Okay, I solved my problem for now like so:

• For the whole range in which I expect C do:
• Assume a value for C
• Take the log of the datapoints - C
• Do linear regression over the obtained numbers and by that obtain the best A and B for the given C
• Calculate E, the sum of absolute differences between the points in the dataset and the points that would follow using the obtained A, B and C
• Choose A, B and C for which E was smallest.

To optimize things a bit I first do the process with large steps for C and than repeat it around the minimum with finer steps.

I think there should be better ways but this works well enough for my situation.

-
Any numerical analysis text will discuss multidimensional minimization and provide routines. Basically you minimize the sum of squares of the errors from your model function to the data. Excel provides Goal Seek which can be used for this purpose as well. –  Ross Millikan Jul 30 '12 at 23:27

Do the experiment in the freezer with a control temp, then find A and B.

These should be true for any C

-
What experiment? –  Cameron Buie Nov 2 '12 at 20:19