Trigonometric/transcendental function accuracy
Re: Trigonometric/transcendental function accuracy
Excellent - thanks! (I'm OK with some inaccuracy on enormous arguments - it's all a question of how enormous they need to be. But pi itself didn't seem enormous to me!)
Re: Trigonometric/transcendental function accuracy
Perhaps BidEd’s original question arises because this is a case of the code and the documentation disagreeing? From page B-4 of the WP43 Reference Manual, in the discussion of range reduction:Jaymos wrote: ↑Wed Jun 07, 2023 6:45 pmAlthough Pauli did not mention fixing it in his post above, he undertook to increase the accuracy by increasing the internal digits and of the pi stored value for (1) argument reduction and (2) operations from 51 to 75 digits. The good news is, it is now accurate, do see below. The bad news, it will be slower, do see when we release the next version. Of course it has to, if it has to deal with more digits. And further bad news is that rounding will ALWAYS be there at some point unless you use infinite digits (good luck!). So the same thing will happen next time someone needs to calculate sin(𝝿 * × 10^20); of course you will run out of accuracy with the reduction and when you do, ask yourself: "why?" - at some point you have to say enough is enough.
Thank you to all of you that spend so much time on these calculators!WP43 uses 1065 digits for 2π to warrant 34 digits accuracy of respective function results within ±10^999.
Cheers,
Scott
Re: Trigonometric/transcendental function accuracy
The underlying problem is known as radian. Each and every angular unit can be reduced properly modulo 360° (or equivalent) except those f...g radians. Only for them the 1065 digits of pi are required. AFAICS radians are necessary (?) for Taylor. Hence the attempt on pp. B-3f to get rid of them using multiples of pi for the Taylor series. A nice challenge for a proper mathematician IMO. Any takers?
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
Re: Trigonometric/transcendental function accuracy
It's not the modulo reduction that's the issue here -- that's good out to a thousand digits or so I think. sin(𝝿 * 10²⁰) won't lose accuracy.
It was the subsequent octant reduction to get a small angle to improve accuracy in certain cases and also to speed convergence that was at fault.
It was the subsequent octant reduction to get a small angle to improve accuracy in certain cases and also to speed convergence that was at fault.
Re: Trigonometric/transcendental function accuracy
This was posted on HackerNews last week, and I found this a similarly fascinating article:
https://austinhenley.com/blog/cosine.html
https://austinhenley.com/blog/cosine.html
SN:09075
- Steve Simpkin
- Posts: 66
- Joined: Thu May 25, 2023 1:35 am
- Location: Los Angeles, California
- Contact:
Re: Trigonometric/transcendental function accuracy
That is a cool article. It reminds me of the BASIC subroutines shown in the Level 1 BASIC User's Manual for the TRS-80 computer in 1977. The Level 1 BASIC in this computer was missing a lot of math functions and these subroutines were provided in the manual for calculating functions such the square root, log and transcendental functions. Here is the routine for calculating the SINE function.dm319 wrote: ↑Fri Jun 09, 2023 1:28 pmThis was posted on HackerNews last week, and I found this a similarly fascinating article:
https://austinhenley.com/blog/cosine.html
Re: Trigonometric/transcendental function accuracy
Taylor series are inefficient to approximate functions over an interval. The best method is to use a minimax approximation.dm319 wrote: ↑Fri Jun 09, 2023 1:28 pmThis was posted on HackerNews last week, and I found this a similarly fascinating article:
https://austinhenley.com/blog/cosine.html
Here is a simple introduction:
https://www.youtube.com/watch?v=j29rVHCpRUY
One can also combine a lookup table, and a minimax approximation (instead of interpolation) over the subintervals.
An excellent book on these subjects is "Elementary Functions - Algorithms and Implementation" from Jean-Michel Muller.
Try Google with this title.
Re: Trigonometric/transcendental function accuracy
Rational approximations seem to be commoner in my experience than polynomial ones.
Re: Trigonometric/transcendental function accuracy
I won't object to rational approximations avoiding radians a suitable way.
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
Re: Trigonometric/transcendental function accuracy
Radians are the natural unit of angle. Your dislike for them is completely irrelevant.