Tough problem...
- From: "Atmapuri" <janez.makovsek@xxxxxxx>
- Date: Tue, 27 Jun 2006 13:42:25 +0200
Hi!
I am hoping somebody here has enough expirience
in math and floating point round off errors, to help
me tackle this issue:
If you pass a large argument to sin or cos, the
result is not accurate. In fact, you loose roughly as many
decimal places, as there are zeros in the argument:
sin(1000) => looses 3 decimal places.
If the computation is done in extended precision,
you have a reserve of 4 decimal places, but sometimes
even that is not enough.
But I "feel" that the information needed to compute
to the full accuracy is there. I cant write the code yet,
but here is my reasoning:
sin(1000) is computed by the FPU by first computing
the reminder after division by two. This is very
similar to getting the fractional part of a number.
The bigger the integer number the less valid decimal
places are in the fractional part. For the number
of 1E+16, the fractional part has zero valid decimal places.
So, the problem could be transformed in to a subproblem
where we need to find:
i*2*Pi + f*2*Pi
where i is the integer part of twoPi and f is the fractional
part. (between 0 and 1).
I have another almost the same issue: I have to find
a way to compute fractional part of number a:
a = i*f; 0 <= f< 1
If "i" is around 1E+16 and f is close to 1, the Frac(a) function results
in complete loss of accuracy.
Its obvious that if only a is given, there is nothing you can do,
but the trick here is the "i" is known in advance, so it feels
that somehow it should be possible to compute the fractional
part accurately.
Thanks!
Atmapuri
.
- Follow-Ups:
- Re: Tough problem...
- From: Eric Grange
- Re: Tough problem...
- From: John Herbster
- Re: Tough problem...
- Prev by Date: Re: Fastcode CompareText B&V
- Next by Date: Re: Fastcode CompareText B&V
- Previous by thread: Fastcode FillChar B&V 1.6.0
- Next by thread: Re: Tough problem...
- Index(es):
Relevant Pages
|