Prem Poddar

Two-Button Scientific Calculator

A calculator with only two buttons that can still do everything: sin, cos, π, complex powers, all of it. The machine comes from the Numberphile video A Two-Button Calculator That Does Everything, where Dr James Grime explains the idea from Andrzej Odrzywołek. Video by Brady Haran. This page is my working version of it.

Everything is computed with exp and ln only. That means ln is the natural log everywhere, and log means log base 10: the page computes it as ln(x) ÷ ln(10).

0 stack: 0

    Copy the presses from the converter, switch to the machine they were made for, and paste them into the Run box to get the same result here. Keyboard: 1 pushes, - subtracts, e is exp, l is ln, Enter is EML on the two-button machine, Backspace undoes one press. On the two-button machine, EML(x, y) = ex - ln(y): it pops y then x.

    Type an expression, get the presses

    Compile it for one of the two machines, then copy the presses and paste them into that calculator above with Run.

    How two buttons do all that

    One button pushes 1. The other, EML(x, y) = ex - ln(y), is enough to rebuild the whole keypad:

    The four-button machine (1, −, exp, ln) gets there with plain stack arithmetic instead. Either way, trig, powers, roots and log base 10 are all rebuilt from those pieces, so a short expression can turn into hundreds or thousands of presses. That is the fun of it.

    Two honest limits of the two-button machine. An operand whose imaginary part passes ±π picks up a 2πi branch error, because EML's ln cannot see past the principal branch. And an addition with a term beyond about e709 fails, because exp(−term) underflows to zero and ln(0) is undefined. The four-button machine has neither limit; its arithmetic is plain stack work. Numbers are float64 throughout.