Re: New Trigonometric Functions Program for the New 12C Platinum Message #3 Posted by Gerson W. Barbosa on 11 Nov 2005, 11:21 a.m., in response to message #2 by tony
Hi Tony,
Thanks for the good news! When I was adjusting the MiniMax coefficients for the arctangent
function (the lowest power coefficients don't require so many significant figures), I considered
1/3 as 0.333333333333 (that's the constant in line 239) in my test spreadsheet. I correctly
guessed the 12C Platinum might have some extra guarding digits. By the way, that constant
should be 0.333333333089303 or 0.3333333331 to ten places but I wouldn't write it this way
just because of a '1' in the leftmost position. So I used 1/3 to 12 places and adjusted the
other constants with help of a spreadsheet and a graphics.
Using the constants explicitly in the program have significantly slowed down the execution time
as more steps have to be run. The constants could have been stores in registers, but then an
initialization routine would have been needed to avoid having to enter them by hand. Anyway, I
haven't calculated whether there would have been free registers left since the program uses
five registers already. In short, the gain in speed obtained by using only three coefficients
in the sine aproximation and only four in the arctangent approximating is lost when the constants
are built into the program. But the easy of use may compensate for this. Notice that the constants
beginning in lines 54 and 247 are pi/540 and 180/pi, respectively.
Reading again my post, I realized the example I provided was out of context. What I meant is that,
calculations like the following are easily done, since the latest computation is saved on the stack:
((sin(60) + tan(30)) * 6/5) ^ 2 :
60 R/S 30 GTO 100 R/S + 6 * 5 / g x^2 => 3.000000001
Thanks again for your remarks.
Cheers,
Gerson.
Correction:
Checking again my test spreadsheet, I discovered I had approximated 1/3 to only 10 significant figures, although I had previously thought of using 12 digits. As a consequence, the '2' in line 236 should be a '3'. Anyway, '2' implies in a maximum absolute error of 5.15E-12 for arguments between 0 and 1, while '3' brings the maximum error down to 4.10E-12.
-------------------------------------------------------------
In the tables below, the HP-15C column shows results obtained
with the built-in HP-15 functions, all of them correct to 10
significant figures, whereas the 12C Platinum shows results
obtained with the equivalent program run on the HP-15C. According
to Tony observations, the results on the real Platinum should
vary slightly, hopefully for better. The HP-35 shows the results
obtained on a bugless HP-35 (version 3). Like the program, its
only angular mode was Degrees.
Sin(x):
x (deg) HP-15C 12C Platinum HP-35
---------------------------------------------------------------
0.00000 0.0000000000 0.0000000000 0.0000000000
0.00001 1.745329252E-07 1.745329252E-07 1.745000000E-07
0.00011 1.919862177E-06 1.919862177E-06 1.919800000E-06
0.02200 3.839724260E-04 3.839724261E-04 3.839723910E-04
3.330000 5.808674960E-02 5.808674960E-02 5.808674960E-02
14.44000 0.2493660251 0.2493660251 0.2493660250
25.55000 0.4312985870 0.4312985869 0.4312985871
36.66000 0.5970652564 0.5970652561 0.5970652561
47.77000 0.7404527827 0.7404527825 0.7404527828
58.88000 0.8560867283 0.8560867282 0.8560867285
69.99000 0.9396329127 0.9396329129 0.9396329127
81.11000 0.9879868528 0.9879868528 0.9879868527
88.88000 0.9998089500 0.9998089502 0.9998089499
89.99000 0.9999999848 0.9999999850 0.9999999848
89.99990 1.0000000000 0.9999999998 1.0000000000
90.00000 1.0000000000 1.0000000000 1.0000000000
Tan(x):
x (deg) HP-15C 12C Platinum HP-35
---------------------------------------------------------------
0.00000 0.0000000000 0.0000000000 0.0000000000
0.00001 1.745329252E-07 1.745329252E-07 1.745000000E-07
0.00011 1.919862177E-06 1.919862177E-06 1.919800000E-06
0.02200 3.839724543E-04 3.839724543E-04 3.839724542E-04
3.330000 5.818499267E-02 5.818499266E-02 5.818499260E-02
14.44000 0.2575006491 0.2575006491 0.2575006490
25.55000 0.4780471798 0.4780471797 0.4780471798
36.66000 0.7442915883 0.7442915881 0.7442915880
47.77000 1.101686578 1.101686577 1.101686578
58.88000 1.656411391 1.656411390 1.656411391
69.99000 2.745986117 2.745986118 2.745986119
81.11000 6.393166451 6.393166452 6.393166426
88.88000 51.15042993 51.15042993 51.15042860
89.99000 5729.577893 5729.577895 5729.569869
89.99990 572957.7951 572957.7950 573019.3057
90.00000 9.999999999E+99 Error 0 9.999999999E+99
ArcTan(x):
x HP-15C 12C Platinum HP-35
---------------------------------------------------------------
0.00000 0.0000000000 0.0000000000 0.0000000000
0.00011 6.302535721E-03 6.302535723E-03 6.302535688E-03
0.15500 8.810732986 8.810732984 8.810732984
0.26795 15.00004318 15.00004318 15.00004317
0.41421 22.49982578 22.49982579 22.49982579
0.57735 29.99998843 29.99998844 29.99998843
0.77700 37.84720677 37.84720678 37.84720676
0.88800 41.60507646 41.60507648 41.60507646
1.00000 45.00000000 45.00000000 45.00000000
1.22200 50.70548702 50.70548700 50.70548702
1.48880 56.11145723 56.11145722 56.11145722
2.11100 64.65265735 64.65265734 64.65265735
4.88800 78.43782359 78.43782359 78.43782360
7.55500 82.46000683 82.46000683 82.46000679
99.9990 89.42705557 89.42705557 89.42705555
3333333 89.99998281 89.99998281 89.99998281
Edited: 12 Nov 2005, 3:12 p.m.
|