Saturday, November 2, 2019

HP 12C: Error Function Approximation

HP 12C: Error Function Approximation

Introduction

The program for the HP 12C calculator approximates the error function defined as

erf(x) = 2 / √π * ∫ e^-(t^2) dt from t = 0 to t = x

by using the series

erf(x) = (2*x) / √π * Σ( (-x^2)^n / (n!*(2*n+1)), n = 0 to ∞)

In the approximation, up to 69 terms are calculated for the sum (the loop stops when n = 69). 

Since there is no π constant on the HP 12C, the approximation 355/113 for π is used.

HP 12C Program Error Function

Step;   Key Code;  Key
01;  44,1;  STO 1
02;  35;   CLx
03;  44, 2;  STO 2
04;  44, 3;  STO 3
05;  45, 1;  RCL 1   
06;  2;   2
07;  21;  y^x
08;  16;  CHS
09;  45, 2;  RCL 2
10;  21;  y^x
11;  45, 2;  RCL 2
12;  43, 3;  n!
13;  45, 2;  RCL 2
14;  2;   2
15;  20;  *
16;  1;  1
17;  40;  +
18;  20;  *
19;  10;  ÷
20;  44,40,3;  STO+ 3
21;  43, 35;  x=0
22;  43,33,31;  GTO 31
23;  1;  1
24;  44,40,2;  STO+ 2
25;  45, 2;  RCL 2
26;  6;   6
27;  9;   9
28;  43,34;  x≤y
29;  43,33,31; GTO 31
30;  43,33,05; GTO 05
31;  45,3;  RCL 3
32;  45,1;  RCL 1
33;  20;  *
34;  2;  2
35;  20;  *
36;  3;  3
37;  5;  5
38;  5;  5
39;  36;  ENTER
40;  1;  1 
41;  1;  1
42;  3;  3
43;  10;  ÷
44;  43,21;  √
45;  10;  ÷
46;  43,33,00;  STO 00

Examples

(FIX 5)

erf(0.5) ≈ 0.52050

erf(1.6) ≈ 0.97635

erf(2.3) ≈ 0.99886

Source

Ball, John A.  Algorithms for PRN Calculators  John Wiley & Sons: New York  1978  ISBN (10) 0-471-0370-8

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Texas Instruments: TI-36X Pro and TI-30X Pro Mathprint

 Essentially, the Texas Instruments TI-36X Pro and the TI-30X MathPrint are functionally equivalent.  What makes the two calculators differe...