New Trigonometric Functions Program for the New 12C PlatinumMessage #1 Posted by Gerson W. Barbosa on 8 Nov 2005, 9:18 p.m.

Here is a new trigonometric functions program for the new 12C Platinum. Are there another
designed specifically for this calculator? This is based on MiniMax Polynomial Approximation
(Thanks to Valentin Albillo who's shed some light on the subject) and drastic range
reductions ([0..pi/12] for arctangent function). The program is focused on accuracy and easy
of use. Arguments are entered in degrees and there is an entry-point for each function.
There are neither constants to be previously stored nor initialization routines. Placing the
constants directly into the program rather than recalling them from registers slows down
program execution but considering the new 12C Platinum is faster, this should not be a
problem. Actually this program has not been tested on the new 12C Platinum. Instead, it has
been tested with a very close version suitable for the 15C. Hopefully, I have made no
mistakes in adapting it to the Platinum. I just hope the new Platinum is at least five times
faster than the golden 12C so no function takes longer than two to three seconds to run.
Cos(x) is calculated as Sin(90-x) for the sake of accuracy. As the program is more than 255
lines long it will not work on the old Platinum unless some modifications are made (such as
replacing the last two or three constants in the program for registers recalls).

The accuracy is comparable with that of the HP-35. Cos(x) is calculated as Sin(90-x) for the
sake of accuracy. The program gives at least nine significant figures, many times matching
the 15C results. Also, the stack register X is always saved. So, the following expression

Re: New Trigonometric Functions Program for the New 12C PlatinumMessage #2 Posted by tony on 11 Nov 2005, 1:13 a.m.,in response to message #1 by Gerson W. Barbosa

Hi Gerson, yes it looks like it will indeed run on the new 12c pt. The new one is not 5 times faster than the golden one ;-) But its accuracy may surprise you as it seems to have 12 sig. digits under the hood. 3 [1/x] shows 0.333333333 but then if we remove 6 of the 3s with .333333 [-] and multiply by E6 we see 0.333333000 - another 6 3s.
Cheers,
Tony

Re: New Trigonometric Functions Program for the New 12C PlatinumMessage #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.