HP Forums
fsolve() bug? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: fsolve() bug? (/thread-2825.html)



fsolve() bug? - Han - 01-10-2015 03:52 AM

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.


RE: fsolve() bug? - parisse - 01-10-2015 07:37 AM

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.


RE: fsolve() bug? - Snorre - 01-10-2015 11:18 AM

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


RE: fsolve() bug? - parisse - 01-10-2015 02:51 PM

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).