Tough problem...



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


.



Relevant Pages

  • Re: weird results when multiplying by a power of 10
    ... I'm not very familiar with how Matlab handles the math for ... I'm having problems multiplying certain numbers by the ... the limited floating point representation by HW (also typically called round ...
    (comp.soft-sys.matlab)
  • Re: Bug in excel fundamantal add-function
    ... floating point math. ... finite number of binary digits, just as 1/3 can't be exactly represented ... You can use ROUND() to round to zero if it's necessary. ...
    (microsoft.public.excel)
  • Re: Bug in excel fundamantal add-function
    ... floating point math. ... finite number of binary digits, just as 1/3 can't be exactly represented ... You can use ROUND() to round to zero if it's necessary. ...
    (microsoft.public.excel)
  • Re: Floating Point Problems
    ... > I have problems with floating point numbers. ... decimal representation of that value? ... those trailing bits make us round up ... I don't know enough about floating point math to say whether the .NET ...
    (comp.programming)
  • Re: prePEP: Decimal data type
    ... I think it's a good thing that you're forced to round ... >is about rounding rules and it's quite easy to avoid the "fail to meet the ... ISTM these things are 'way beyond the concern of a math package per se, ... for the meaning of "context" in this PEP context, ...
    (comp.lang.python)

Quantcast