<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Of course, this does only work for integer multiples of %pi. This
plot illustrates well Antoine's remark:</p>
<p>x=(10^15*%pi)+(0:0.001:2*%pi);<br>
plot(sin(x));</p>
<img moz-do-not-send="false"
src="cid:part1.707A6EAE.70DAD7D2@utc.fr" alt="error" width="610"
height="460">
<p>I like new year's jokes !<br>
</p>
<p>S.<br>
</p>
<div class="moz-cite-prefix">Le 06/01/2021 à 09:49, Stéphane
Mottelet a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:f9f8ddfa-58dd-5496-af47-2fc3a13b1431@utc.fr">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<p>I do not agree with your answer. Doing *by hand* the shift to a
principal period of sin () solves the problem. For example,
here is a plot of sin(x) vs sin(x-floor(x/2/%pi)*%pi*2) for
large values of x:<br>
</p>
<p>x = (10^[1:16])*%pi<br>
sx = sin(x-floor(x/2/%pi)*%pi*2)<br>
plot("ln",x,sin(x),'-o',x,sx,'-o')<br>
legend("$\Large\sin x$","$\Large\sin
\left(x-2\pi\left\lfloor\frac{x}{2\pi}\right\rfloor\right)$",3)</p>
<img moz-do-not-send="false"
src="cid:part2.BC5610F1.DCA38D1C@utc.fr" alt="error" class=""
width="437" height="377">
<p>I suppose that the hardware implementation used by the compiler
when using the standard math library does not use this simple
trick because it would decrease the floating point performance.</p>
<br>
<div class="moz-cite-prefix">S.<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Le 06/01/2021 à 09:14, Jean-Yves
Baudais a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:18f181de-0582-c968-f189-bb9a9f4190d4@insa-rennes.fr">Hello,
<br>
<br>
Le 05/01/2021 à 09:19, Federico Miyara a écrit : <br>
<blockquote type="cite">--> sin(%pi) <br>
ans = <br>
0.0000000000000001224647 <br>
</blockquote>
<br>
<br>
You face the limited precision of all numerical calculus. See <br>
--> help %eps <br>
<br>
It has no sense to use 23 digits with a precision of 2.22E-16,
the 7th last digits are noise. <br>
<br>
<br>
<blockquote type="cite">--> sin(1e10*%pi) <br>
ans = <br>
-0.0000022393627619559233 <br>
<br>
--> sin(1e15*%pi) <br>
ans = <br>
-0.2362090532517409080526 <br>
</blockquote>
<br>
<br>
All is consistent with the definition of the precision. A toy
example: <br>
--> a=2; <br>
--> b=sqrt(2); <br>
--> a-b^2 <br>
<br>
You expect zero because you do symbolic calculus, not Scilab. <br>
<br>
<br>
<blockquote type="cite">The Wolfram Alpha site yields the
correct value 0 in all cases (using their own pi). <br>
</blockquote>
<br>
<br>
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. <br>
<br>
--Jean-Yves <br>
_______________________________________________ <br>
users mailing list <br>
<a class="moz-txt-link-abbreviated"
href="mailto:users@lists.scilab.org" moz-do-not-send="true">users@lists.scilab.org</a>
<br>
<a class="moz-txt-link-freetext"
href="https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users"
moz-do-not-send="true">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a>
<br>
</blockquote>
<pre class="moz-signature" cols="72">--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.utc.fr/~mottelet" moz-do-not-send="true">http://www.utc.fr/~mottelet</a>
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
<a class="moz-txt-link-freetext" href="http://www.utc.fr/~mottelet">http://www.utc.fr/~mottelet</a>
</pre>
</body>
</html>