-
×InformationFix Windows 10 Update Issues
Resolve Windows 10 related issues for your HP computers or printers by HP Windows 10 Support Center
-
-
×InformationFix Windows 10 Update Issues
Resolve Windows 10 related issues for your HP computers or printers by HP Windows 10 Support Center
-
- HP Community
- >
- Other Products
- >
- Calculators
- >
- Use solve function in program
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Create an account on the HP Community to personalize your profile and ask a question

Use solve function in program
05-03-2018 10:15 PM

Hi,
I was trying to solve the equation below using the solve command. I used the synntax solve(Expr,[Var] ) but it still did not work in my program. This equation is one of many so i am trying to make one program that solve many equation and I am stuck at this one.So It would be better for me to make a program then use the solve app.Can anyone help me to get this work?
05-03-2018 10:45 PM

Hello,
Are you trying to do a symbolic or numerical solve?
If symbolic, then you need to make sure that you use the CAS version.
If numerical, remember that the solve function is a function aplet function (yes, seems confusing I know :-)). by this I mean that either the funciton app needs to be the current one, or you need to call Function.Solve...
I do not remember if the numerical solve function works with program local variables. This might be the problem.
Cyrille
05-05-2018 11:31 PM - edited 05-05-2018 11:38 PM

Cyrille,
Thanks for the response. It is numerical. Here is a sample code I have, I tried to add Function.solve and have the Function app as the app open but it still gives me syntax error.
Is it not possible to use to do this kind of numerical operation in a program on the hp prime?
EXPORT Prog(X_lkd, X_hkd,F) BEGIN solve(F/D+X_lkd+X_hkd=1,D)
RETURN D END; H
05-06-2018 11:38 PM

Hello,
The following does seem to work.
EXPORT V1, V2, V3;
EXPORT Prog(X_lkd, X_hkd,F)
BEGIN
V1:= X_lkd; V2:= X_hkd; V3:= F;
Solve.SOLVE(V3/D+V1+V2=1, D, -2);
RETURN D;
END;
If, depending on the 3 parameter, the right part of the function is always greater than 1, then the solver seems to have issues finding the root and needs a guess to work with...
Cyrille
05-07-2018 01:05 PM

When I enter
X_lk = .97,X_hl=.001 ,f=12 it gives me 0. Even when I change the intial guess to 413 it still gives me 0.The correct answer should be what I post ealier around 413.79 is there a way to get it to work with number above 0?
05-07-2018 11:30 PM

Hello,
Changing the equation do V3+D(V1+V2)=D makes it much easier to solve for the system and reduces the issues!
Having made the change, things seems to work much much better...
Cyrille
05-08-2018 11:01 PM - edited 05-08-2018 11:02 PM

Cyrille,
one last thing I would like to add to my program that i can not figure out. I would like to find phi such that it is in between these paremeters.
The probelm I have is
The probelma are
1) The index number can change. I would like for the program to ask for the index number so i can enter in the correcet parameters. for example if i=3 then I would like for the program to know I need 3 alphas and 3 Z and the user can enter the values.
2) I do not know how to code to solve for phi inside the sumation.
I would like to find phi such that it is in between these paremeters.
05-14-2018 03:00 PM

@Unluckyowl1wrote:When I enter
X_lk = .97,X_hl=.001 ,f=12 it gives me 0. Even when I change the intial guess to 413 it still gives me 0.The correct answer should be what I post ealier around 413.79 is there a way to get it to work with number above 0?
The reason is that SOLVE does not change D, it just returns a number.
You ask to return D, which will be the same as it was before running he program.
If you want to change D write:
D:=Solve.SOLVE.....
RETURN D;
Or just write:
RETURN Solve.SOLVE.....
05-16-2018 03:24 PM

@Unluckyowl1wrote:...........
Is it not possible to use to do this kind of numerical operation in a program on the hp prime?
EXPORT Prog(X_lkd, X_hkd,F) BEGIN solve(F/D+X_lkd+X_hkd=1,D)
RETURN D END; H
Suppose you want to solve SIN(10*D)+D/10+X_lkd+X_hkd=0 between the lower limit: a and the upper limit: b.
Then you could write this CAS program:
#cas cas_myprog1(X_lkd,X_hkd,a,b):= BEGIN RETURN solve(SIN(10*D)+D/10+X_lkd+X_hkd=0,D,a..b); END; #end
Or alternatively:
#cas cas_myprog1(X_lkd,X_hkd,a,b):= BEGIN RETURN solve(SIN(10*D)+D/10+X_lkd+X_hkd=0,D=a..b); END; #end
You can find the solve and fsolve commands and their Help via:
Toolbox - CAS - Solve - (Solve or Numerical Solve)
The differences between solve and fsolve are not very big, but solve is primarily meant for exact calculations and fsolve for numerical ones.
Because solve and fsolve are CAS commands it is easiest to use them in a CAS program as we did here.
It is also possible to use them in a non-CAS program with the construction CAS("....").
Then we get:
EXPORT MYPROG1(X_lkd,X_hkd,a,b) BEGIN RETURN CAS("solve(SIN(10*D)+D/10+X_lkd+X_hkd=0,D,a..b)"); END;
Or:
EXPORT MYPROG1(X_lkd,X_hkd,a,b) BEGIN LOCAL s; s:="solve(SIN(10*D)+D/10+X_lkd+X_hkd=0,D,a..b)"; RETURN CAS(EVAL(s)); END;
Still another way is to use this construction:
EXPORT MYPROG1(X_lkd,X_hkd,a,b) BEGIN RETURN CAS.solve("SIN(10*D)+D/10+X_lkd+X_hkd=0","D","a..b"); END;
So solve is not the same as the app command SOLVE.
In fact you can choose between:
-The strong exact solver: solve.
-The strong numerical solver: fsolve
-The Home solver: FNROOT
-The Function app solver: ROOT
-The Solve app solver: SOLVE.
See also this article for more inormation:
http://www.hpmuseum.org/forum/thread-3149.html
Didn't find what you were looking for? Ask the community