# [Maxima] Exponential fitting with lsquares

Robert Dodier robert.dodier at gmail.com
Sun May 24 00:14:34 CDT 2009

```On 5/23/09, Jose A. Vallejo <jose.a.vallejo at prodigy.net.mx> wrote:

>>> lsquares_estimates_approximate(mse,[a,b],initial=[0.0001,1],iprint=[-1,

The argument initial=... is ignored --- that's a bug.
I fixed it and I'll commit it soon.

> Maxima encountered a Lisp error:
>
> NTH: T is not a list

This is a failure (on Maxima's part) in the handling of
floating point overflow. lbfgs constructs a Lisp function to
compute numerical values. That function is apparently
doing something unhelpful here. Can you make a bug report

FWIW I find the following formulation seems to yield a
sensible result with Maxima built from CVS (didn't try it
on any released version).

M : matrix
([1900, 75.995],
[1910, 91.972],
[1920, 105.711],
[1930, 123.203],
[1940, 131.669],
[1950, 150.697],
[1960, 179.323],
[1970, 203.212],
[1980, 226.505],
[1990, 249.633],
[2000, 281.422]) \$

mse : lsquares_mse (M, [x, y], y = a * exp(b*(x - 1950)));

est : lsquares_estimates_approximate (mse, [a, b], initial=[100, 0.01]);

plot2d ([a * exp(b*(x - 1950)), [discrete, args (M)]], [x, 1900, 2010]), est;

lsquares_residuals (M, [x, y], y = a * exp(b*(x - 1950)), first (est));

best

Robert Dodier
```