Re: Sine code for ANSI C
In article <40A9381C.500B5 038@yahoo.com>,
CBFalconer <cbfalconer@yah oo.com> wrote:
[color=blue]
> Christian Bau wrote:[color=green]
> >[/color]
> ... snip ...[color=green]
> >
> > Somehow your mentioning of sin (DBL_MAX) sparked a little idea
> > that might help you calculating sin (x) for arbitrarily large
> > values quite quickly, especially useful if you use long double
> > with 15 exponent bits and an enormous range:
> >
> > Instead of storing huge numbers of bits of 1/2pi and doing huge
> > precision argument reduction, just store the values of
> > sin (65536 ^ N) and cos (65536 ^ N) with lets say 20 or 24
> > extra bits of precision. ... snip ...[/color]
>
> That isn't necessary. Assuming the argument is precise (i.e.
> extended by zero bits on the right) all we need to compute (arg
> mod PI) to the precision of PI is a couple of guard bits.[/color]
When you write PI you mean a floating point approximation of the
mathematical constant pi? For large x, reduction modulo an approximation
to pi will give a result that is very much different from reduction
modulo pi. That is why some libraries store pi or 1/pi with a precision
of several thousand bits.
In article <40A9381C.500B5 038@yahoo.com>,
CBFalconer <cbfalconer@yah oo.com> wrote:
[color=blue]
> Christian Bau wrote:[color=green]
> >[/color]
> ... snip ...[color=green]
> >
> > Somehow your mentioning of sin (DBL_MAX) sparked a little idea
> > that might help you calculating sin (x) for arbitrarily large
> > values quite quickly, especially useful if you use long double
> > with 15 exponent bits and an enormous range:
> >
> > Instead of storing huge numbers of bits of 1/2pi and doing huge
> > precision argument reduction, just store the values of
> > sin (65536 ^ N) and cos (65536 ^ N) with lets say 20 or 24
> > extra bits of precision. ... snip ...[/color]
>
> That isn't necessary. Assuming the argument is precise (i.e.
> extended by zero bits on the right) all we need to compute (arg
> mod PI) to the precision of PI is a couple of guard bits.[/color]
When you write PI you mean a floating point approximation of the
mathematical constant pi? For large x, reduction modulo an approximation
to pi will give a result that is very much different from reduction
modulo pi. That is why some libraries store pi or 1/pi with a precision
of several thousand bits.
Comment