#1196 lsquares (newton) does not work

closed
5
2012-12-04
2007-05-19
Anonymous
No

The following example from the Maxima 5.12 manual does not work (compiled on Linux with GCL 2.6.7):

load("lsquares");
lsquares(matrix([1.1,7.1],[2.1,13.1],[3.1,25.1],[4.1,49.1]),
[x,y], y=a*b^x+c, [a,b,c], [5,5,5]);

The output is:

Improper argument to ev:
Solutions
i
#0: lsquares(arglist=[matrix([1.1,7.1],[2.1,13.1],[3.1,25.1],[4.1,49.1]),[x,y],y = c+a*b^x,[a,b,c],[5,5,5]])(lsquares.mac line 147)
-- an error. To debug this try debugmode(true);

loading mnewton before lsquares seems to change this behavior - although it still does not work.

Discussion

  • Nobody/Anonymous

    Logged In: NO

    It looks like the manual is missing the fact that mnewton should be loadded (loading it is also commented out in lsquares.mac).
    However, still the three parameter fit bombs as I say above. The exact output is:

    quotient is not exact
    #0: mnewton(funclist=[2*b^4.1*c+2*b^3.1*c+2*b^2.1*c+2*b^1.1*c+2*a*b^8.199999999999999+2*a*b^6.2+2*a*b^4.2-98.2*b^4.1-50.2...,varlist=[a,b,c],guesslist=[5,5,5])(mnewton.mac line 89)
    #1: lsquares(arglist=[matrix([1.1,7.1],[2.1,13.1],[3.1,25.1],[4.1,49.1]),[x,y],y = c+a*b^x,[a,b,c],[5,5,5]])(lsquares.mac line 136)
    -- an error. To debug this try debugmode(true);

     
  • Nobody/Anonymous

    Logged In: NO

    I thought I added the following comment but it disappeared somehow:

    If you change keepfloat:true to keepfloat:flase in the following, I no longer
    get errors. It is slow, however, since it carries out fractions at full accuracy.

    mnewton(FuncList, VarList, GuessList):=
    block([nfunc, Solutions, Increments, solved:false, h, DF,
    i, j, k, keepfloat:true, ratprint:false],

     
  • Robert Dodier

    Robert Dodier - 2007-07-03
    • labels: 887072 --> Share Libraries
     
  • Robert Dodier

    Robert Dodier - 2007-08-01

    Logged In: YES
    user_id=501686
    Originator: NO

    lsquares has been replaced by a different implementation. Re-test this example with Maxima 5.13.0 or a release candidate, and if it succeeds we can close this report.

     
  • Robert Dodier

    Robert Dodier - 2007-08-01
    • milestone: --> To_be_reviewed
    • assigned_to: nobody --> robert_dodier
     
  • Robert Dodier

    Robert Dodier - 2008-03-06

    Logged In: YES
    user_id=501686
    Originator: NO

    Example shown in original report works OK with Maxima 5.14.0 + SBCL + Linux.

    load (lsquares);
    lsquares_mse (matrix([1.1,7.1],[2.1,13.1],[3.1,25.1],[4.1,49.1]),[x, y],y=a*b^x+c);
    lsquares_estimates_approximate (%, [a, b, c]);
    => [[a = 2.799099761149952, b = 2.000000318477728, c = 1.099975417909244]]

    Closing this report as fixed.

     
  • Robert Dodier

    Robert Dodier - 2008-03-06
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks