Algorithm used to find Q and Q^-1 on HP32E


Does anyone have the details of the algorithm used to find Q and Q^-1 on the HP32E calculator - it is obviously iterative.

I suspect that it is performing a numerical integration, probably using a Trapezoid or Simpson approximation but I have not idea which or what limits are used. The manual simply states 'The HP-32E computes Q^-1 using a sophisticated iterative algorithm.' and does not give any further clues as to how the answer is calculated.

Thanks, (in advance).

Mike T.


The algorithms use raitonal polynomials.


The HP29C program library shows a polynomial approximation used to
calculate Q(x). The error term is < 7.5 * 10^-8. The inverted function Q^-1(x) may also be approximated by a polynomial, but the error term is worse (< 4.5 * 10^-4). So it is a good guess the HP32E uses the same (or a similar) poly approximation for Q(x) and for the inverse function Q^-1(x) uses some iterative search (like interval splitting) on the more precise Q(x) approximation to find x.

Algorithm from the manual:

f(x) = exp(-x^2/2) / SQRT(2 * PI);

R(x) = f(x)* (b1*t + b2*t^2 + b3*t^3 + b4*t^4 + b5*t^5) + err(x);

where |err(x)| < 7.5e-8

t = 1 / (1 + r * abs(x));

r = 0.2316419

b1 = 0.319381530

b2 = -0.356563782

b3 = 1.781477937

b4 = -1.821255978

b5 = 1.330274429

Q(x) = [R if (x >= 0)] or [1-R if (x < 0)]

If you want to find out the truth, I'd suggest you try the above math and whether it produces the same results as the 32E does.
No warranties implied - maybe you find a typo (I didn't check it).

According to the manual, the primary source is Abramowitz and Stegun, Handbook of Mathematical Functions, National Bureau of Standards, 1970.

If the above algorithm works like the HP32E, please post a reply..
for a long time (~20years) I wanted to know what makes the HP32E Q^-1 lightshow... which is really cool, for a non-programmable calc.

best regards,


Thank you - I'll try this out some time.

I don't suppose you have an HP29C you can try the published program out on...? A 'quick' check of the results produced on an HP29C against the HP32E would give an indication as to the similarity of the algorithms used. Alternatively I could try implementing this on a HP34C...

Mike T.


Good reason to buy the museum disks and look at the vntage calculator manuals and solution pacs. These guides contain the math equations that show the approximations used to calclate various probability distribution functions and their inverse.

You can also find these equations (for Normal, Student-T, Chi, and F) in my book:

"Mathematical Algorithms in Visual Basic for Scietists and Engineers" by Namir C Shammas This book was published in 1996 by McGraw-Hill.



Some book that must be - the LOWEST price I can find on Amazon is over $1500.00 !! Think I'll have to pass on that..


Hi, Namir:

Is this the book you're referring to ?

Mathematical Algorithms in Visual Basic for Scientists & Engineers

because the price is absolutely outrageous (more than $3 per page ... what was the 'new' price, then ?) and the reviews seem a little on the negative side, don't they ? Any explanation ? Lots of typographical errors at the printer's or something beyond your control ?

Best regards from V.


for sure, the 32e doesnt use the Abramowitz and Stegun "Hastings" approximation. at least not the standard one, although i understand there are other hasting approxes. the polynomial you mention is the one use by most programmable libraries include those of casio.

however, it is not 10 digit accurate, but the 32e is. also for inversion (ie inv Q). my guess is that it is, in fact, an iteration, as this would be less storage than the bigger polynomials needed for 10 digit accuracy. Q, erf and gamma are all related and normally require two iterative algorithms, one that converges over 0-1 and the other for x>1.

a while back, i ran some tests on this, here,

in other news....

the lygea 12c emulator has added N(z) and z. which are exactly Q and inv Q. this is a huge plus for black-scholes on the 12 and why hp couldnt have done this for the 12cp, who knows. AFAIK, the lygea 12c is a true emulator and not a simulator, which means they've suceeded in adding functions to the original code (or bolted them on somehow). so this proves its possible to revise functionality.

it alsp appears to be 10 digit accurate.


Well, Gentlemen, I did mention in my post it was only a good guess on how the HP32E might do the calculation, did I ?

To really find out the truth, it might be worthwile to try annotate the disassembled microcode listing of the HP32E microcode.

I think this should be done with all HP calc microcode once Eric's Nonpareil is perfected to a point where there are no ambiguities left as how to the ACT chip works (= all calcs simulated perfectly).

Any volunteers ?



I think I found the right page(s) here Abramowitz and Stegun, Handbook of Mathematical Functions, National Bureau of Standards, 1970

Mike T.

Possibly Related Threads...
Thread Author Replies Views Last Post
  Prime cant find Memory available Dougggg 5 689 10-07-2013, 07:24 PM
Last Post: Han
  HP Prime can't find how to use partfrac function ! dg1969 3 544 10-04-2013, 09:25 PM
Last Post: Joe Horn
  OT - A lucky find - Busicom Handy-LE LE-120A Cristian Arezzini 2 530 09-26-2013, 04:43 AM
Last Post: Cristian Arezzini
  Question about a "combinations" algorithm Namir 9 799 09-20-2012, 04:51 PM
Last Post: Gilles Carpentier
  Linear Programming - Simplex Algorithm LarryLion 5 574 09-04-2012, 10:57 PM
Last Post: David Hayden
  Craigslist find and fix - HP 19C Matt Fegenbush 12 1,045 08-13-2012, 02:57 PM
Last Post: Matt Fegenbush
  Where to find the HP 39GII in London Miguel Toro 10 830 08-01-2012, 01:23 AM
Last Post: Thomas Radtke
  35s - find roots of 3rd and higher order equations Chris C 11 988 02-25-2012, 02:55 PM
Last Post: Thomas Klemm
  Algorithm for fitting a logistic curve? Tim Wessman 5 539 11-13-2011, 01:22 AM
Last Post: Wes Loewer
  Interesting find: HP 9875A dual cassette drive David Ramsey 16 1,238 11-03-2011, 06:59 PM
Last Post: Eric Smith

Forum Jump: