# HP Forums

Full Version: fsolve() bug?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
fsolve([x+y=3,2*x+2*y=6,x-y=0],[x,y],[0,0]); --> invalid dimension
fsolve([x+y=3,2*x+2*y=6,x-y=0],[x,y]); --> [3/2, 3/2]
fsolve([x+y=3,x-y=0],[x,y],[0,0]); --> [1.5, 1.5]

fsolve() seems use a naive dimension check -- if the number of equations is not equal to the number of variables, then giving initial values results in invalid dimension.
It is not a bug: fsolve is a numeric solver, you can not run an iterative method (explicitly called if you pass a guess as third argument) if the number of equations is not the same as the number of unknowns.
Hello,

Sorry to ask (I'm not a mathematician):
(01-10-2015 07:37 AM)parisse Wrote: [ -> ]It is not a bug: fsolve is a numeric solver, you can not run an iterative method (explicitly called if you pass a guess as third argument) if the number of equations is not the same as the number of unknowns.
I've always thought that's the basic principle of iterative methods: first guessing an approximation, then successively improving it until some exact-enough-measure is met.

Greetings
That's correct, and that's what fsolve does if you give a guess as third argument. If you do not give a guess, it might however solve the equation/system using a different method (for example a polynomial rooter for a polynomial equation).
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :