mathstodon.xyz is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance for maths people. We have LaTeX rendering in the web interface!

Server stats:

2.8K
active users

I've been reminiscing a lot about calculators lately. I started learning math just when electronic scientific calculators were replacing slide rules as tools for engineers.

But scientific calculators are themselves almost extinct outside of the classroom, because computers, smartphones and tablets running powerful CAS or numerical software can do all the kinds of computing you really need... unless you're not allowed to use them because of classroom or exam restrictions.

So the market has contracted to education, and the high-end calculators sold today, though they're extremely powerful, are very much catering to students rather than to engineers or scientists. There's a lot of power siloed into user-friendly apps, but less ability to link those together into powerful custom-built systems of your own design.

And inevitably, because I'm getting old, I have a lot of nostalgia for old ones... particularly for HP's RPL line, starting in the late 1980s with the 28C (which was woefully underpowered, but the potential was there) and continuing through the very capable 28S and 48/49/50 series.

The ones I actually had were the 28S and the 48SX--the latter got stolen after just a few years; it was too damned expensive to leave lying around. I still have the 28S somewhere though the batteries for it can be hard to find. But I've been getting back into messing with them through emulation. Here's Calculator Culture's review of the 48SX that goes through its innovations, strengths and weaknesses.

youtube.com/watch?v=yujtxo5efb

HP's scientific calculators were quirky in that most of them until quite recently solely or primarily used postfix or Reverse Polish Notation (RPN), a stack-based system in which every operator followed its operands: to add 2 + 3, instead of

2 + 3 =,

you'd press

2 [ENTER] 3 +.

These calculators had a stack, that is, a list of numbers represented as a vertical tower that they would generally enter and exit from the "bottom" (in HP's terminology, at least). In the addition above, the ENTER key would signal that you were finished typing a number and put the 2 on the stack. The + would implicitly do an ENTER if necessary, then take the bottom two items off the stack and add them.

For more complex calculations, there was no messing around with order of operations or nested parentheses--the stack was everything. So, say, (4+5) * 3 - 2 could be entered as

4 5 + 3 * 2 -

(where it's understood you type ENTER after every number not followed by an operator.)

The joke was that an advantage to using an HP was that nobody ever asked to borrow your calculator more than once. But for complex calculations off the cuff, people who used them soon learned to prefer RPN to algebraic entry, and I still like it.

Now, the RPL line overhauled and expanded this system in ways that annoyed some RPN calculator purists, but it was where I came in, so none of this bothered me much.

HP's older calculators all had a four-level stack, with levels named X, Y, Z and T, and they often only showed the bottom, X level on the display. With these new models, the stack was "infinite" up to the capacity of the calculator's RAM, and they'd display the bottom few levels.

And instead of just storing numbers, a single stack level could store... *anything*: a matrix, a vector, a complex number, a string, a bitmap image, even a function or an algebraic expression. Or a list of other objects.

Because the programming system in these models had been expanded into a functional language with list processing, that could script anything the calculator could do, called RPL (which unofficially stood for "Reverse Polish Lisp"). RPL was my favorite programming language for a while, back in the day, though I'm rusty. For a handheld device in the late 1980s it was mind-blowingly powerful.

These calculators were also the first to have some CAS and graphing capabilities. They could do some symbolic algebra and symbolic calculus on algebraic expressions (on top of the numerical evaluation and integration of functions that HP's scientifics could always do).

Probably the most controversial thing to older-school HP fans was that the algebraic expressions that the symbolic math functions could manipulate were *only* expressed in algebraic notation, not in RPN. Beginning with the 48, there was even a "WYSIWYG" equation editor. That was anathema to some, and I suppose in some ways it was the crack of doom for RPN as they'd known it.

A thing I'd forgotten how to do until the other day was how to define a new function that could not just be evaluated (like executing a program), but actually be used in algebraic expressions that you could simplify, graph, differentiate and so forth. The answer was the DEFINE key. Thinking about it is a little illuminating about how it did CAS stuff.

If I wanted to define my old friend the Gudermannian arctan(sinh(𝑥)), I could just write a little RPL program that went

« SINH ATAN »

and store that in a variable called GD, and it'd make a button that would find the Gudermannian of the bottom thing on the stack. Great! Simple! But if I put GD(X) in an algebraic expression, it won't work. The CAS and graphing stuff isn't up to chewing on arbitrary RPL programs.

But what will work? If I instead enter the algebraic equation

'GD(X) = ATAN(SINH(X))'

and hit the DEFINE key, now what happens seems to be exactly the same, only now I can use GD(X) in algebraic expressions just like it was a built-in function. I can differentiate or integrate it, I can graph it, great!

If I look at the contents of the GD variable, what's in there? It's still RPL, but it looks like this:

« → X 'ATAN(SINH(X))' »

Ha, it looks kind of like a lambda expression with a bound variable, but in RPL! I guess I know why they call it Reverse Polish Lisp.

Anyway, the pattern from the perspective of the user interface was clearly that anything you entered algebraically could be manipulated by the symbolic math system, whereas anything that was pure RPL couldn't be.

So this "lambda expression" format was a kind of wrapper to make an RPL program that just represented an algebraic expression. (I *think* that the algebraics were really represented internally in an RPL-esque format, but it was clearly a specially restricted subset.)

There was another level called "System RPL" that was compiled and removed a lot of type checking for speed, and in which apparently the internal utilities were written, but I never got into that. User RPL was enough.

Anyway, how am I even messing with this stuff, given that I don't currently have batteries for my 28? Well, there are free emulators for these things.

For a while, I've had an Android 48G/48S emulator on my phone called Droid48, and I actually use it for day-to-day calculation sometimes. Most of the advanced capabilities of these calculators can be done better by other means these days--Wolfram Alpha has a phone app that is, like, three bucks, and even the Google search bar is a fairly sophisticated calculator. But sometimes you want to bang out stuff in RPN.

Lately I discovered that a much fancier, popular Windows emulator called Emu48 had been ported to Android--this one actually supports a whole bunch of HP calculators, including the 50g, which was the latest and greatest in the line, from 2006.

The 50g was a big enough beast that its keyboard can be a little difficult to manipulate on my little phone screen, but it's impressive.

It added something that must have seemed even more like the crack of doom for reverse Polish notation: a purely algebraic entry mode much like TI's calculators... which is the default! But you can switch it to RPN entry easily.

But that was the last RPL calculator. Later ones do have a simpler RPN mode, but their programming environments are different.

youtube.com/watch?v=eBK60gQjeI

Most of these ran on HP's custom Saturn processor, but the HP50g was actually running an ARM processor and emulating a Saturn-based system. Another sign of changing times.

As much as I liked RPL, I wasn't thinking in terms of functional programming at the time; I tended to write traditional procedural programs and I think I only barely scratched the surface of what it could do. In some ways it was way ahead of its time.

...But reading old forum conversations on this, the consistent pattern seemed to be that RPL made people unfamiliar with it (aficionados of older HP programmables, and people who wanted to program in any other kind of language) *extremely angry*. It had a reputation for being incomprehensible. The older HP fans got incensed just that it used different names for stack operations (derived from Forth) than older HP calculators did. So maybe HP just realized that nobody other than a particular small subset of their fan base wanted it.

(Why is "reverse Polish notation" called that? Well, "Polish notation" is a prefix notation, in which the operator always comes *before* the operands, and it was invented by the Polish logician Jan Łukasiewicz. Lisp uses a variant of it, though Łukasiewicz's version avoided parentheses, which you can do if the number of arguments for an operator is fixed, whereas Lisp slings around parentheses like there was just a clearance special on parentheses at the parentheses store. Anyway, RPN is the reverse of that.)

Matt McIrvin

I should also say that in the HP calculator community specifically, "RPN" is often used to mean "RPN but *not* RPL": a four-level numeric stack, and there are buttons that say "R↓" and "x⇄y".

Most of these calculators supported a simpler programming model, essentially keyboard macros plus branching and looping operations, which varied in the details from model to model.

The beloved Voyager series, like the 15C, were all like that, and the mighty 41C, which was easily the most powerful pre-RPL calculator HP made, more of a full-fledged handheld computing platform with all manner of accessories and peripherals. HP actually went back and made more of these after the RPL series was established--the HP42s has a passionate fan base of its own.

A thing I always wondered was why the first RPL calculator, the HP 28C, was so underpowered for its operating system--just 2K of RAM, which would quickly run out if you were trying to use its powerful software to do anything significant.

Apparently (based on a comment I read somewhere) it's because the hardware was just a repurposing of the HP 18C Business Consultant, which had the same physical clamshell design as the 28 but was a business/finance calculator. The 18C's software was written in RPL, but RPL was not exposed to the user, it lacked the 28C's complicated algebra/calculus/scientific functions, and it didn't need more than 2K to support its capabilities.

HP felt that this radical overhaul of their scientific line was a big risk, and the easiest way to mitigate that was just to ship the first model on the 18C's hardware without spending any money on upgrading it. Once it was successful enough, they came out with the 28S with far more RAM, and eventually the 48SX which was more or less what the designers of RPL had really wanted to ship in the first place.

I had a 28S, which expanded the RAM to a much more reasonable 32K, and added a few software enhancements. I loved that calculator and used it through most of college.

The clamshell case was divisive but I thought it was a great design--apart from the fragile battery door, which had a tendency to self-destruct over time under the pressure of the powerful contact springs, a real design flaw.

Having all those keys reduced the amount of shifting you had to do, and you could fold the alphabetic keyboard back for handheld operation if you only needed basic calculator functionality. The 48 went to a more traditional vertical format with three shift keys and I was *slightly* disappointed by that.

But the 28's display was kind of short, which limited its graphing capability. The most ambitious program I wrote for it was a utility to render and display tall graphs that you could scroll up and down through with the arrow keys. It used the "graphics strings" capability that was one of the 28S's new enhancements. A friend of mine, who has since passed away, had a work account with a connection to the Internet and posted a listing of the program for me on the Usenet group comp.sys.handhelds; that was (by proxy) my very first Internet activity of any kind.

hpmuseum.org/hp28c.htm

www.hpmuseum.orgHP-28C/S