[Scilab-users] Rounding error or precision setting?
Adrien Vogt-Schilb
vogt at centre-cired.fr
Wed Feb 19 15:24:33 CET 2014
Hi
The function *clean *does that:
clean(cos(%pi)+%i*sin(%pi))
Note that the limited precision of floating point numbers is a general
issue in computer science.
http://en.wikipedia.org/wiki/Floating_point#Representable_numbers.2C_conversion_and_rounding
You should be aware of that for instance when testing numbers, as in:
if cos(%pi)+%i*sin(%pi) == -1
disp("i am a mathematician")
else
disp("i am a computer")
end
if abs(cos(%pi)+%i*sin(%pi) +1)<1d-8
disp("yep")
else
disp("nope")
end
or when you calculate indefinite integrals.
Also note that some modules on ATOMS and scilabfilexchange allow to make
computation with arbitrary (but not infenitesimal) precision.
On 19/02/2014 15:15, Lester Anderson wrote:
> Hello,
> Just a quick query. Not been using Scilab for a while, so maybe I have
> missed something, but is there a built-in precision setting for
> working with real and imaginary functions?
> Tried the Euler formula (special case) in Scilab 5.4.1:
> -->x=cos(%pi)+(%i*sin(%pi))
> x =
>
> - 1. + 1.225D-16i
>
> -->y=%e^(%i*%pi)
> y =
>
> - 1. + 1.225D-16i
> The real part is fine, but the complex has a measured value
> (approaching zero). Is there a way to tell Scilab if this gets beyond
> a limit to round off at zero say?
> Sure this is an easy one!
> Cheers
>
> Lester
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
--
Adrien Vogt-Schilb
PhD Student (Cired)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20140219/e43d1e9c/attachment.htm>
More information about the users
mailing list