Post Reply 
Evaluate expression with HP50g
06-22-2017, 01:05 AM
Post: #1
Evaluate expression with HP50g
Hello,

I have a long algebraic expression in function of 'x' and I need to evaluate it for different values of 'x'. How can I do it in an intelligent way, without reentering the whole expression for each value of 'x'?
Find all posts by this user
Quote this message in a reply
06-22-2017, 10:16 PM
Post: #2
RE: Evaluate expression with HP50g
Hello vini.simoes,

The easiest way is to define a function and feed it with the values you like.

Maybe you aren't not familiar with this calc. The best way is to choose in the "MODE" app:

a) RPN
b) Set exact mode in submenue "CAS"
c) Set flag 117 in submenue "FLAGS", that's important because you can access your own objects with the keys "F1" to "F6" show in the last line of display (inverted, background black foreground "white").

For example:

Your complicate expression is x^2;
Key in the following

'MYFUN(X) = X^2' Don't forget the single quotes they are important!

Then press the key "Right Shift" and then press the "SYMB", now you get the catalogue of all functions and look for the command "DEFINE" and press "OK".

Now you get a new objekt that works like a build in function.

Key in:

16

and then press where in the last line of display is MYFUN located (let's say at the fourth position), you press "F4" and you get the result you intended:

256.
Find all posts by this user
Quote this message in a reply
06-23-2017, 06:17 AM (This post was last modified: 06-23-2017 06:18 AM by Carsen.)
Post: #3
RE: Evaluate expression with HP50g
Peacecalc is correct but here are a few things to simplify his method.

Instead of searching the catalog by pressing [Right Shift] [SYMB] for the function "Define", you can simply press the [left shift] button and then press the [ 2 ] button. It should say "DEF" above the [ 2 ] button in white text, which means define.

The second thing that Peacecalc was unclear about is you have to press the [VAR] button in order to see the "MYFUN" variable name.

The third thing I have to say is that you do not need to have flag 117 set. When pressing the [VAR] button, it is always a soft menu. Also, when using the Catalog, it is always a CHOOSE box. So flag 117 is irreverent in this problem.
Find all posts by this user
Quote this message in a reply
06-23-2017, 10:55 AM
Post: #4
RE: Evaluate expression with HP50g
Use the numerical solver

Red right Shift followed by NUM.SLV (on 7 key)

Select "1.Solve equation"

Highlight "Eq: " and select EDIT (F1 key)

Enter your equation in the form y=f(x)

Below the equation you will be presented with
x:
y:

Highlight x and enter a value
Highlight y and select SOLVE (F6 key)

Repeat last two steps for as many x values as needed.

(The numerical can also be used with many variables e.g. P*v=n*R*T etc.)


Visit this user's website Find all posts by this user
Quote this message in a reply
06-23-2017, 02:42 PM
Post: #5
RE: Evaluate expression with HP50g
(06-23-2017 10:55 AM)BartDB Wrote:  Use the numerical solver


(The numerical can also be used with many variables e.g. P*v=n*R*T etc.)

I'm a big fan of the numeric solver as well. As an added benefit, you can solve the function backwards. For instance if you have a desired Y value, you can enter it and solve for X (note you may have to play with an initial guess for X to find the right answer if there are multiple possibilities).
Find all posts by this user
Quote this message in a reply
06-23-2017, 08:05 PM
Post: #6
RE: Evaluate expression with HP50g
I find The SOLVE soft menu (page 6-26 of the user guide) very practical.
Find all posts by this user
Quote this message in a reply
06-23-2017, 11:59 PM
Post: #7
RE: Evaluate expression with HP50g
To save keystrokes, I often "cheat" and use the "lim" command like this:

1) Put any expression in 'X' on the stack. MUST be 'X' (or whatever your current independent variable is; press MODE CAS, see top line).
2) Put the desired value for X on the stack.
3) Execute lim (shortcut: left-shift 4, LIMIT, lim)

All the X's will be replaced by the number, and the expression evaluated.

If you want to substitute several values, put them in a list, and all will be handled at once. Example:

'3*X^2-4*X-5'
{6 7 8}
lim
--> { 79 114 155 }
... that's what the polynomial evaluates to when 6, 7, and 8 are substituted into 'X'.

It's not what lim was intended to be used for, but I find it's more keystroke efficient than other ways of substituting values into X.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
06-24-2017, 10:08 AM
Post: #8
RE: Evaluate expression with HP50g
Nice ideas!

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
06-24-2017, 09:00 PM (This post was last modified: 06-24-2017 09:06 PM by Gilles59.)
Post: #9
RE: Evaluate expression with HP50g
Hi,

If your expression is on the stack for example '2*x' and you need exact results or CAS capabilities, you can do :

Code:
'F(x)'
->         @ right arrow to swap 
=          @ RShift W
DEF        @ Lshift 2

If you have to enter the full expression, you can use the equation writer, F(x)=2*x then ENTER and DEF
Find all posts by this user
Quote this message in a reply
Post Reply 




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