[Scilab-users] Problems arising from truncation of %pi
Federico Miyara
fmiyara at fceia.unr.edu.ar
Tue Jan 5 09:19:30 CET 2021
Dear all,
In order to test the FFT on a periodic signal whose period is an exact
submultiple of the FFT length I found a frequency fo satisfying this for
the chosen sample rate and window length, and generated the following
signal:
x = sin(2*%pi*fo*t);
where t is a time vector. This should be a perfectly periodic discrete
signal but it isn't because the sin() function has a (virtually) exact
period of pi, while %pi is exact to 16 digits only.
For instance, we have (23 digits shown)
--> sin(%pi)
ans =
0.0000000000000001224647
--> sin(1e10*%pi)
ans =
-0.0000022393627619559233
--> sin(1e15*%pi)
ans =
-0.2362090532517409080526
The Wolfram Alpha site yields the correct value 0 in all cases (using
their own pi).
Questions:
1) How is the sin() function extended to very large values of the
argument? My first guess would be to compute a quarter cycle using
Taylor and then extend it by symmetry and periodicity, but with which
period? The best approximation available is 2*%pi. Or it is possible to
use extended precision internally?
2) Is there a way to get a periodic discrete sine other than extending
it periodically with the desired period?
Wouldn't this create a slight glitch at the frontier between cycles?
Regards,
Federico Miyara
--
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20210105/8e813cb3/attachment.htm>
More information about the users
mailing list