(12C) Error Function Approximation - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (12C) Error Function Approximation (/thread-13749.html) |
(12C) Error Function Approximation - Eddie W. Shore - 10-02-2019 03:21 AM 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. Program: Code: Step; Key Code; Key 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 RE: (12C) Error Function Approximation - Albert Chan - 10-05-2019 12:26 PM From Abramowitz & Stegun, 7.1.22, erf and cdf are related. cdf(z) = (1 + erf(z/√(2)) / 2 erf(z) = 2 cdf(√(2) z) - 1 = 1 - 2 cdf(-√(2) z) Confirm with Casio FX-115ES, R(z) = cdf(-z) erf(0.5) = 1 - 2 R(√(2) * 0.5) = 0.5205 erf(1.6) = 1 - 2 R(√(2) * 1.6) = 0.976348 erf(2.3) = 1 - 2 R(√(2) * 2.3) = 0.9988567 Casio's Q(z) (pdf area 0.5 to z) is simpler, but not as accurate. 2 Q(√(2) * 0.5) = 0.5205 2 Q(√(2) * 1.6) = 0.97634 2 Q(√(2) * 2.3) = 0.99886 |