On 2013-02-22, Andreas Goebel <a-goebel at gmx.de> wrote:
> The first problem is a wxMaxima problem: The function doesn?t return the
> focus to wxMaxima. I have to press abort, then I get the results. This
> doesn?t happen when an exact solution with solve is found.
Looks like 'solve' gets lost trying to find an exact solution and never
returns. Probably 'solve' could never find a solution, given the form of
the equations.
> The second problem seems to be a lsquares problem: In the sample (see
> attachment) I want to fit a logistic growth function to the given data.
>
> I get an empty result. If I remove just one data pair, I get fine
> results (no matter which data pair I remove).
Well, when looking for a numerical solution, it makes a difference where
one starts looking. (The numerical algorithm employed by lsquares only
tries to find one solution. It would be reasonable to try multiple
starting points, but that's not implemented.) I tried the example you
gave and from the default starting point (all 1's), it doesn't find a
solution. But I tried a different starting point, and it found a
solution. Perhaps you just need to adjust the starting point.
best
Robert Dodier
PS.
(%i1) M: matrix(
[0,0.45],
[2,1.1],
[4,2.3],
[6,3.75],
[8,4.90],
[10,5.55],
[12,5.85],
[14,5.95]
);
(%i2) h(t):=G*1/(1+%e^(-k*G*t)*(G/a-1));
(%i3) load (lsquares);
(%i5) mse : lsquares_mse (M, [x, y], y=h(x));
8
====
\ G 2
> (M - -------------------------)
/ i, 2 - M k G
==== G i, 1
i = 1 (- - 1) %e + 1
a
(%o5) ------------------------------------------
8
(%i6) lsquares_estimates_approximate (mse, [a, G, k], initial = [2, 1, 1]);
*************************************************
N= 3 NUMBER OF CORRECTIONS=25
INITIAL VALUES
F= 1.194511680896226D+01 GNORM= 5.572637071353574D+00
*************************************************
I NFN FUNC GNORM STEPLENGTH
1 2 7.208075852826302D+00 3.876541576126205D+00 1.794482553225207D-01
2 3 2.849560812759228D+00 3.090680933782664D-01 1.000000000000000D+00
3 4 2.804514156348150D+00 2.450179962005848D-01 1.000000000000000D+00
4 5 2.686206321728874D+00 1.069446774061238D-01 1.000000000000000D+00
IFLAG= -1
LINE SEARCH FAILED. SEE DOCUMENTATION OF ROUTINE MCSRCH
ERROR RETURN OF LINE SEARCH: INFO= 3
POSSIBLE CAUSES: FUNCTION OR GRADIENT ARE INCORRECT
OR INCORRECT TOLERANCES
*************************************************
N= 3 NUMBER OF CORRECTIONS=25
INITIAL VALUES
F= 1.211823711958010D+00 GNORM= 1.108746652085573D+02
*************************************************
I NFN FUNC GNORM STEPLENGTH
1 7 1.139936453165609D+00 1.210256408504471D+01 3.207203026637674D-05
2 8 1.135997596020803D+00 1.036745043219363D+01 1.000000000000000D+00
3 10 1.129715829055599D+00 1.779837542931532D+00 4.522448162252484D-01
[...]
29 40 1.318771762971247D-04 4.159127221614088D-04 1.000000000000000D+00
THE MINIMIZATION TERMINATED WITHOUT DETECTING ERRORS.
IFLAG = 0
(%o6) [[a = .4651374951493832, G = 6.017545276672657, k = .08255299436107316]]
(%i7) soln : % $
(%i8) load (draw);
(%o8) /usr/share/maxima/5.29.1/share/draw/draw.lisp
(%i9) draw2d (point_size=3, point_type=circle, points (M), explicit (h(x), x, -1, 15)), soln;