HP-12C Financial Calculator

Updated 12 November 2023


Hp-12C Financial Calculator

Hp-12C financial calculator 1998

Introduction

The HP-12C Financial Calculator is a standard device used in finance and education, for more than 41 years. The IBM PC started production in 1981, the same year as the HP-12C. There is almost no other electronic design from 1981 that still can be purchased, as a new item in 2022. One item that comes to mind is my Technics turntable for playing vinyl recordings.

I recently purchased a second-hand, 1998 vintage, HP-12C Financial calculator from an auction at a low price. It was essentially in original condition. I thought it would be a good retirement project to turn it into a useful scientific calculator, along with the original financial functions.


HP-12C Financial Calculator Versions

According to Wikipedia the HP-12C is HP's best selling product. There is a Platinum version which has up to 400 program lines, added algebraic capability and a few extra functions - including x2, Undo and a Backspace key. Numerous HP-12C articles can be found on the internet. The links at right are a good start.


HP-12C
              Financial Calculator

Hp-12C financial calculator 1998 - back


I have a "Platinum" version of this calculator, also from an auction. It is a bit unusual, as it is, in fact, a standard HP-12C with a "Platinum" branded faceplate. It runs 170 times faster than my original HP-12C, so I am keeping it as a working calculator. This calculator did not cost much and it is otherwise in good condition.

Summing 1s in a loop gives 86200 counts in 1 minute. A self test shows that the calculator manufacture date was 2015-01-30.

A DM12 calculator is available from SwissMicros. This is supplied either as a DM12 credit card sized version or a DM12L full size calculator. Both use an ARM micro-controller in a titanium case. The speed is somewhere between the two HP-12C versions I have here. Two operating speeds can be set with a battery life penalty for the faster speed. There is a technical manual covering all the SwissMicros Voyager series calculators. The USB interface allows programs to be saved or loaded using a serial terminal session and a programming tool.


Science Program 2

The revised program I created to add scientific functions to the HP-12C financial calculator is linked here: Science Program 2. I hope this is useful. The list below summarises all the functions:

  • Sin(θ), sin-1(x), cos(θ), cos-1(x), tan(θ) tan-1(x). The inverse trig functions are calculated using the Newton solver.
  • Solves polynomials up to 4th order using the Newton Solver.
  • Parallel resistance calculation.
  • Harmonic mean, using the extended resistance calculation and multiplying the result by the number of entries.
  • Geometric Mean, which is progressively calculated for each entry
  • Newton Solver, with completion dependant on the number of decimal places set.

Log(x) = ln(x)/ln(10) is not worth programming. If 𝝿 is required, I can simply keep 3.141592654 in a register, which requires only one program line when used in a program.

Internal science functions include ex, x, ln(x), arithmetic mean, standard deviation, linear regression, yx, 1/x and n!. I can easily calculate log(x), x2 and the Root Mean Square. Most of the functions of a basic scientific calculator are here.


Trigonometric functions

The cosine approximation cos(x) = (𝝿2-4x2)/(𝝿2+x2) adapts a function for sine(x) attributed to Bhaskara I, 1400 years ago in India. The cosine function can be programmed in fewer lines.

Using degrees, the formula for the cosine ratio is cos(θ) =(9-4(θ/60)2)/(9+(θ/60)2) - modified for degree input by Thomas Klemm.

  • Trig ratios - enter R/S at Line 02.
  • Trig ratios - GTO 00 and enter θ R/S to display Sin(θ), then X⇌Y for Cos(θ), followed by ÷ for Tan(θ). To repeat, enter new θ, R/S
  • Sin-1(x) - enter GTO 08 at Line 02.
  • Cos-1(x) - enter GTO 07 at Line 02.
  • Tan-1(x) - enter GTO 04 at Line 02.
  • Inverse trig angles - enter x, STO 4, GTO 00. Enter guess for θ, R/S. To repeat, enter new x, STO 4. Enter guess for θ, R/S.
  • For Sin-1(x) I usually use 20 degrees as a guess for θ.
  • For Cos-1(x) a guess around 70 degrees often works.

Errors

Absolute errors in the sine and cosine trig ratios are less than ±0.002. For the tangent, errors are mostly less than ±0.004, with a gradual increase above 70 degrees. The error is -0.15 at 85 degrees and -0.98 at 89 degrees, where the tangent is 56.31. Errors in the inverse trig functions are less than ±0.14 degrees.

Calculating cos(90-θ) instead of sin(θ) will improve the accuracy for small angles. Calculating sin(90-θ) instead of cos(θ) will improve the accuracy for large angles. For example, sin(30) = 0.5020 while cos(90-30) = 0.5000.

If very accurate trigonometric functions are required then this program Tried & Tricky Trigonometrics by Valentin Abillo may suit.


Inverse trig example

What is the angle from ground level to the top of a dam, 5 metres high, from the position of a laser-rangefinder set at ground level? The distance measured by the laser-rangefinder to the top is 20 metres. A new overflow water-race is being planned. The slope should not exceed 15 degrees. Height/hypotenuse is 5/20 = 0.25. Calculate sin-1(0.25).

  • Enter GTO 08 at Line 02.
  • Store 0.25 in register 4.
  • To solve for θ or sin-1(x), GTO 00.
  • Enter a guess for θ, R/S.
  • The result is an angle of 14.39 degrees using the HP-12C and 14.48 degrees using an HP-15C.
  • The difference is very small at 0.09 degrees and the results are clearly less than 15 degrees.
  • Stepping back to 30 meters distance, the angle is now 9.53 degrees.

Quartic polynomial

The Quartic polynomial starts at Line 34. a4x4 + a3x3 + a2x2 + a1x + a0 = 0. It is programmed in the form (((a4x + a3)x + a2)x + a1)x + a0 = 0. The constants a4 to a0 are entered into the financial registers n, i, PV, PMT and FV. These can be used as normal registers. Zero is stored for each missing function term. A guess for x is entered and GTO 00, R/S starts the Newton Solver.

  • At Line 03 enter GTO 34.
  • To solve x4 - 5x2 + 4 = 0, enter 1 into n, 0 into i, -5 into PV, 0 into PMT and 4 into FV.
  • Suitable guesses are -3, -1.3, 1.3 and 3.
  • GTO 00, R/S.
  • The four roots are -2. -1, 1 and 2.

Polynomials can also be solved on the HP-12C as cash-flows.


HP-12C parallel resistance

I used the standard R=1/(1/R1+1/R2) formula which takes 7 program lines and any number of entries in sequence. The first result, for R1 and R2 in parallel, is pushed onto stack level y when a third R3 entry is made. The program is then repeated, etc.

  • GTO 52 R1 ENTER R2 R/S to start, then R3 R/S if needed.
  • A 10 and a 20 ohm resistor are connected in parallel.
  • 10 ENTER 20 R/S = 6.6667 ohms.
  • Adding another 30 ohm resistor in parallel, 30 R/S = 5.4545 ohms, etc.

Entering a negative second resistance gives a resistance to add in parallel with the first resistance so that the combination equals the second resistance. For example 10 Enter 6.6667 CHS R/S CHS = 20.


Harmonic mean

  • Use the parallel resistance calculation.
  • Multiply the result by the number of entries.
  • For a harmonic mean from 1 to 6: 1 ENTER 2 R/S, 3 R/S, 4 R/S, 5 R/S, 6 R/S.
  • The result = 0.4082 and the number of entries = 6.
  • The Harmonic mean = 0.4082 X 6 = 2.4490.

The harmonic mean is used to average rates. For example a trip was 10 km at 100 km/h. A second trip was 20 km at 60 km/h, which is also two 10 km trips at 60 km/h. The average speed of 3 trips of the same distance was 3 x 1/(1/100 + 1/60 + 1/60) = 69.23 km/h.

GTO 52 100 ENTER 60 R/S to start, then 60 R/S. The harmonic mean = 23.08 x 3 km/h = 69.23 km/h.


Geometric mean

  • GTO 58, R/S, to clear the statistics registers, then x1, R/S, x2, R/S, for a geometric mean.
  • Repeat x3, R/S etc., for further entries.
  • The current geometric mean is progressively displayed when R/S is pressed.
  • For 1 to 6, the Geometric mean = 2.9938.

A geometric mean might be used for numbers which cover a wide range, or are exponentially related. Comparing the mean diameter of the earth at 12,742,000 m to the diameter of a silicon atom at 2.22-10 m generates a geometric mean = √(1.27427 x 2.22-10) = 0.0532 m = 53.2 mm. This is close to the 52.4 mm diameter of a Snooker ball.

GTO 58 R/S 1.2742 EXX 7 R/S 2.22 EEX CHS 10 R/S. The geometric mean = 53.2 mm.

My simple interpretation is that the number of silicon atoms that can pack into the volume of a 53.2 mm diameter ball is the same as the number of 53.2 mm diameter balls that can pack into a volume the size of the Earth.


Other means of 1 to 6

  • The Arithmetic mean = 3.5, using the statistics function .
  • The Root Mean Square = 3.8944 = √(∑x2÷n) or RCL 3 RCL 1 ÷ √x, using the statistics registers.

HP-12C Newton solver

One of the best function solvers is Newton’s method for solving f(x)=0. I adapted this HP-12C Newton Solver, which has a simple program structure. This version is close to the shortest version I have seen. I added rounding where the iteration finish time depends on the number of decimal digits displayed.

The program lines between 4 and 64 can be used to solve any functions of the form f(x)=0. At Line 03 enter the first program line. At the end of the function add GTO 70. In RUN mode, enter GTO 00. Enter a guess x and R/S to start. There is a PSE at Line 84 to allow progress to be monitored.


Function call summary

The HP-12c uses GTO statements in place of the missing LBL and RTN statements. Also there are only 99 programming lines. Writing long programs can be challenging.

Lines that a user might access or alter

  • Line 01 (GTO 65) Newton Solver. GTO 00, R/S to start.
  • Line 02 (GTO 08, GTO 07, GTO 04, R/S) (sin-1, cos-1, tan-1, stop) Modify returning Bhaskara I cosine function to produce sine, cosine or tangent for inverse trig solution.
  • Line 03 (GTO 11, GTO 34) Solve either Bhaskara I cosine function to produce inverse trig functions or solve Quartic polynomial.
  • Line 52 Resistance and Harmonic mean, start.
  • Line 58 Geometric mean, start.

Lines called by GTO statements.

  • Line 02 (GTO 08, GTO 07, GTO 04, R/S) (sin-1, cos-1, tan-1, stop)
  • Line 11 Bhaskara I cosine function.
  • Line 34 Quartic function.
  • Line 65 Newton Solver.
  • Line 66 Newton Solver, loop back destination.
  • Line 70 Newton Solver, function return destination.
  • Line 87 Newton Solver, internal jump destination, new f'(x).
  • Line 99 Newton Solver, display result.

Function returns.

  • Line 10 (GTO 70) Trig function end, return to solver.
  • Line 33 (GTO 02) Bhaskara I cosine function, return.
  • Line 50 (GTO 70) Quartic function end, return to solver.
  • Line 57 (GTO 51) Resistance and Harmonic mean, wait for input.
  • Line 64 (GTO 59) Geometric mean, wait for input.

Additional lines with GTO statements.

  • Line 69 (GTO 03) Newton Solver, external function call f(x).
  • Line 72 (GTO 87) Newton Solver, internal jump, new f'(x).
  • Line 86 (GTO 03) Newton Solver, external function call f(x).
  • Line 97 (GTO 99) Newton Solver, display result.
  • Line 98 (GTO 66) Newton Solver, loop back.


JEPSPECTRO logo

JEPSPECTRO - Home Page

Email: replace at with @
jepattersonatactrix.co.nz

Links

JEP Related Links

SwissMicros

HPCC: Handheld and portable computer club

Museum of HP calculators

Valentin Albillo's HP collection

Eddie's math and calculator blog

HP-12C Mass made soul

SwissMicros DM15 scientific calculator

Program pdf

Science Program 2


Click the photos below to enlarge. Use the browser "back control" to return.


HP-12C Platinum HP-12C "Platinum"

HP-12C Platinum - back HP-12C "Platinum"