- Best all-around: PCalc. Math 42 is one part calculator and one part math tutorial. Math 42 (free) goes beyond functioning as just a calculator, adding in quite a bit of education to the mix.
- Amazon.com: Pleatco PCAL42-F2M Replacement Cartridge for Cal Spa Avalon - M-07-A726LMA-26 Cartridge, 1 Cartridge: Swimming Pool Cartridge Filters: Garden & Outdoor.
- What is the value of antilog 10 100? The value of antilog 10 (100) is a googol, or ten thousand sexdectiollion, 10 100, or 1 followed by 100 zeroes.This is found by solving the equation y = b x, where in this instance the base, b, is 10 and x is 100.
That's why the PCalc icon still has a 42 on it - it's meant as a tribute to him. I didn't know him very well, but he was always enthusiastic about my work, and as a huge fan of his writing, that meant a lot. Anyway, I let PCalc make its way around the world, while I actually did some work for my degree.
May 1, 2013 at 11:11 AM by Dr. Drang
If you followed my advice back in December, you bought PCalc for the ridiculously low price of 99¢ during its 20th anniversary sale1 and have been using a first-class calculator for the past four months. With Version 2.8 just released, you’re going to see its value explode with two new features: user-defined conversions and user-defined functions.
Pcalc Calculator
PCalc added an f(x) key in Version 2.6 as a way to access functions beyond those available on the keys. Initially, the additional functions were limited to whatever the developer, James Thomson, gave us. Here’s me, back in December:
What I’d really like to see, though, is an expansion of these functions. Things like present value, future value, and internal rate of return are natural for the financial section. And the statistical section could use functions for the normal and inverse normal cumulative distribution.
This was not based on any insider knowledge. High-end calculators have been programmable since the 70s, so it was only natural to expect that functionality to come to PCalc eventually. We just had to wait for James to figure out how he wanted to implement it.2
In this post, I’m going to focus on creating user-defined functions. The creation of user-defined conversions follows almost exactly the same steps and has access to the same set of commands—once you’ve learned how to define functions, you’ll have no trouble defining conversions.
Creating a new function
Start by tapping the f(x) key to see the list of function categories and then tap the Edit key in the lower left corner. You’ll get a ⊞ key in the upper right corner, which will allow you to add new categories. As you can see below, I’ve added three categories: Financial 2, Probability, and Weather.
![Piccalc Piccalc](https://live.staticflickr.com/4059/4577647383_10f3041703_b.jpg)
Tapping the ⊞ key on this screen will create a new category. Tapping that category takes you to a screen where you can rename it and then start defining new functions.
Tapping the new function takes you to a screen where you can rename and define it. PCalc starts you off with two commands: one that puts you in decimal mode (if you weren’t already there) and one that multiplies the current value by the universal constant.
You can change these by tapping them, which will take you to a command editing screen we’ll discuss in a bit, and add new commands by tapping the ⊞ key.
The command set
PCalc gives you 39 commands from which to build your function. Here they are, with descriptions, as they appear in the scrolling list you see as you construct your function.
Seven of the commands have only one part—the command itself with no arguments. These are typically commands that set the calculation mode, like the Decimal Mode command we saw above or the Radians Mode command.
Seventeen of the commands have two parts, in which you have to choose both the command itself and a single argument. The trig, log, and exponential commands work this way, as does the Clear command.
We’ll discuss how to set the argument in a bit.
Nine of the commands have three parts: the command and two arguments. The basic arithmetic commands (My Dear Aunt Sally) fall into this category, as does the command that sets a register.
Finally, six of the commands have four parts: the command and three arguments. These are all branching commands that test one value against another and skip a given number of steps if the test is true.
Variables and constants
Numerical functions need places where they can store numbers and retrieve them from. PCalc provides 29 such places: the X and Y registers, ten memory locations, sixteen registers, and a special register called Tax Rate used in some of the builtin financial functions. In addition to these read/write variables, there are three read-only constants: Pi (π), a uniformly distributed random number between 0 and 1,3 and a user-defined constant called Value.
Here’s PCalc’s scrolling list of variables and constants you can choose from. If you’re setting or changing a value, the constants don’t appear in the list.
The X and Y registers and the memory locations are accessible any time you’re using PCalc. Merlin 2 9 1 – project management software. Registers 0-9, A-F, and the Tax Rate are accessible only through the programming environment; they’re the best place to store intermediate results because they don’t alter what the user has stored in memory.
Update: James says the persistence of the registers is part of the design, so it’s safe to take advantage of that if you want.
A simple example
Let’s look at a five-step function for calculating the future value of an investment. The formula is elementary:
[FV = PV ; (1 + i)^n]where (FV) is the future value, (PV) is the present value, (i) is the interest rate per compounding period, and (n) is the number of compounding periods.
The function I defined calculates just the ((1 + i)^n) part. It gives, in effect, the multiplier associated with the compounding. Here’s the function defined in PCalc:
It expects the interest rate in the Y register and the number of compounding periods in the X register; it returns the future value multiplier in the X register. To run this function in RPN mode, which is what I use, you type in the interest rate, tap Enter, type in the number of compounding periods, and then select the Future Value function from under the f(x) key. In algebraic mode, you type in the interest rate, tap the x~y key, type the number of compounding periods, and then select the Future Value function from under the f(x) key. It’s the same amount of work either way.
Pcalc For Windows 10
James has decided that functions that need more than two arguments will have to use the memory locations for the extra arguments. I’d much prefer to be able to load up the RPN stack with all my arguments (it’s faster than entering values into memory), but that would leave the algebraic users out in the cold.
Sharing functions
You can share the functions you write with others by tapping the share button and sending an email with the functions bundled up in an attachment. When the recipient gets the email, she can tap on the attachment and choose to import them into her copy of PCalc.
It’s my understanding that functions you define on one iOS device will be automatically available on your other iOS devices through iCloud syncing. With only an iPhone, I have no way of testing this.
Programming on your computer
For functions with only a few steps, the tap-scroll-tap method of creating functions on an iPhone or iPad is just fine. But for more complicated functions, it’s easy to get lost and make mistakes. Fortunately, there’s a way to program PCalc in your favorite text editor.
When you send an email with a shared bundle of functions, the attachment is a plist file with a
.pcalcfunctions
extension. If you save this file to your computer, you can open it in a text editor to see the usual plist structure. Each function is a <dict>
, with its code stored in a string using a compact little language. Here’s definition of the Future Value function described above:If we rearrange the string of code, it’s easy to see how it relates to our definition above.
This shows us the path to writing long, complicated functions:
- Create a new function in PCalc. Give it the name you want and put it in the category you want, but don’t bother changing the definition from the two-command default we saw near the top of the post.
- Share that function with yourself via email. Open the email on your computer and save the attached
.pcalcfunctions
file to disk. - Write the function you really want in the little language used in the
,pcalcfunctions
plist. I write mine with each command on its own line and then do a search-and-replace to turn it into a long, semicolon separated string. - Replace the default commands in the
.pcalcfunctions
file with what you just wrote. - Send yourself an email with the edited
.pcalcfunctions
file attached. - Open that attachment on your iOS device to install the redefined function. It’ll replace the old definition.
This may seem like too many steps, but it’s much easier than writing a long function directly in PCalc.
One of the functions I wanted is the cumulative distribution function for the standard normal. There is one of those integrals that can’t be performed analytically, so it has to be approximated. Here’s a good approximation from Abramowitz and Stegun:
And here’s that formula (generalized to handle negative arguments) converted into a PCalc function:
It’s much faster to type the lines than to scroll through the list choosing commands and registers, and it’s easier to see the overall logic this way.
All the command abbreviations
The main difficulty in writing PCalc functions in a text editor is figuring out what the abbreviations are for each of the commands. To help with this, I created, in PCalc, a fake function with 37 steps—one for each of the commands. After sharing this function and opening the
.pcalcfunctions
file on my computer, I extracted all the commands. Here they are with their default arguments and an explanatory comment:These are in the same order as the screenshot list. Most of the names are immediately obvious; others take a little thinking to understand. The inverse power command,
roo
, is short for root.4 The b at the front of beq
and the other skip commands is short for branch. The only one I’ve had trouble remembering is pwr
, which I tend to type as pow
.Finally
A calculator isn’t necessarily the best tool for complicated analyses, but sometimes it’s the best tool that’s readily available. Because PCalc is in my phone, its capabilities—whatever they are—are always with me. The addition of user-defined functions allows me to do calculations away from my desk that I couldn’t do before.
This post wasn’t intended to be a breezy read. Its main purpose is to act as a reference to help you (and me) get new functions written. I don’t know if James intends to host a repository of functions at pcalc.com, but I’ll be putting all my functions in this GitHub repository. At present, it has three sets of functions:
Financial 2.pcalcfunctions
. This has the future value function shown above, a present value function, and a loan payment function.Probability.pcalcfunctions
. This has the standard normal PDF, CDF, and inverse CDF.Weather.pcalcfunctions
. This has functions for calculating the wind chill factor and the heat index.
Pcalc 42
The README is pretty rudimentary at the moment, but it does explain the inputs and outputs of each function. I’ll be adding better explanations of the underlying calculations soon. Nutxt 3 170.
- How can an iOS app be 20 years old? Strictly speaking, it can’t, but its older cousin, PCalc for the Mac, was 20 years old in December, and iOS PCalc joined the celebration. ↩
- There may also have been a question about the iOS developer rules. Programmability used to be a no-no, but with things like Pythonista that restriction has clearly been lifted. ↩
- OK, a random number isn’t a constant, but I lumped it in with the constants because it can’t be written to. ↩
- If you were thinking it had something to do with Winnie the Pooh, you’ve got the wrong beloved English author in mind. If James were going to name a command after a character, it’d be Zaphod Beeblebrox, which would be tough to squeeze into three characters, even with Unicode. ↩
I’ve had my Swiss Micros DM42 for about a year now and I thought I’d write some thoughts about it. The Swiss Micros DM42 is a semi-faithful clone of the HP-42S, an RPN calculator HP sold from 1987-1995.
This will be a long and rambling post… you have been warned. It is more of a log of a journey than a review.
So first, why the heck do I even need a calculator? How does someone my age end up using a calculator when iPhones, Wolfram|Alpha, and Excel exist? And why would I spend a decent amount of cash on a physical calculator based on a 30-year old design and not buy a much cheaper and more capable modern design?
Background
I’m a physicist by training. I’ve worked as a plasma physicist, a (mechanical) design engineer, and now as something in between1. I went to high school in the mid ‘90’s and got a TI-81 (I think?) at some point in early high school. By the time I got to college, it was mostly useless, particularly in physics courses. I think it served primarily to hold books open to the right pages. I remember one of my class mates had a weird-ass HP graphing calculator that I could never figure out how to work. That was all the exposure I’d had to HP calculators (and RPN) for the first 30 years of my life.
Fast forward to the late 2000’s. I’ve been to graduate school, never having bought another calculator, and done a post doc as well. All of my math is in python or Mathematica, or honestly, by hand. With the arrival of smart phones, I find myself using my phone as a calculator periodically. I think I read a recommendation on Daring Fireball or And now it’s all this for PCalc and I purchase it for my phone. I slowly start using it more and realize it’s nice not to have to fire up a program for a quick calculation.
Sometime in 2009 there was a release note for PCalc where ‘Optional HP48-style RPN behavior’ was added. I didn’t know what this was so I tried it out. “RPN is weird,” I think. But I start to see the usefulness of the stack and stick with it for a while, then I made the move permanent.2 I also become enamored with the ability to easily access to multiple memories.
A few years later, I start a new job as a (mechanical) design engineer. I’m now disconnected from all of my old tools due to corporate policy. I still mostly am using my phone as a calculator, far more than is reasonable. I finally break down and order some calculators. At this point, I dig RPN and that’s what I want to buy. I do some research and see that HP still sells the HP 35s and the HP 50g, along with some business calculators. I also download a bunch of RPN calculator apps on my phone and find the wonderful Free42, an HP-42S clone. “Man, I wish I could buy an HP-42S still.”
The 50g is a large graphing calculator and is completely overkill for what I need. It’s also complicated in it’s use. HP has also released its next generation calculator at this point, the HP Prime, but it’s also complicated, had more limited RPN at the time, and has a rechargeable battery that doesn’t last ‘forever’. For complicated stuff, I’d rather go to python or something. I want a smallish calculator that I can bang out some quick calculations on, not have it go to sleep on me, and only need its battery replaced once a year.3
So the 35s it is. The 35s is decent but has some annoyances, mostly with its display, the inability to backup to a computer, and partially with its programming limitations. It’s still better than the other options. The multiple memories (storage registers in HP lingo) are killer, as are some of the easy unit conversions and universal constants accessed with just a few button presses. I also become enamored with the easy linear fits to data and HP Solve. This isn’t a review about the 35s but if you are looking to spend < $50 on a programmable RPN calculator, it isn’t too bad.
Free42 and the DM42
As I mentioned, I also found Free42 for my phone around this time and was blown away about 1) how powerful and relatively easy to use an almost 30 year old calculator is and 2) how much time was put into Free42 to make it as good and faithful as it is. The HP-42S (and Free42 by extension) seems to exist in that region of complex enough to be powerful but not so complex to be complicated to use.
During my research of the prior weeks, I also heard about a small company named Swiss Micros who makes some clones of a few of the classic HP calculators. It was rumored they were working on a larger screen HP-42S-like clone as well. And holy shit, they were going to use Free42 as the code base. This was really cool because Free42 is a faithful recreation of the HP-42S, which means you can run any program written for it on Free42. In addition, the author of Free42 put a lot of work into the numerical implementation, giving the calculator 34(!) digits of precision in its calculations. Total overkill, but cool nonetheless.
Over the next year, I saw updates on the calculator and started to think this thing will actually get made. Mid year (I think), hardware starts to show up in a beta test program. I decide to wait it out and just purchase one of the first run units.
On to the actual DM42
At the very end of 2017, my DM42 arrived, just in time for me to start at NASA as a non-contractor. I use it almost every day, at the very least for a quick conversion or calculation.
I’ve had the calculator now for a bit less than a year and I’ve not had to replace the battery. The calculator can be powered over USB, and it also gets a speed boost when connected to USB power.
The display
Oh, the screen. The screen is big and sharp. I think it is one of the best 1-color LCD screens I’ve seen in a device. Up to five configurable lines can be displayed at once, giving you the full stack and Last X or Alpha register all at once. There are two font choices, several sizes available (configurable on a line by line basis), and several stack layouts to choose from.
In addition to the niceness of the screen while on, when off, the calculator goes into a super low power mode where the screen can still display an image (like eink). I quickly made up some ‘off screen’ images of pictures I like. The pictures must be 1-bit black and white bitmaps. I ran the selected images through another mini-project of mine that I coded up, an implementation of Atkinson dithering, which reminds me fondly of playing with a classic Mac as a kid.
New features
The DM42 has a few features that the HP-42S and/or Free42 do not have:
- Free42 added some time and date functions that didn’t exist on the HP-42S. Since the DM42 has an internal clock, these functions came along for the ride.
- The aforementioned ability to display all four stack levels.
- Ability to import and export programs, inherited from Free42.
- Ability to save and restore the full calculator state. This is useful for testing purposes and backing up work. Some have suggested that you could set up ‘workspaces’ that you toggle between, i.e. an engineering setup and a finance setup. I’d rather have my stuff all mixed together.
Programming
In general, programming on the DM42 is similar to on the 35s and other more modern RPN calculators, and almost exactly the same as on Free42. You can see the actual key strokes entered as opposed to the 12c/15c style address. You can also see up to 10 lines of code at once which is nice. Lastly, you can import and export programs by mounting of the calculator as a USB drive. They do need to be converted to the raw binary format for the calculator to use them.4
I’ve written (and modified) a bunch of programs for work:
- A ‘time sheet’ program.
- A program to take data in a matrix and send it to the summation registers for statistics.
- I customized some available units and conversions programs for plasma physics and electric propulsion applications.
- Some quick utility functions for converting voltages into real units for a few of our commonly used pressure gauges.
- A utility to calculate rate of rise as a quick check on leak rates for our high purity feed systems. This utility is something I can run quickly while performing the 24-hour rate of rise test (and before I have access to the real data).
- A utility to help set flow rates based on other parameters.
- A simple dice program.
- A few statistical distribution programs that I used to learn the solve and integration functions.
The negatives
I only really have one negative impression of the calculator. I’m not a huge fan of the keyboard. It’s not bad, but it’s not great. The keys on my 12c are much better, as are the ones on the 35s.5 They are a bit small and hard, and every once in a while miss a press. They also don’t look anywhere near as nice as the vintage 12c/15c keys. I wonder if we will ever see buttons like that again. (No.)
While I would personally spend extra money to upgrade that aspect of the DM42, it should not be a deterrent.
Pca Calculation Example
Appreciation
I’m very impressed and thankful that there are ‘crazy’ people like Swiss Micros and Thomas Okken (author of Free42) who have spent considerable energy scratching an itch.
Piccalc
Swiss Micros DM42 summary
The Swiss Micros DM42 is a wonderful tool. Highly recommended.
Rating: ★★★★★
Pcalc Lite
- A ‘Research AST’ is my title, which is short for AeroSpace Technologist. Technically I think I am classified as an Electrical Engineer. ↩
- Incidentally, this was around the time I started using Vim full time, so I guess I was into experimenting with obtuse and esoteric entry methods. ↩
- As a side note, while the HP Prime and its TI counterparts are incredibly powerful, they are targeted at the education market which is slightly different than what a ‘professional’ might want. I rarely need to graph something on the go; that is a task for Mathematica or python for me. In addition, I graph analytical functions ever more rarely; I graph data. Portability and battery life are more important than raw power. Likewise, there is something appealing about keystroke programming for quick and dirty recurring tasks. ↩
- I recently wrote a python script to encode text programs into the raw binary format that the DM42 expects. ↩
- The 12c is a newer Platinum model. I like the keys on that more than the 35s. The 50g is a bit worse and mushier than the 35s, but fine in actual use. ↩