HP Forums
How to use RPN mode with Functions? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: How to use RPN mode with Functions? (/thread-7853.html)



How to use RPN mode with Functions? - lemontea - 03-03-2017 12:05 AM

Hello - I bought a Prime ages ago but only recently tried to use it. My 15C had been quite sufficient thus far.

Anyway I entered a function definition and then tried to resolve it at the Home screen using Textbook entry, and it was fine.

But when I switch to RPN mode I get a syntax error.

E.g., if I define F1 = X^2 (for example)

Textbook mode, I press Vars and then find the symbolic F1 entry, it shows F1 on the Home screen. Then I press the () key and then enter, say, 5. Then ENTER, and it would resolve to F(5) which is 25.

But RPN mode doesn't work. Gets error.


RE: How to use RPN mode with Functions? - Han - 03-03-2017 12:16 AM

In RPN entry, you need to place the argument(s) onto the stack. Then you would execute a command using COMMAND(n) where n is the number of arguments used by COMMAND. In this case, your command is F1. In algebraic notation, you would enter F1(5) to get 25. In RPN notation, you would place 5 onto the stack, and type F1(1).


RE: How to use RPN mode with Functions? - lemontea - 03-03-2017 12:37 AM

(03-03-2017 12:16 AM)Han Wrote:  In RPN entry, you need to place the argument(s) onto the stack. Then you would execute a command using COMMAND(n) where n is the number of arguments used by COMMAND. In this case, your command is F1. In algebraic notation, you would enter F1(5) to get 25. In RPN notation, you would place 5 onto the stack, and type F1(1).

Ok thanks.

So if I define a function with X and Y, then I would enter Y and then X onto the stack, and then type F1(2) to tell it to use the last 2 entered parameters on the stack?


RE: How to use RPN mode with Functions? - Han - 03-03-2017 12:52 AM

(03-03-2017 12:37 AM)lemontea Wrote:  
(03-03-2017 12:16 AM)Han Wrote:  In RPN entry, you need to place the argument(s) onto the stack. Then you would execute a command using COMMAND(n) where n is the number of arguments used by COMMAND. In this case, your command is F1. In algebraic notation, you would enter F1(5) to get 25. In RPN notation, you would place 5 onto the stack, and type F1(1).

Ok thanks.

So if I define a function with X and Y, then I would enter Y and then X onto the stack, and then type F1(2) to tell it to use the last 2 entered parameters on the stack?

Yes, for a general 2-variable function. Usually, F1 is intended for a single-variable function.


RE: How to use RPN mode with Functions? - lemontea - 03-03-2017 01:08 AM

(03-03-2017 12:52 AM)Han Wrote:  
(03-03-2017 12:37 AM)lemontea Wrote:  Ok thanks.

So if I define a function with X and Y, then I would enter Y and then X onto the stack, and then type F1(2) to tell it to use the last 2 entered parameters on the stack?

Yes, for a general 2-variable function. Usually, F1 is intended for a single-variable function.

Thanks.

But I am thinking maybe I should just use Textbook mode... sad to see RPN go....


RE: How to use RPN mode with Functions? - Tim Wessman - 03-03-2017 02:20 AM

Note that specifying argument count only needs to be done when you have a variable number of arguments.


RE: How to use RPN mode with Functions? - lemontea - 03-03-2017 02:53 AM

(03-03-2017 02:20 AM)Tim Wessman Wrote:  Note that specifying argument count only needs to be done when you have a variable number of arguments.

I tried not specifying anything and it didn't work.


RE: How to use RPN mode with Functions? - Tim Wessman - 03-03-2017 03:05 AM

(03-03-2017 02:53 AM)lemontea Wrote:  I tried not specifying anything and it didn't work.

F1 can take a variable number of arguments.

Use the define key, define a named function, and it wouldn't require it. Nor would something like CEIL, SIN, or similar.