Post Reply 
Easter Sunday Trigs ( rpn38-CX)
04-10-2016, 07:16 PM (This post was last modified: 04-10-2016 09:25 PM by Gerson W. Barbosa.)
Post: #29
RE: Easter Sunday Trigs ( rpn38-CX)
(04-08-2016 10:42 PM)bshoring Wrote:  It is interesting that we can use the Net Present Value on a financial calculator to compute sine, up to a point, but as you say, the closer one gets to 90 degrees, the less accurate that method is.

These issues are due mostly to cancellation errors. Notice the polynomial cannot be evaluate for zero when using the NPV method, unless this is properly handled. It appears NVP is not as accurate on the HP-12C Platinum as it is on the HP-12C for certain values, judging by a few results which are better on the latter when it should be otherwise.

(04-08-2016 10:42 PM)bshoring Wrote:  I'd say that the best program is the one you posted on 3 April, 2016. It appears to give the best overall accuracy for the 6 main trig functions. This exercise has been quite an enlightenment for me.

That's the one I like best too. However doing calculations with three or four extra digits doesn't prevent cancellation errors from popping up in those critical regions.

(04-08-2016 10:42 PM)bshoring Wrote:  Thanks!

My pleasure! You might also want to take a look at this this HP-17BII equation, in case you haven't seen it yet.

The following program is meant for the REAL HP-38C, but it has been tested only on the HP-12C and the HP-12 Prestige.

Regards,

Gerson.

.
Trigonometric Functions - REAL HP-38C

Code:

01 - 3            3
02 - 21 11        STO n
03 - 71           ÷
04 - 21 14        STO PMT
05 - 25 6         x=0
06 - 25 7 13      GTO 13
07 - 31           ENTER
08 - 61           ×
09 - 1            1
10 - 24 23        ∆%
11 - 21 12        STO i
12 - 24 13        NPV
13 - 22 14        RCL PMT
14 - 61           ×
15 - 31           ENTER
16 - 31           ENTER
17 - 61           ×
18 - 4            4
19 - 61           ×
20 - 32           CHS
21 - 3            3
22 - 51           +
23 - 61           ×
24 - 31           ENTER
25 - 31           ENTER
26 - 61           ×
27 - 32           CHS
28 - 1            1
29 - 51           +
30 - 24 21        √x
31 - 25 7 00      GTO 00
32 - 31           ENTER
33 - 61           ×
34 - 32           CHS
35 - 1            1
36 - 51           +
37 - 25 7 40      GTO 40
38 - 31           ENTER
39 - 61           ×
40 - 24 71        1/x
41 - 1            1
42 - 41           −
43 - 24 21        √x
44 - 25 6         x=0
45 - 25 7 00      GTO 00
46 - 1            1
47 - 33           x≷y
48 - 25 5         x≤y
49 - 25 7 52      GTO 52
50 - 24 71        1/x
51 - 9            9
52 - 0            0
53 - 21 13        STO PV
54 - 25 33        R↓
55 - 24 71        1/x
56 - 21 14        STO PMT
57 - 31           ENTER
58 - 61           ×
59 - 51           +
60 - 24 21        √x
61 - 22 14        RCL PMT
62 - 41           −
63 - 21 14        STO PMT
64 - 31           ENTER
65 - 61           ×
66 - 31           ENTER
67 - 31           ENTER
68 - 31           ENTER
69 - 22 6         RCL 6
70 - 61           ×
71 - 73           .
72 - 1            1
73 - 0            0
74 - 6            6
75 - 51           +
76 - 61           ×
77 - 22 5         RCL 5
78 - 41           −
79 - 61           ×
80 - 22 4         RCL 4
81 - 51           +
82 - 61           ×
83 - 3            3
84 - 24 71        1/x
85 - 41           −
86 - 61           ×
87 - 1            1
88 - 51           +
89 - 22 14        RCL PMT
90 - 61           ×
91 - 2            2
92 - 61           ×
93 - 22 0         RCL 0
94 - 71           ÷
95 - 22 13        RCL PV
96 - 25 6         x=0
97 - 33           x≷y
98 - 33           x≷y
99 - 41           −

Constants:

R0:  1.745329252e-02
R1: -8.86096144e-07
R2:  1.3495798e-11
R3: -9.7284-17
R4:  0.199989464
R5:  0.14247163
R6: -0.0606366

Angles in DEGREES

-90 =< x =< 90

R/S     --> cos(x)
R/S x≷y --> sin(x)
R/S ÷   --> tan(x)

GTO 32 R/S --> asin(x)      0 =< x <  1
GTO 38 R/S --> acos(x)      0  < x <= 1
GTO 44 R/S --> atan(x)   1e-50 < x < 1e50, x=0

RCL 0 ÷  --> Rad->Deg
RCL 0 ×  --> Deg->Rad
------------------------------------------

Constants:

R0: 1.745329252e-02
R1: -8.86096144e-07
R2: 1.3495798e-11
R3: -9.7284-17
R4: 0.199989464
R5: 0.14247163
R6: -0.0606366


------------------------------------------

Trigonometric Functions:

Angles in DEGREES

-90 =< x =< 90

R/S --> cos(x)
R/S x≷y --> sin(x)
R/S ÷ --> tan(x)

GTO 32 R/S --> asin(x) 0 =< x < 1
GTO 38 R/S --> acos(x) 0 < x <= 1
GTO 44 R/S --> atan(x) 1e-50 < x < 1e50, x=0

RCL 0 ÷ --> Rad->Deg
RCL 0 × --> Deg->Rad

------------------------------------------
Examples:

0.0001 R/S --> 1.000000000 ; cos(0.0001) ; [result on the HP-12C Prestige: 1.000000000] {HP-15C built-in function result: 1.000000000}
x≷y --> 1.745329252E-06 ; sin(0.0001) ; [1.745329252E-06] {1.745329252E-06}
x≷y ÷ --> 1.745329252E-06 ; tan(0.0001) ; [1.745329252E-06] {1.745329252E-06}

0.9999 GTO 32 R/S --> 89.18970909 ; asin(0.9999) ; [89.18970856] {89.18970856}
0.9999 GTO 38 R/S --> 0.8102914371 ; acos(0.9999) ; [0.8102914375] {0.8102914371}
0.9999 GTO 44 R/S --> 44.99713507 ; atan(0.9999) ; [44.99713506] {44.99713507}

180 RCL 0 × --> 3.141592654 ; 180° = π rad
3.141592654 ENTER 8 / RCL 0 ÷ --> 22.50000001 ; π/8 rad = 22.5°

Other examples:

sin(0) = 0.000000000 [0.000000000] {0.000000000}
cos(0) = 1.000000000 [1.000000000] {1.000000000}
tan(0) = 0.000000000 [0.000000000] {0.000000000}

sin(1) = 1.745240644E-02 [1.745240644E-02] {1.745240644E-02}
cos(1) = 0.9998476952 [0.9998476952] {0.9998476952}
tan(1) = 1.745506493E-02 [1.745506493E-02] {1.745506493E-02}

sin(15) = 0.2588190451 [0.2588190451] {0.2588190451}
cos(15) = 0.9659258263 [0.9659258263] {0.9659258263}
tan(15) = 0.2679491924 [0.2679491925] {0.2679491924}

sin(0.01) = 1.745329243E-04 [1.745329243E-04] {1.745329243E-04}
cos(0.01) = 0.9999999847 [0.9999999848] {0.9999999848}
tan(0.01) = 1.745329270E-04 [1.745329270E-04] {1.745329270E-04}

sin(30) = 0.5000000002 [0.5000000000] {0.5000000000}
cos(30) = 0.8660254037 [0.8660254038] {0.8660254038}
tan(30) = 0.5773502695 [0.5773502693] {0.5773502692}

sin(60) = 0.8660254034 [0.8660254038] {0.8660254038}
cos(60) = 0.5000000001 [0.5000000000] {0.5000000000}
tan(60) = 1.732050804 [1.732050808] {1.732050808}

sin(75) = 0.9659258263 [0.9659258265] {0.9659258263}
cos(75) = 0.2588190451 [0.2588190445] {0.2588190451}
tan(75) = 3.732050808 [3.732050808] {3.732050808}

sin(89) = 0.9998476951 [0.9998476952] {0.9998476952}
cos(89) = 1.745240958E-2 [1.745240611E-2] {1.745240644E-2}
tan(89) = 57.28995131 [57.28996271] {57.28996163}

sin(89.99) = 0.9999999850 [0.9999999848] {0.9999999848}
cos(89.99) = 1.732050808E-4 [1.745508522E-4] {1.745329243E-4}
tan(89.99) = 5773.502604 [5728.989416] {5729.577893}

sin(89.9999) = 1.000000000 [1.000000000] {1.000000000}
cos(89.9999) = 0.000000000 [2.449489743E-6] {1.745329252E-6}
tan(89.9999) = Error 0 [408248.2905] {572957.7951}

asin(0) = 0.000000000 [0.000000000] {0.000000000}
acos(0) = Error 0 [Error 0] {90.00000000}
atan(0) = 0.000000000 [0.000000000] {0.000000000}

asin(1) = Error 0 [Error 0] {90.00000000}
acos(1) = 0.000000000 [0.000000000] {0.000000000}
atan(1) = 45.99999997 [45.99999999] {45.00000000}

asin(1e10) = 90.00000000 [90.00000000] {89.99999999}

atan(0.4142135624) = 22.49999990 [22.49999994] {22.50000000}

acos(0.8660254038) = 29.99999997 [30.00000001] {30.00000000}

atan(50) = 88.85423719 [88.85423716] {88.85423716}

------------------------------------------

Forensic result:

9 R/S x≷y R/S R/S ÷ GTO 44 R/S GTO 38 R/S GTO 32 R/S --> 9.707005398 [9.008774143] {9.000417403}

------------------------------------------

P.S.: W|A plots for accuracy checking of the polynomials used in this program:

Plot sin(x)-(x-0.1666666645x^3+0.008333198583x^5-0.0001971967922x^7),x=0..pi/6

Plot atan(x)-(x-0.3333333333x^3+0.199989464x^5-0.14247163x^7+0.106x^9-0.0606366x^11),x=0..sqrt(2)-1

P.P.S.: FV in lines 53 and 95 has been replaced with PV. The former is the only register left for the user.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Easter Sunday Trigs ( rpn38-CX) - Gerson W. Barbosa - 04-10-2016 07:16 PM



User(s) browsing this thread: 1 Guest(s)