[Scilab-users] Problems arising from truncation of %pi

Jean-Yves Baudais Jean-Yves.Baudais at insa-rennes.fr
Fri Jan 8 10:48:31 CET 2021


Hello,

----- Original Message -----
> The function could be sinpi() or similar, with two arguments: the main
> argument x and an integer argument n, being its result equivalent to
> 
> sin(x - n*pi)

So now the problem can be how these large numbers are obtained
--> a=1e16+1
--> a-1e16
of course equals zero. 

> where pi is the exact value of pi

Hum... What does "exact" mean in numerical calculus? (In symbolic one, it's simpler :-)

--> format(25)
--> %pi
3.141592653589793115998

the 6 last digits are wrong (cf. https://oeis.org/A000796) because of float64 format.

> Probably it is not proper to refer to it as noise, since the difference
> is deterministic as can be demonstrated by using the function nearfloat()

Maybe noise is not the right word. But, the difference is fixed and %pi give all the time the same digit in format(25). It's a bit weird (up to my ignorance) to have these wrong deterministic digits... Hum, maybe I need to read "What Every Computer Scientist Should Know about Floating-Point Arithmetic", David Goldberg, ACM Computing Surveys, vol. 23, no  1, mars 1991 recommanded by https://en.wikipedia.org/wiki/IEEE_754

--Jean-Yves




More information about the users mailing list