Trigonometric Functions (HP-17BII) Message #1 Posted by Gerson W. Barbosa on 7 Apr 2013, 7:37 p.m.
Here is a new set of trigonometric functions equations for the HP-17BII. These are based upon approximations for both sine and cosine involving a few Taylor series terms and the correspondent hyperbolic functions, as discussed here last week.
SIN=(1-2*IP((MOD(X:360)/180)))*(2*SIGMA(K:1:21:4:(L(A:MOD(X:180)*PI/180))^K/FACT(K))-(EXP(G(A))-EXP(-G(A)))/2)
COS=(1-2*IP((MOD(X+90:360)/180)))*(2*SIGMA(K:1:21:4:(L(A:MOD(X+90:180)*PI/180))^K/FACT(K))-(EXP(G(A))-EXP(-G(A)))/2)
TAN=(4*SIGMA(K:1:21:4:(L(A:MOD(X:180)*PI/180))^K/FACT(K))-EXP(G(A))+EXP(-G(A)))/
(4*SIGMA(K:0:20:4:(L(A:MOD(X:180)*PI/180))^K/FACT(K))-EXP(G(A))-EXP(-G(A)))
The equations are short enough to be quickly keyed into the calculator without mistakes. Arguments in degrees up to +/- 999 999 999 999 are accepted for SIN and TAN (The range is slightly shorter for COS because it is computed as SIN shifted 90 degrees). The maximum absolute error for SIN should be in theory 3.5*10-13 (2*pi^25/25! -- that is close to what is obtained on the HP-200LX solver as can be seen in the third plot), but in practice the HP-17BII, a 12-digit calculator (four less than the HP-200LX solver), can deliver results accurate to 10 or 11 results only. When working next to its accuracy level, the HP-200LX loses about two digits of accuracy (second plot).
The running times are very good: about 1.1 second for SIN and COS and 2.2 seconds for TAN. Of course the inverse functions can also be calculated, but this will take longer and will depend on the initial guess.
Plots of SIN, COS and TAN on the HP-200LX:
The second plot shows the difference of the SIN equation in relation to the built-in SIN function (in degrees mode), when seven terms of the Taylor series are used (...SIGMA(K:1:25:4:...).
For arguments and results in radians, the conversion factor pi/180 should be used. Alternatively, the following set of equations (arguments and results in radians, but input range limited to [-pi..pi]) can be used:
SIN=2*SIGMA(K:1:21:4:X^K/FACT(K))-(EXP(X)-EXP(-X))/2 COS=2*SIGMA(K:0:20:4:X^K/FACT(K))-(EXP(X)+EXP(-X))/2 TAN=(4*SIGMA(K:1:21:4:X^K/FACT(K))-EXP(X)+EXP(-X))/(4*SIGMA(K:0:20:4:X^K/FACT(K))-EXP(X)-EXP(-X))
This latter set should work on all HP-17BII versions. I don't have any HP-17BII+ handy to test the first set of equations. Perhaps a few changes have to me made, because of issues with L() and G() on the newest models.
|