Quadratic PCalc

When in the course of human events it becomes necessary for a person to dissolve the computational bands which have connected him with an app and to assume among the powers of the earth, the separate and equal station to which the Laws of Mathematics and of Polynomials entitle him, a decent respect to the opinions of other users of the app requires that he should declare the causes which impel him to the separation.

A few months ago, I explained why I wrote my own combinations function for PCalc. Today I declare my independence from its quadratic formula function.

We all know the quadratic formula. It works on equations that look like this,

[ax^2 + bx + c = 0]

and provides the two solutions:

[x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}]

It’s the ± that gives us two solutions. One of the solutions uses the minus and the other uses the plus.

PCalc comes with a quadratic solver function. You can find it in the Special section of functions, and it has a very long and explicit name.

PCalc built-in quadratic formula

What the name is telling you is to put the a term in the X register, the b term in the Y register, and the c term in the memory (or the M0 memory if you have multiple memories turned on). Then the two solutions, [x_1] and [x_2], will come out in the X and Y registers.

This solution has the advantage of being usable to every PCalc user. It works whether you have multiple memories on or not. More important, it works whether you’re in algebraic or RPN mode. It’s also presented in a form that should be familiar to anyone who knows what the quadratic formula is. PCalc’s developer, James Thomson, was careful to set it up with universal applicability.

But I don’t care about universal applicability. I care about what seems natural to me, and the placement of the a, b, and c terms has never seemed right to me. So I wrote my own quadratic solver function that fits with the way I think.

First, there’s no need for three inputs. Any quadratic can be put in the form

[x^2 + bx + c = 0]

without any loss of generality by dividing through by the leading coefficient. This means the inputs to the function can fit in the X and Y registers—no need to use one of PCalc’s memory registers.1

Second, I prefer to enter the b term in the Y register and the c term in the X register. In RPN mode, I enter them onto the stack in what I consider their natural order: b first and then c. Even if I were in algebraic mode—which I never am—it would seem more natural to me to enter b first, press the x~y key to put it in the Y register, and then enter the c term.

So with that design of the inputs, the PCalc function for the quadratic formula looks like this (the long screenshot was stitched together with PicSew):

Quadratic formula in PCalc

If you don’t want to enter the steps yourself, you can download it.

Note that if the equation has complex roots, my function will throw an error. This is consistent with PCalc’s built-in quadratic function and with how it handles the square roots of negative numbers. PCalc is a real calculator.

To solve a quadratic, I just enter b and c in that order and call the function. Here’s the input and output for the equation

[x^2 + x - 6 = 0]

Quadratic input and output

I hold that for the kinds of work I do with quadratic equations, the superiority of my quadratic solver function is self-evident.


  1. You may think that dividing through by the leading coefficient is extra work. Not really. Most of the quadratics I deal with already have a leading coefficient of one, so I seldom need to divide. And even when I do, the two divisions can be done quickly with RPN stack manipulation. It’s harder for me to remember which term goes into memory than it is to do two divisions.