cancel
Showing results for 
Search instead for 
Did you mean: 
Mathiopie
New member
4 2 0 0
Message 1 of 3
514
Flag Post

HP Prime and RPN function issues

HP Recommended

I have following problem: when I have defined a function with the functions app and I want to use it in RPN modus, not the desired X value is used but the value on the first stack level.

For instance: function F1(X)=X

First stack level : 5

F1(1) gives 5 as result and not 1

I find it problematic!

Is that a bug?

 

Thanks a lot for your answer.

0 Kudos
2 REPLIES 2
Joe_Horn
Level 8
622 609 117 206
Message 2 of 3
Flag Post
HP Recommended

The problem is happening because you are using algebraic notation in RPN mode.  Never do that.  In RPN, function arguments are always taken from the stack, and are never put in parentheses after the function (because THAT is algebraic notation).

 

However, sometimes you have to tell Prime how many arguments to take from the stack.  This is done by typing the desired COUNT of arguments (not the arguments themselves) after the function in parentheses.  For example, if you want the F1 function to take ONE number off the stack as its argument, then type F1(1).  This LOOKS like algebraic notation, but it's not; the "(1)" here doesn't mean "perform F1 on an argument of 1" but rather it means "take 1 number off the stack and perform F1 on it."

 

In RPN mode, FOO(3) doesn't mean "perform the FOO function on an argument of 3" but rather "perform the FOO function on the bottom 3 levels of the stack."  And those 3 levels get "consumed" by the function and removed from the stack, of course.

 

Functions which always have the same number of arguments don't need to be told how many arguments to take off the stack, e.g. SIN works without needing to type SIN(1).  But user-defined functions are unpredictable, so Prime needs you to type F1(1) if F1 has one argument.

 

Hope that made sense!

 

Suggestion: If you want to create user-defined functions for use in RPN mode, you can avoid the need to type the number of arguments by using the Define key (Shift x-t-theta-n) instead of the Function app.  For example, if you Define 'foo' to be 'X^2+1' then in RPN you can just type foo and it'll take its argument from the stack without you needing to type foo(1).

 

Disclaimer: I don't work for HP. I'm just another happy HP calculator user.

-Joe-
0 Kudos
Mathiopie
Author
New member
4 2 0 0
Message 3 of 3
Flag Post
HP Recommended

Hi Joe,

 

Thanks a lot for your quick and good answer. I have understood it. I also tried another way which also works: I can enter 'F1(2)' - ENTER and then EVAL. But you are right, I should be very cautious when using RPN after having entered an algebraic equation.

 

Kind Regard.

 

Mathiopie

0 Kudos
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation