Are RPN Calculators dead and buried? R U Happy or sad?

(At least, at this particular level of notational decision)

I’ll track down RpnCalc and install it. Thanks!

I have a physical HP 10C right here by my workstation. Lovely old machine, still works like a charm.

Somewhere in this house there’s a functional (last time I saw it) 28S. I need to find that bad boy.

My HP-11c has been used so much the text/info on the back is almost all worn off. All the functions and keys still operate like brand-new. If only all their new products worked as well.

I have my computer science students use a stack to create an RPN calculator in C++. For fun, I have them create a data structure to implement mixed fractions (whole number, numerator, and denominator). It’s a good project that also shows how to do operator overriding of + etc. in C++.

Besides mixed fractions, what else other data structures might you recommend for an RPN calculator? Time (hours/minutes/seconds)? Polar coordinates? Others?

Polynomials are useful. Also, numbers with units (kg, m/s, etc.).

RPN is supposed to mimic the way you evaluate a complex expression - from the inside out.
Say you’ve got something like:
-(134+5/1115+4/99)800+4/74-22.
Following standard precedence (and adding parens because hell, I can’t read that!):
(-(1
34 + 5/(1115) + 4/99) * 800) + 4/(7*4) - 22
On pencil and paper, you evaluate it from the inside out like so:
(-(12 + 5/(165) + 4/99) * 800) + 4/(28) - 22
(-12 - 5/165 - 4/99) * 800) + 1/7 - 22
((whatever, too lazy to figure so let’s call it 100) * 800) + 1/7 - 22
80,000 + 1/7 - 22
79,978 + 1/7

That’s basically what RPN does. But looking at the mess it started with, how do you keep it straight to enter into the calculator? I tried using one, twice, and nearly threw it across the room.

I had a calculator once that let you put in the parentheses. So you could plug that expression in as-is, and it would figure it out.

Oh, and with that expression:
(-(134 + 5/(1115) + 4/99) * 800) + 4/(74) - 22

I think what you’re supposed to do is:
1 (enter)
3 *
4*
then maybe save that to memory?
11 (enter)
15 *
then how do you divide 5 by that?
Hence my frustration.

Write out the expression as a tree. (So when you want to add two subexpressions, draw a little + with arrows to the roots of the subexpressions, etc.). Can you do that? The structure of the tree will be the logical structure of the expression, expressed clearly and unambiguously without any “operator precedence” or any of that, and thus a good place to start.

Just that little part of the expressions: 5/(11*15) would be entered as:
5 (enter) 11 (enter) 15 * ÷

However, RPN calculators typically also have a button that interchanges the top two items on the stack. So you could also enter that as:
11 (enter) 15 * 5 (swap) ÷

Well, but you need to know something about operator precedence to figure out which are THE subexpressions and how they are associated with which others. So don’t discount that.

Correcting my own groupings, I actually did it wrong:
-(134+5/11*15+4/99)800+4/74-22

should group to
( -( (134) + (5/11)*15 + 4/99) * 800) + ( (4/7) * 4) - 22

That evaluates to -15,106.something.

Breaking it down like a tree, I get:
a) 1+3+4
b) 5 / 11 * 15 (not that if you mess up the rules of precedence, you could get 5/(11*15) which is quite different)
c) 4/99
d) add b to a
e) add c to d
f) multiply e by -1
g) multiply f by 800
h) etc.

I guess what I don’t understand is how you do the ‘a’ calculations, then do the ‘b’ calculations separately, and so on.

The calculator on my phone has parenthesis capabilities, so I plugged in exactly what I wrote originally and came up with the correct answer.

How would you enter that (at least up through the multipy by 800) step in RPN?

Also a “1/x” button. So you enter, say, 100, hit the 1/x, and it gives you .001. Another way to put the divisor before the dividend.

Well:
a we would write as 1, 3, 4, *, * [I assume you meant * instead of + here]
b we would write as 5, 11, /, 15, *
c is 4, 99, /
d is a + b. So we write the expression for a, then the expression for b, then +: this gives 1, 3, 4, *, *, 5, 11, /, 15, *, +
e is d + c: So we write the expression for d, then the expression for c, then +: this gives 1, 3, 4, *, *, 5, 11, /, 15, *, +, 4, 99, /, +
f is e * -1: So we write the expression for e, followed by -1, followed by *: this gives 1, 3, 4, *, *, 5, 11, /, 15, *, +, 4, 99, /, +, -1, *
And g is f * 800: So we write the expression for f followed by 800 followed by *: this gives 1, 3, 4, *, *, 5, 11, /, 15, *, +, 4, 99, /, +, -1, *, 800, *.

The whole thing follows the pattern: “To transcribe a tree into RPN, first recursively transcribe the child trees, then write the root operation.” This is just like ordinary mathematical/programming notation for expressions built out of general functions [like “f(g(3, 5), h(3, f(4, 3), 1))”], except with the operation coming after the arguments instead of before them.

No, that’s algebraic, 2 + 5 = 7, only vertical. Add more addends and it looks more RPN:


  3
  4
  2
+ 5
----
 14 

because the operator appears to be postfixed, but that’s not how you solve it because you are not shifting things onto a stack in your head then solving it all at once. What you are doing is: 3 + 4 = 7, 7 + 2 = 9, 9 + 5 = 14. Make the addends more than one digit and it becomes none of the above, but with the sum being the result, when you do it by hand, of a sequence of single-digit additions in columns.

Natural? I can see nothing natural about it, and I’ve used both. Though I like RPN fine, in small doses and short formulae, it strikes me as a kludge from the days of weak microprocessors that some people have taken to heart and made its weaknesses virtues, but to each his own. I prefer a calculator that thinks like I do (without the tangents) and calculates the way I would lay out the formula on paper.

Where on the stack? Are you sure where? And what are you going to do with the numbers above it? For me, my numbers are in one of the several memory slots I have available to put them, with “1” being one of the possible values of “several” and “a piece of paper” standing in for the rest. Anyway, most tax returns can be calculated with a pencil on the return itself. :smiley:

Yes, this too.

And similarly for reverse subtract: If you find it convenient for some reason to put the subtrahend before the minuend (remember subtrahend and minuend?), you could use the “Change sign” key (which most calculators have), or the “swap” key.

Example: Doing 10 - 7, if for some reason you felt the need to enter the 7 first:

7 (change sign) (enter) 10 + (Note that after changing sign, you still have to press Enter, at least on my calculator.)

OR: 7 (enter) 10 (swap) -