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

Jean-Yves Baudais Jean-Yves.Baudais at insa-rennes.fr
Wed Jan 6 09:14:23 CET 2021


Hello,

Le 05/01/2021 à 09:19, Federico Miyara a écrit :
> --> sin(%pi)
>   ans  =
>     0.0000000000000001224647


You face the limited precision of all numerical calculus. See
--> help %eps

It has no sense to use 23 digits with a precision of 2.22E-16, the 7th 
last digits are noise.


> --> sin(1e10*%pi)
>   ans  =
>    -0.0000022393627619559233
> 
> --> sin(1e15*%pi)
>   ans  =
>    -0.2362090532517409080526


All is consistent with the definition of the precision. A toy example:
--> a=2;
--> b=sqrt(2);
--> a-b^2

You expect zero because you do symbolic calculus, not Scilab.


> The Wolfram Alpha site yields the correct value 0 in all cases (using 
> their own pi).


Because it uses symbolic calculus. So, if you want more precision with 
Scilab you should change the standard used, but maybe some tricks in 
your code can solve the problem... Or maybe you need symbolic calculus tool.

--Jean-Yves



More information about the users mailing list