HP Forums
Evaluate expression with HP50g - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Evaluate expression with HP50g (/thread-8546.html)



Evaluate expression with HP50g - vini.simoes - 06-22-2017 01:05 AM

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'?


RE: Evaluate expression with HP50g - peacecalc - 06-22-2017 10:16 PM

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.


RE: Evaluate expression with HP50g - Carsen - 06-23-2017 06:17 AM

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.


RE: Evaluate expression with HP50g - BartDB - 06-23-2017 10:55 AM

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


RE: Evaluate expression with HP50g - ndzied1 - 06-23-2017 02:42 PM

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


RE: Evaluate expression with HP50g - Juan14 - 06-23-2017 08:05 PM

I find The SOLVE soft menu (page 6-26 of the user guide) very practical.


RE: Evaluate expression with HP50g - Joe Horn - 06-23-2017 11:59 PM

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.


RE: Evaluate expression with HP50g - pier4r - 06-24-2017 10:08 AM

Nice ideas!


RE: Evaluate expression with HP50g - Gilles59 - 06-24-2017 09:00 PM

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