Menu

#4492 minpack_solve doesn't check number of equations and unknowns

None
closed
5
2025-02-15
2025-02-14
No

minpack_solve is documented to " Solve a system of ‘n’ equations in ‘n’ unknowns."
But in some cases, it doesn't complain at all when the number of equations and unknowns are not equal (and gives good results):

minpack_solve([x-y+1],[x,y],[0,0]);
  => [[-1.0,0.0],0.0,1]

In other cases, it gives an internal error rather than a clean error:

minpack_solve([x-y,y,y+x],[x,y],[0,0]);

Maxima encountered a Lisp error:

 Invalid index 4 for (SIMPLE-ARRAY DOUBLE-FLOAT (4)), should be a non-negative integer below 4.

Related

Bugs: #4491

Discussion

  • Raymond Toy

    Raymond Toy - 2025-02-15
    • assigned_to: Raymond Toy
     
  • Raymond Toy

    Raymond Toy - 2025-02-15

    Yeah, it should check that that the number of equations matches the number of variables. I do wonder what it's doing when there are less than n equations. Maybe it just assumes the remaining equations always return 0, independent of the value of the variables?

     
  • Raymond Toy

    Raymond Toy - 2025-02-15
    • status: open --> closed
     
  • Raymond Toy

    Raymond Toy - 2025-02-15

    Fixed in commit [976c5d]. Your example now gives:

    (%i2) minpack_solve([x-y+1],[x,y],[0, 0]);
    minpack_solve(fcns, vars, init-x, jacobian = true, 
                                                tolerance = 1.0536712127723509e-8):
      number of equations (1) must be the same as the number of variables (2)
     -- an error. To debug this try: debugmode(true);
    
     

    Related

    Commit: [976c5d]


Log in to post a comment.