<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<font face="Courier New">Dear all,<br>
<br>
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:<br>
<br>
x = sin(2*%pi*fo*t); <br>
<br>
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.<br>
<br>
For instance, we have (23 digits shown)<br>
<br>
--> sin(%pi)<br>
ans =<br>
0.0000000000000001224647<br>
<br>
--> sin(1e10*%pi)<br>
ans =<br>
-0.0000022393627619559233<br>
<br>
--> sin(1e15*%pi)<br>
ans =<br>
-0.2362090532517409080526<br>
<br>
The Wolfram Alpha site yields the correct value 0 in all cases
(using their own pi).<br>
<br>
Questions:<br>
<br>
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?<br>
<br>
2) Is there a way to get a periodic discrete sine other than
extending it periodically with the desired period?<br>
Wouldn't this create a slight glitch at the frontier between
cycles?<br>
<br>
Regards,<br>
<br>
Federico Miyara <br>
</font>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /> <table style="border-top: 1px solid #D3D4DE;">
<tr>
<td style="width: 55px; padding-top: 18px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
<td style="width: 470px; padding-top: 17px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Libre de virus. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a> </td>
</tr>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>