HP 50g Solve on object?

04292019, 09:22 AM
Post: #1




HP 50g Solve on object?
Hi all,
Just purchased a HP50g as I enjoyed using a HP12C and wanted more. I was trying to programmatically use the SOLVE command and I think the following exemplifies what I am trying to do. Say I have a small program like this: « « X 5 + » 'X' SOLVE » The SOLVE command fails on running this program. However, if I use the solver via the menus ("NUM.SLV" and select "1. Solve equation") and enter << X 5 + >> in the equation input the solver correctly returns 5 (screenshot attached). Is there a way I can use the solver in a program on an object <<>> (hopefully I'm using the right terms..)? As a background on why  I created a program for the value of a call option (which would replace <<X 5 +>> above) and wanted to use the solver to back out the implied volatility (one of the inputs to price of call). Thank you! 

04292019, 11:27 AM
(This post was last modified: 04292019 11:27 AM by grsbanks.)
Post: #2




RE: HP 50g Solve on object?
The 50g expects an expression or an equation on level 2, not a program.
So, this works: Code: \<< 

04292019, 12:22 PM
Post: #3




RE: HP 50g Solve on object?
Thanks for the reply! Perhaps I am misusing the solver or there is an alternative method to do what I'm looking for.
This is my program, BSCALL (I've added '>' since I copied it over): Code:
Overall, I'm looking to use the calculator to solve for one of the inputs, volatility, v when BSCALL() = .25. This seems to work when I use the solver via the solver in the menu with these inputs: << 25 30 X .5 .03 BSCALL .25  >> solves for X = .2069... correct! or this: 'BSCALL(25,30,X,.5,.03) = .25' works too. However, neither of these methods works via the key input on the stack. So in a general sense is there any way in the calculator to solve for one of the inputs of another program (without using the menus)? 

04292019, 04:41 PM
(This post was last modified: 04302019 11:50 PM by Giuseppe Donnini.)
Post: #4




RE: HP 50g Solve on object?
I would rather rely on the good ol' HP48 routines still present in the HP50G, and use the ROOT command.
ROOT is the programmable form of HP Solve and takes the following arguments: ++++  Stack level 3  'alg' / << prog >>  1. An algebraic expression or a program     acting as the current equation. Note     that the variable EQ is *not* used by     ROOT.       Stack level 2  'global'  2. The name of the unknown.       Stack level 1  guess / {guesses}  3. A number or a list of 1, 2, or 3     numbers acting as initial guess(es).  ++++ Don't forget the third argument! In contrast to its interactive implementation, the programmable version of the rootfinder requires you to supply an initial guess. (The HP Solve environment uses a default guess if you don't supply one, which is simply the current value of the unknown variable, if it already exists, or zero, if it doesn't [formal variable]). Note that ROOT only displays a message if an error occurs (Bad Guess(es) or Constant?). As it is not meant to be used interactively, it does not provide intrepretative messages when a root (or extremum) is actually found (Zero, Sign Reversal, or Extremum), nor does it allow you to monitor the rootfinding process as during an HP Solve session. Applying this to your example, we get the following program: \<< @ Begin program \<< X 5 + \>> @ Current equation 'X' @ Unknown 0 @ Initial guess ROOT @ Call rootfinder \>> @ End program Executing the program puts 5 on stack level 1, just as you wanted. 

04302019, 04:02 PM
Post: #5




RE: HP 50g Solve on object?
That's amazing, thank you!! Works perfectly with my original code too. Thanks again!


04302019, 07:47 PM
(This post was last modified: 04302019 08:09 PM by Gilles.)
Post: #6




RE: HP 50g Solve on object?
(04292019 09:22 AM)iainiain32 Wrote: Hi all, the HP50g is a jewel for me ;D with your example the simplest way is : 'X+5' SOLVEVX in 7 keystrokes ' X+5 ENTER LeftShift S.SVL SOLVEVX result : X=5 Another example in R~ mode 'X^3.+7.*X^2.+9.*X12.' SOLVEVX { 'X=.791287847478' 'X=3.79128784748' 'X=4.' } This works for rational expression. for non rational expression you can you the MSLV command. exemple [ '√(x^2+y^2)=5' '√(2*a^2(2*x+2*y)*a+(x^2+y^2))=3' '√(a^22*y*a+(x^2+y^2))=4' ] [ 'x' 'y' 'a' ] [ 3 3 6] @ initial guess MSLV result [ 3.44599325458 3.62286219575 5.65390392093 ] 

04302019, 08:14 PM
Post: #7




RE: HP 50g Solve on object?
But that's not exactly what the original poster wanted. As a matter of fact, SOLVEVX does not work with an equation/expression in the form of a program. So, for the given problem, the best solution is still to use the ROOT command.


04302019, 09:10 PM
(This post was last modified: 04302019 09:14 PM by Gilles.)
Post: #8




RE: HP 50g Solve on object?
**Deleted **


04302019, 09:18 PM
Post: #9




RE: HP 50g Solve on object?
(04302019 08:14 PM)Giuseppe Donnini Wrote: But that's not exactly what the original poster wanted. As a matter of fact, SOLVEVX does not work with an equation/expression in the form of a program. So, for the given problem, the best solution is still to use the ROOT command. You are right. I though UTPN was a equation/expression but it is a command/program. 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)