Re: Tough problem...
- From: "Atmapuri" <janez.makovsek@xxxxxxx>
- Date: Tue, 27 Jun 2006 17:17:29 +0200
Hi!
Why don't you first subtract out the multiples
of 2*pi?
:) You mean compute the reminder of the divison
with 2*Pi? I do that. Its better, but it seems
only because the reminder function computes the
reminder in extended precision. (the variables are never
saved to memory while the reminder is computed).
Namely, The sin function inside the FPU
first substracts 2*PI many times until the argument falls between
-Pi and +Pi.
(according to the Intel manuals).
If the argument is 1000, you loose last 3 decimal
places for every subtraction at the begining. So
it is not sin itself that is causing the problem, but
the way the argument is moved in to the
correct starting interval.
I am not sure exactly how much is the reminder
function in this case more accurate. (It sure is faster than
the subtraction loop done by the FPU!)
1000/(2*Pi) can be rewritten as:
1000 * 1/(2*Pi)
And this means that after you computed 1/(2*Pi)
and then multiplied by 1000, you have cut off the last three decimal
places, because you moved the decimal point three places back.
The problem is equivalent to obtaining the
fractional part of a large number. The bigger the
number the less precision the fractional part has.
I noticed that, when I was doing:
a = i*x, 0<x<1
y = Frac(a);
As soon as I multipled x with i, I already lost three
decimal places in y, if i was 1000.
So, I was thinking that maybe there is way
to compute y, without explicitely computing a.
Thanks!
Atmapuri
.
- Follow-Ups:
- Re: Tough problem...
- From: Avatar Zondertau
- Re: Tough problem...
- References:
- Tough problem...
- From: Atmapuri
- Re: Tough problem...
- From: John Herbster
- Tough problem...
- Prev by Date: Re: Tough problem...
- Next by Date: Re: Tough problem...
- Previous by thread: Re: Tough problem...
- Next by thread: Re: Tough problem...
- Index(es):