Re: HP-12C Platinum Trigs Program Message #10 Posted by Les Wright on 7 Aug 2006, 2:11 p.m., in response to message #1 by Gerson W. Barbosa
This is really impressive. I have been germinating an interest in polynomial and rational approximation. I recently successfully ported the Numerical Recipes rational approximation routine in section 5.13 of the book to Maple. Couldn't get the code to work in C, but the Maple version works beautifully, and if anyone here uses Maple I would love to share it. That routine, for folks who know the work, purports to be at best a "sloppy" approximation that uses an iterative weighted leastsquares approach to roughly approach a minimax fit without going thru the the Remez rigamarole. I find the approach works very well with the trigonometric functions, and if it doesn't give a true minimax fit it comes close in these cases. Indeed I was able to generate coefficients pretty close to yours for the sine fit. Your range reduction is inspired, and indeed it helps you achieve such high accuracy with a relatively small polynomial. I am also impressed with how you experimented with the coeffiecients, truncating them to strike a balance between lower memory usage and acceptable precision.
In my experimenting I came across an example that should warm the cockles of your heart. (What is a cockle anyway?)
Try your routine to compute sin(32.888 deg). The displayed answer is 0.542998588, and when you multiply by 1000 and take the fractional part you see the full twelve digit result is 0.542998588466. This is what I see on my HP48G, HP49G+, and HP42S.
In Maple, sin(32.888*Pi/180) gives, to 25 digits, .542998588465592253694888.
But on my 15C, 41CV, and 41CX, I get 0.542998589, though when multiplying thru by 10 to see the tenth digit it is indeed a 5, the effect of the 6 rounding up the 4. When it is off the display that five rounds up the 8 to 9. But the 12Cp displays what we know to be the more correct 9 digit answer, given what we know the next three digits to be. I think that is pretty impressive.
Thanks for sharing this excellent work with us.
Les
|