Re: sin(x) for large x

From: glen herrmannsfeldt (gah_at_ugcs.caltech.edu)
Date: 05/15/04


Date: Fri, 14 May 2004 22:28:33 GMT

Dr Chaos wrote:

> glen herrmannsfeldt <gah@ugcs.caltech.edu> wrote:

>>There is a discussion in comp.lang.c titled
>>Sine code for ANSI C

>>regarding the evaluation of the sin() function for large
>>arguments. It might be more applicable in this
>>group, so I thought I would ask here.

>>What result do people expect from the sin() function for
>>very large arguments, for example sin(1e100)?

> sin(1e100) is a symptom of a mistake.

I suppose it should have been sin(1D100) in this newsgroup...

> I believe that if one's program depends on evaluating that to any
> degree of accuracy, it is computing something in a mathematically
> mistaken way.

> Generally you need some paper-and-pencil analysis and thinking to
> avoid this problem.

>>Hopefully the discussion won't get too nasty, but it
>>does seem to be a contentious issue over there.

> Sometimes computer scientists have an odd idea what it means to be
> "correct", e.g. imagining that the particular rules of IEEE floating
> point define "correctness" as opposed to solving the problem in a
> satisfactory way.

It seems that some believe that it is possible to consider
even a very large floating point number as a value in radians,
and compute the sin() for that value. It may take hundreds
or thousands of digits of pi to do the computation.
(There are floating point systems with 15 or 16 bit exponents.)

None of the arguments made so far in comp.lang.c seem
to have been convincing that there is no mathematical
use for such, except possibly when one is already using
multiple precision arithmetic.

thanks for replying,

-- glen