What Is RPN? Why Did/Does HP Use RPN? Learning RPN (1999)
hpmuseum.org
hpmuseum.org
The owner set PS1 to resemble a DOS shell prompt and they were satisfied.
Im convinced you could take damn near anything through SFO tech wise, cause they've seen it all. Meanwhile explaining to the TSA people in Palm Springs why I've got 3 laptops, let alone 4 dozen cell phones was always a hassle and a half.
The best features, IMO, were (0) the IR emitter and (1) the ability to program it to switch ON at a specified time and run code.
This means I could hide my calculator somewhere in a room before class started and program it to turn on halfway through class, turn the classroom TV on, turn the volume to max, and start wildly flipping to random channels.
One teacher had all of us students put our hands up and walked around the room looking for who had a remote at their desk, and I remember watching that teacher's face of horror when the TV continued flipping channels as everyone had their hands up.
Even with its lowly Saturn CPU and perceptually slower, it was trouncing the TIs at basically every task, especially when you customised it.
I learned RPN and RPL alright, but also got to dive into System RPL: the low level, faster, much more rich RPL, but where every argument was basically unchecked as it was more like HP-provided ASM routines in disguise.
And then learned to bit-bang stuff on the screen in assembly with all the timing tricks to produce 4 grayscale instead of just black/white. Great for coding small games.
Got the the third party CAS algebra extension card that also replaced the original UI for the same thing, only faster and better, and with a much more potent symbolic solver, whose UI was absolutely glorious to write, select, navigate, and perform advanced stuff.
Also got a maxed out storage expansion for the second slot. Such storage was not solid state so it required a continuously operating CR2032 battery to persist over time.
Unfortunately, as robust as it was, some time after engineering school it took a hard fall too much and was irreparably broken.
Later got my hand on a HP49G+, ARM powered but surprisingly the default was to run an emulation of the Saturn CPU, and CAS was bundled. You could still code for the ARM one though. By that time I lost interest so it currently sits in a drawer. Also preferred the 48 boxy design, especially the mushy keys of the new one were way worse.
----
Sadly my collection of HP and other RPN calculators (there are a few) was stolen two years ago.
RPN has no use for brackets, because there is never any ambiguity.
If you're using "algebraic", you sometimes have to put a "(" into your expression a long way ahead of when you need it. Think of how many times you have to go and fix up your left parens when writing C code conditionals. On a calculator, if you screw up, go back to start. Also, old calculators had parentheses limits.
"Modern" algebraic calculators mitigate this somewhat because they can enter the expression in text form on a dot matrix LCD so you can go back and add/delete parentheses as required.
An explicit stack means that I can start and stop subexpression calculations at various points and cache the results. It also means that I can rearrange precedence at my convenience--of course, the flip side is that precedence is my problem instead of the calculator's.
Is it? It's easier to code an evaluator, but I'm not convinced it's necessarily more intuitive. In practice, only addition/subtraction and multiplication/division are ambiguous. I'll also play devil's advocate and admit order of precedence is somewhat arbitrary, and precedence of bitwise and and equality is wrong in most languages. Not sure why I'd want this: (flags & (4 == 4)), but that's what flags & 4 == 4 does.
One difference is you see all intermediate results. That's huge for avoiding mistakes. In-fix, if you type (5+5)*(9+9), you only see the end result. Post-fix 5 5 + 9 9 + *, you see 10 and 18 along the way.
Another is the stack lets you easily reuse subresults. If you've computed the total energy and want to use it three places, you pick it off of the stack. All your work is there. It's very common that this happens.
It's an incredible productivity boost once you get used to it.
Only if in see-full-expression-before-action mode. Otherwise you would see 10 after the first ), and see 18 after the second ).
Originally there was no && operator. You had to use & for Boolean conjunction too. The precedence makes sense under that condition. (And later couldn't be changed without breaking existing code.)
I would imagine if I were young today and started with a modern multi line calculator with textbook display then that is what I would be comfortable with but for folks born before 1980 or so the algebraic calculators of our time were error prone.
I have an HP 27S that is algebraic and breaks the mold of being error prone because it shows the whole expression up until the point where a part can be evaluated. Then it evaluates the inner part while still showing the rest of the expression.
I prefer to always use RPN. MacOS has an RPN mode on their calculator, which one can activate by pressing command + R. On my iPhone I have an app called i41CX+, which is an HP-41CX emulator. I highly recommend the app, as the developer is constantly updating it. It probably is the most updated app I have of all of my apps.
Also apparently there are some companies that recreate old HP RPN scientific calculators: https://www.swissmicros.com/products
(yes, I know that xcalc has an HP mode, but I only learned of that mode long after I'd begun using GPRN.
The calculator on my Android phone (I 'disabled' the maker installed one):
https://play.google.com/store/apps/details?id=org.efalk.rpnc...
And I've still got my original 80's HP-15C.
And since you're solving part by part, it's easier to spot mistakes in calculations.
Going back to algebraic is pretty much impossible... luckily, there are many rpn calculator apps for phones.
The dev sent me the upgraded one after I reviewed the free(?) one in CNET years ago. I used an HP-41CV with various expansion packs for years. It doesn't have the same feel as the sadly broken physical calculator of course but I still like it. I basically don't anything these days more than simple arithmetic these days though--and if I did I'd use a computer. (I have been tempted by the Swiss Micro models but that would be a pure nostalgia-fueled buy on my part.)
But mostly I use my old 28S which is next to my keyboard always. Also have a 50g on the desk, but I prefer the 28S.
The main one is that the pi and e keys act as if they are invoking constant functions that return pi and e, respectively. On an HP calculator, the pi key enters pi.
That may sound like the same thing, but it is not. Consider this sequence:
2 ln pi x
On my HP 15C the result is to multiply the natural log of 2 and pi. Same thing with PCalc on my iPhone. With OS X calculator the result is either pi with an error beep if you started with an empty stack or pi times whatever was on the top of the stack if you started with a non-empty stack.The "2 ln" part leaves ln(2) on the stack. On the HP and other sensible calculators the pi key pushes pi. On the MacOS calculator, it replaces the top of the stack with pi.
They also had some problems where if you did a function and then started entering digits it would overwrite the function result, but I think they fixed those. I've seen what I thought was that problem recently, but when I finished entering the number and hit enter or invoked a function on the number, the previous function result appeared second on the stack, so it apparently is just a bug in displaying the stack.
Admittedly I only use the OSX calc for very basic +-*/ operations. Anything more than that and I grab the 28S!
<< a -> a a + >> (double function)
Those machines were well before their time.. I hope the makers had fun, it's really sad it's gone from the market although one could say that ES6 in your smartphone browser is your modern day HP48 reincarnation.Defining a DOUBLE word, the usual way, rather than anonymously. (Tricky to pick a good identifier that doesn't sound like it's doing something with double-precision floats.)
( num -- num_doubled )
: DOUBLE DUP + ;
Next up, we push 7 to the stack, define our 'function' (not a Forth term) anonymously using :NONAME which pushes an execution token value to the stack, then we immediately invoke it. This has the effect of printing 14. 7 :NONAME DUP + ; EXECUTE .When calculating with an RPN calculator you do the calculation the same way you would by hand: “ok, figugpre out the numerator, now calculate the denominator, ok, do the division, ok now there’s a product, so do the multiplication, now add it to that fraction I just calculated...” except you don’t need to write down the partial results.
Not only is it fewer keystrokes and parentheses and such, but as you’re doing it as you naturally would anyway you’re less likely to get lost.
The user types less, the computer does a lot less.
I find it fun to think in RPN.
Really? What do you call an operator applied to an empty stack? A sequence of commands that leaves the stack non-empty? I don't see why that's any less ambiguous than mismatched parentheses.
That’s actually a feature. It’s even fundamental in concatenative programming languages such as FORTH and Factor.
[Pi] for example is an operator which can push the value of Pi onto an empty stack.
Here’s the code:
https://github.com/ashok-khanna/RPN-31
Here’s the link:
Don't get me wrong, I love RPN and I've had a stream of HP calculators through my college years (synthetic programming on the HP41!), but... they come at a cognitive price. When you see an expression, you have to process the precedence in your mind to find out the most nested expression and start entering from there.
Basically, the calculator is cheating by forcing you to do some of its job.
If you’re just copying existing expressions, you might as well use one of those OCR calculators.
The point is that it takes time.
As much of an RPN fan I am, I am not convinced that the time it takes my brain to identify nested expressions is smaller than the time it would take me to just type the expression left to right on a regular calculator.
When I first got that thing as kid, nearly returned it, RPN seemed so bizarre. So glad I didn't... Really love that language, would never have understood stack based VMs as deeply if it weren't for the things I coded on that calculator.
Droid48 - https://play.google.com/store/apps/details?id=org.ab.x48&hl=...
Back in the early 80's Forth was the first language available on the original Macintosh. I loved Forth, but it completely ruins you for every other non-RPN language. I remember writing an ASCII terminal (dial-up modem) application in Forth to learn the language, and afterwards every other language that I was using at the time just looked... weird.
I had to perform a massive mental shift to get back into all of the other languages I was being paid to work with at the time, and it was so difficult (for me, anway) that I never went back to it.
Unfortunately, all the Forth I had on hand or could easily find was one of ⓐ something I'd written myself, ⓑ something written for didactic purposes or as an example of the ideal way to do things, or ⓒ by the author of the Forth implementation it runs on. I'd argue that all of these are likely to be atypical examples of Forth style.
About 15 years ago, I was gifted a 1986 12C by our cost accountant. This thing was beat up, missing the badge, and generally nasty; given that and the fact that it is a financial calculator made it pretty much ignorable.
Over the years, the batteries would die in my other calculators and I would reach for that 12C more and more. Eventually the 12C became my main desktop four-banger. Now main did not mean only because I need something to convert between dec and hex, so I also have a TI-36x solar on my desk.
Don't get me wrong, I am a huge fan of the early 90s incarnation of the 36x but I really don't want two calculators on my desk. So last night after reading this thread I was inspired to use some of the programmable features of my 12C and write decimal/hexadecimal conversion routines.
And here are the routines:
DEC -> HEX: GTO 00
Input integer 0-255
Result format is nibble.nibble
e.g. 10.15 = AF
12.05 = C5
HEX -> DEC: GTO 15
Input format is nibble.nibble
e.g. enter 14.13 = ED
1.11 = 1B
Result is an integer
01 16
03 /
04 DUP
05 INTG
06 SWAP
07 FRAC
08 .16
11 *
12 +
13 GTO 00
14 R/S
15 DUP
16 INTG
17 16
19 *
20 SWAP
21 FRAC
22 100
25 *
26 +
27 GTO 14
Now this formerly disrespected lowly financial calculator has grown to be not only my favorite four-banger but now the only calculator I will ever need at my desk.One reason Lisp needs parentheses while Forth doesn't is that Lisp allows a variable number of arguments to functions; Forth generally does not. It's possible to build variadic Forth functions but you have to push the number of arguments as a parameter, which is usually not very convenient. With Lisp, the closing parenthesis delimits the last argument so the Lisp compiler always knows how many arguments were passed automatically.
Polish notation makes both Forth and Lisp very easy to parse compared to algebraic languages, and as the article points out it also makes expressing function composition very easy in both.
I wonder if teaching it early on, instead of parenthesis, would have made math lessons different?
Could there have been different notations used for things like factoring out a quadratic equation?
well, you're talking about high school algebra, but just adjacent to that is the lisp programming language which uses polish notation. It also uses parentheses because parsing the parentheses-less polish notation requires that the operators have a fixed number of operands
Sussman, co author of SICP and co creator of lisp-like Scheme, has a current idea/book/project he's advocating which is to teach physics using scheme instead of algebraic-calculus because the notation is more precise: rather than differential equations which you need to be skilled at reading, you use polish notation computer programs that can be executed and studied.
I was just thinking of notation, but making math parsable, or teaching a regular math notation, that should be a thing.
I remember hearing generalizations like "chess is pattern matching", and "math is just symbol manipulation", but latter really comes to life if we make math notation regular enough to be funamentally machine readable.
Just think what it could do with ai (or for ai)
:-/
Apple not me
The combination of HP quality build and RPN.
Not a chance that I would have allowed anything less waste my desk space
The HP prime and Droid48 apps are nice, but I just don't need calculators as much anymore.
[1] https://www.uiltexas.org/academics/stem/calculator-applicati...
Even RPN has a limit, that being the stack depth --- while most of HP's calculators had 4, the HP48 has one limited only by available memory.
I don't think RPN is a super great fit for multitouch screens but it works really well for keyboard interfaces.
Looking up used editions of WFF'N Proof on Amazon I recognize the instruction book published in 1965. That must have been around the time I received the game. It looks like more recent sets were more extensive.
Well, the game likely had a positive influence on me, I ended up with a Math degree in college. Even in high school, I understood logic and proofs better than the other kids in my school.
https://www.amazon.com/Algorithms-RPN-calculators-John-Ball/...
https://apps.apple.com/us/app/hp-15c-calculator/id503720774
And oh, BTW, I still have my 15c.
It also made for very confused expressions whenever anyone borrowed my calculator...
I know when I'm out with coworkers and they whip out Droid48 to calculate the tip, I picked a good place to work.
Also, the HP 12c financial calculator and the HP 35S scientific calculator are still being sold by HP.