Re: sin(x) for large x
From: *** Hendrickson (***.hendrickson_at_att.net)
Date: 05/15/04
- Next message: glen herrmannsfeldt: "Re: Sun compiler not liking X in format statements"
- Previous message: Dr. Richard E. Hawkins: "Sun compiler not liking X in format statements"
- In reply to: glen herrmannsfeldt: "sin(x) for large x"
- Next in thread: Eric J. Kostelich: "Re: sin(x) for large x"
- Reply: Eric J. Kostelich: "Re: sin(x) for large x"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 14 May 2004 22:18:18 GMT
glen herrmannsfeldt 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)?
>
> Hopefully the discussion won't get too nasty, but it
> does seem to be a contentious issue over there.
>
> -- glen
>
Since it's getting late on a Friday and the beer isn't
quite chilled yet, I'll try the obviously correct answer.
"I wouldn't expect anything useful."
I think there's two ways to look at this.
We know mathematically
Sin(x+2*N*pi) = Sin(x)
But once N is large we can't computationally recover
the value of x, it gets lost in the truncation to finite
representation. And then Sin(x+2N*pi) is independent of x.
But, if we look at the problem in a different way,
and if I could remember my high school trig, I'm sure I
could expand Sin(2.0) into some nice function of
Sin(1.0) (Please don't tell me the function,
I've only got a 12 pack). And by doing the evaluation
in double precision and pulling it back to single
we could probably compute sin(2.0) to within one bit.
Then it's a simple matter to compute Sin(3.0) from the
pretty accurate Sin(2.0) and Sin(1.0), again I think to
one bit. By working our way up, wouldn't we eventually
compute sin(1.e100) from a few accurately known values
to a high degree of accuracy? But, this contradicts
the first argument.
Maybe the expectaion depends on where the 1.e100 comes
from. If it comes from a long series of addition, then
you could reasonably expect to work your way up the
sequence, effectively taking out the 2*pi each time you
go around the circle. But if it comes from dividing
the age of the universe by the gravitational constant,
you'll never get the 2*pis out.
When there's two more or less different ways to look at
a problem, and they give different answers, I usually
think that defining one of them to be correct isn't
useful. It'll confuse too many people some of the time.
*** Hendrickson
- Next message: glen herrmannsfeldt: "Re: Sun compiler not liking X in format statements"
- Previous message: Dr. Richard E. Hawkins: "Sun compiler not liking X in format statements"
- In reply to: glen herrmannsfeldt: "sin(x) for large x"
- Next in thread: Eric J. Kostelich: "Re: sin(x) for large x"
- Reply: Eric J. Kostelich: "Re: sin(x) for large x"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]