HP Forums
Need help with solve&fsolve with stored equations - 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: Need help with solve&fsolve with stored equations (/thread-1683.html)



Need help with solve&fsolve with stored equations - alexzkter - 06-21-2014 11:02 PM

As the title says, I'm having a hard time in the attempt of solving stored equations (on Apps).

The equation is P=((R*T)/(x-b))-(a/x^2)

Here's the definition of the needed variables on CAS:
[Image: xf3j3b.png]

In order to store the 3 equations on a Solve app, (a,b and P equations) I also need to define the 'v' as v:=0 so I don't get syntaxis error:
[Image: 2d7x2lf.png]

fsolve and solve are working if v is an undefined variable. But if I create this variable, I can't solve the equation anymore (fsolve and solve shows [] )


Then...how am I supposed to easily type in solve() on CAS and then copy-paste the expression from Solve app or such ???

Thanks in advance


RE: Need help with solve&fsolve with stored equations - CR Haeger - 06-22-2014 12:02 AM

Not easy at all I am afraid.

To get equations into solver, it seems you have to either use Home variables only (A,B, C etc) or first define the equation in CAS then save it using Solve.E1:= . For example

[attachment=858]

You can do the same for the other two equations a and b. Unfortunately, Solver will then require you to create user variables before running the solver.

If you go back to CAS, you will then need to delete some or all of the recently created user variables before running solve() or fsolve().

Its a pain and I would avoid the Solver app and stick with CAS solve(), fsolve().


RE: Need help with solve&fsolve with stored equations - alexzkter - 06-22-2014 12:22 AM

(06-22-2014 12:02 AM)CR Haeger Wrote:  Not easy at all I am afraid.

To get equations into solver, it seems you have to either use Home variables only (A,B, C etc) or first define the equation in CAS then save it using Solve.E1:= . For example



You can do the same for the other two equations a and b. Unfortunately, Solver will then require you to create user variables before running the solver.

If you go back to CAS, you will then need to delete some or all of the recently created user variables before running solve() or fsolve().

Its a pain and I would avoid the Solver app and stick with CAS solve(), fsolve().


Thanks for the quick reply.

I was reading through the forums and saw the shift+Notes method, which doesn't seem to be that much longer in keystrokes (the copy-paste part seems longer) and has the benefit of allowing comments.


RE: Need help with solve&fsolve with stored equations - parisse - 06-22-2014 07:47 AM

Bisection can not solve your equation (without precise boundaries), because the root and the singular point 0 are too close. I'm going to improve the solver so that it recognizes your equation is polynomial-like, even if v is assigned.


RE: Need help with solve&fsolve with stored equations - alexzkter - 06-22-2014 09:41 AM

(06-22-2014 07:47 AM)parisse Wrote:  Bisection can not solve your equation (without precise boundaries), because the root and the singular point 0 are too close. I'm going to improve the solver so that it recognizes your equation is polynomial-like, even if v is assigned.

Are you sure that's the problem here?
I rebooted the virtual calculator so all stored equations and variables are purged, then did the example above again..same result.
Typed in only the equation, without the solve/fsolve command, and I get 7000000=-Inf
[Image: 4rymfp.png]


Take a look at this example:
[Image: 167qd0k.png]
No matter how close the root is to the singular point 0, fsolve&solve shows proper result unless the variable was previously defined, even if its v:=5 or any other number than 0)


RE: Need help with solve&fsolve with stored equations - parisse - 06-22-2014 02:33 PM

Yes, because if the variable is not assigned, the equation is found to be reducible to a polynomial equation, and proot is called. If the variable is assigned, it is not found to be reducible to a polynomial equation, and bisection is called. That's what I'm going to improve.