Saturday, March 20, 2021

Testing The Accuracy of LN and EXP Approximations

Testing The Accuracy of LN and EXP Approximations


Introduction


Today we are testing an approximation polynomial for two common scientific functions.  I used a TI-84 Plus CE in testing.   The values take a range from x = 0.5 to x = 11.  


Approximating e^x


Approximation used:


e^x ≈ 1 + x * (1 + x/2 * (1 + x/3 * (1 + x/4 * (1 + x/5 * (1 + x/6)))))

(fractions are simplified, see source)


TI-84 Plus CE Program:  EXPTEST


"EWS 2021-01-19"

Disp "e^(X) TEST","JON M. SMITH"

Disp "RANGE, MIN. 0.5"

Input "START? ",A

Input "INCREMENT? ",I

Input "NO STEPS? ",N

seq(X,X,A,A+I*N,I)→L₁

e^(L₁)→L₂

1+L₁*(1+L₁/2*(1+L₁/3*(1+L₁/4*(1+L₁/5*(1+L₁/6)))))→L₃

abs(L₂-L₃)→L₄

iPart(log(L₄))→L₅

Disp "L₁:X, L₂:EXP, L₃:APPROX","L₄:ABS ERROR","L₅:PLACES"

SetUpEditor L₁,L₂,L₃,L₄,L₅

Disp "PRESS STAT, 1. EDIT"


Test: x range:  0.5 to 11, increments of 0.5




Approximating ln x


Approximation used:


ln x ≈ y * (1 + y/2 * (1 + 2y/3 * (1 + 3y/4 * (1 + 4y/5))))

where x ≥ 0.5

and y = (x - 1)/x

(see source)



TI-84 Plus CE Program:  LNTEST


"EWS 2021-01-19"

Disp "ln(X) TEST","JON M. SMITH"

Disp "RANGE, MIN. 0.5"

Input "START? ",A

Input "INCREMENT? ",I

Input "NO STEPS? ",N

seq(X,X,A,A+I*N,I)→L₁

ln(L₁)→L₂

(L₁-1)/L₁→L₆

L₆*(1+L₆/2*(1+2*L₆/3*(1+3*L₆/4*(1+4*L₆/5))))→L₃

abs(L₂-L₃)→L₄

Disp "L₁:X, L₂:LN, L₃:APPROX","L₄:ABS ERROR"

SetUpEditor L₁,L₂,L₃,L₄

Disp "PRESS STAT, 1. EDIT"


Test: x range:  0.5 to 11, increments of 0.5



Final Thoughts


The approximation for ln x hold much better than e^x as x increases.   I would not recommend the following approximations for values above 5.  


Source:


Smith, Jon M.  Scientific Analysis on the Pocket Calculator John Wiley & Sons: New York. 1975


Eddie


All original content copyright, © 2011-2021.  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.