-1

I would like to fit y = a + exp(bt) to the points (1,1) and (2,5). So I take the natural logarithm of the equation and apply it to both points:

ln(y1) = ln(a) + bt1
ln(y2) = ln(a) + bt2

With (1,1) = (t1, y1) and (2,5) = (t2, y2) so that:

ln(1) = ln(a) + b
ln(5) = ln(a) + 2b

Subtracting yields b = ln(5) = 1.609. I plug this back into my linearized system and I get ln(a) = -1.609, therefore a = 0.2. So far, so good. Do these numbers work in the original equations?

a = y1 - exp(bt1) --> 0.2 = 1 - exp(1.609) = 1 - 5 = -4 WRONG!
a = y2 - exp(bt2) --> 0.2 = 5 - exp(2 * 1.609) = 5 - 25 = -20 ALSO WRONG!

I would have thought that even though the initial equations were nonlinear, taking logarithms would have changed them to two linear equations in 2 variables {ln(a), b}. This should in theory produce a unique answer for the pair {a,b}.

Where am I going wrong?

Roberto

2 Answers2

1

Algebra is incorrect.

y = a + exp(bt)

Subtract a from both sides:

(y-a) = exp(bt)

Take the natural log of both sides:

ln(y-a) = bt
duffymo
  • 305,152
  • 44
  • 369
  • 561
1

Log(x + y) Does not equal Log(x) + Log(y)

Your initial implementation of ln is wrong.

@duffymo has a good implementation of log.

Nicholas Patton
  • 786
  • 3
  • 8