RPN programming perplexity driving me nuts
11-29-2017, 08:53 PM
Post: #1
 lemontea Member Posts: 176 Joined: May 2014
RPN programming perplexity driving me nuts
Hi folks,

Maybe it's my advancing years (lol) or something, but I just can't figure out what is going on.

Wrote a very simply RPN routine on my 15C and the "bug" seems to replicate on 11C so must be a logic issue.

I just want to calculate

X - 1
------
X^2 - 1

(x minus 1, divided by x-squared minus 1)

So this is what I put in:

LABEL A
ENTER
1
-
X <-> Y
X^2
1
-
/
R/S

The way I run it is just typing a number then issuing "f A" to run it.

It seems not to work as intended if I do not press ENTER before issuing "f A"

I thought the first ENTER (line 2) already puts the number I typed into both Y and X on the stack?

And that I do not need to press ENTER before running the program, because whatever I typed (prior to issuing f-A) is already in the X register?

???
11-29-2017, 09:09 PM
Post: #2
 Paul Dale Senior Member Posts: 1,753 Joined: Dec 2013
RE: RPN programming perplexity driving me nuts
ENTER disables stack lift so the 1 on the next line overwrites X instead of raising it again.
The solution is to ENTER ENTER or ENTER then a no-operation (x<>y e.g.)

A quirk that survives.

Pauli
11-29-2017, 09:11 PM
Post: #3
 hth Senior Member Posts: 413 Joined: Mar 2014
RE: RPN programming perplexity driving me nuts
Try:

X^2
LASTX
1
-
X<>Y
1
-
/

The problem is that ENTER duplicates the number, but also disables stack lift.

HÃ¥kan
11-29-2017, 09:16 PM
Post: #4
 Philippe Junior Member Posts: 23 Joined: Aug 2015
RE: RPN programming perplexity driving me nuts
Hi,

You can try here to see how the stack works :

http://hp15c.com/web/hp15c.html

Philippe
11-29-2017, 10:13 PM (This post was last modified: 11-29-2017 10:21 PM by Dieter.)
Post: #5
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: RPN programming perplexity driving me nuts
(11-29-2017 08:53 PM)lemontea Wrote:  Maybe it's my advancing years (lol) or something, but I just can't figure out what is going on.

This should have been resolved now: ENTER disables stack lift, so another ENTER is required.

(11-29-2017 08:53 PM)lemontea Wrote:  I just want to calculate

X - 1
------
X^2 - 1

1
+
1/x

OK, except for x=1. ;-)

Dieter
11-29-2017, 11:13 PM
Post: #6
 lemontea Member Posts: 176 Joined: May 2014
RE: RPN programming perplexity driving me nuts
Wow, thanks everyone.

3+ decades and somehow I got by without knowing that! Haha!
11-29-2017, 11:15 PM
Post: #7
 lemontea Member Posts: 176 Joined: May 2014
RE: RPN programming perplexity driving me nuts
(11-29-2017 09:16 PM)Philippe Wrote:  Hi,

You can try here to see how the stack works :

http://hp15c.com/web/hp15c.html

Philippe

Thanks, this is useful!
 « Next Oldest | Next Newest »

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