Sujet : Re: Radians Or Degrees?
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 17. Mar 2024, 11:59:46
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <ut6if0$3fvei$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Mozilla Thunderbird
On 17/03/2024 09:06, Michael S wrote:
On Sat, 16 Mar 2024 16:19:11 -0700
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
As written, your example does not emphasize that the problem has
nothing to do with implementation of sinX() library routine.
It's best illustrated by followup conversation with bart, IMHO 100%
O.T.
Actually, the thread topic is the more basic one of whether angles to these functions should be specified as degrees or radians.
In answer to that, I decided long ago (in my language designs) to keep them as radians, but allow degrees for constants if written in one of these styles like this:
sin(30°) + cos(60 deg)
Because, once they're inside a variable:
sin(alpha) + cos(beta)
then the unit used is irrelevant.
As for the value returned from sin() etc, I haven't worried about that since last century.
Except briefly more recently when I had an arbitrary precision floating point library and considered whether to add such functions, but concluded I didn't have the right skills, experience (of using ultra-high precision trig functions) or motivation.
The first problem was: exactly how accurately should it be generated. With ieee754 it's easy, you only have 53 binary digits to fill.
In my (decimal) library, the default precision for a calculation like 1.0/3.0 is typically set up to 500 decimal digits, or about 1600 bits, otherwise it will keep going forever (the theoretical limit is 19 billion decimal digits, or 64 billion bits).
The second problem was, how do you even calculate sin(x) so that it converges to that accuracy within a reasonable amount of time? The Taylor series that I used to use wouldn't cut it.
(Dealing with inputs that are extreme multiples of +/- 2pi radians would be an additional difficulty.)
I decided not to bother with transcendental functions.