# DFT of a pure sine wave not showing ideal sine wave

I have a question with regard to the DFT of an ideal sine wave.

This is my simulation result in cadence.

I analyzed an ideal sine wave (from vsin source) and passed it through a dft calculator function with hanning window. For an ideal sine wave, I should expect to see only the signal components. However, apart from the three signal bins, I also have many tones. Even though the tones are of very small value, I still wonder why they appear for an ideal sine wave (which they shouldn't).

Thank you very much,

Kenny

You say you have an ideal sinewave. But do you? You probably only have a good approximation to one. Depending on whether it's in 32 bit or 64 bit reals, you will, at best, have quantisation noise in the 24th or 56th least significant bit position. This will contribute to wideband noise. Compute what that expected noise power is, and compare that with your observed noise floor.

You will notice that the observed noise floor is higher than that input quantisation level. There are two reasons for this.

1. You are using a window, in your case hanning. In the ideal case, all DFT windows have 'noise gain' of a few dBs. The narrower the window, the larger the noise gain.

2. The arithmetic used by the both the window multiplication and the DFT operation will introduce quantisation noise at every stage. The handling of intermediate calculations is a function of not only the (almost always IEEE754 compliant) hardware, but also how the software uses it. While some hardware has the ability to keep 80 bit precision at intermediate stages, many implementations only keep 64 bits in the hardware, and only 56 bits when saving back to memory as 64 bit reals.

You would need to study the detail of DFT algorithm used, the hardware you are running on, the effect of the compiler flags, to find every last dB of increased noise in your final DFT.

• Hi Neil_UK, Thank you very much for your answer. I appreciate it. May I please restate it in my own words and let you see if I have understood it correctly? The reason why the sine wave (from Cadence Voltage Source) has many noise tones on its dft is due to the fact that the sine wave though from an ideal source is only an approximation to the "real ideal" sine wave since the computer can only store 32-bit or 64-bit details (finite). Hence there will be quantization errors in the sine wave causing the tones to appear on its dft. The noise floor may be higher than theory due to many factors. Commented May 31 at 14:56
• @Kenlucius Yes, the quantisation noise on the original samples forms a lower bound on what noise you may see. The quantisation noise present on all of the intermediate operations, from the windowing, to the FFT itself, will probably have a bigger contribution to the final noise. Commented May 31 at 15:34
• Thank you very much for your help :) Commented Jun 2 at 11:18

The noise floor on your plot around -190...-200dB is simply the result of rounding errors and other sources of noise from the calculation. I guess it uses floating point math, which does not have infinite precision, so it introduces quantization noise. Fixed point has a fixed amount of it, but floating point does not, so it's hard to calculate. It manifests in the FFT, the sinewave generation, the window calculation, etc.

Even the time axis will have quantization errors, for example double precision can't encode "0.001" exactly, so if you use a millisecond time step, instead of 0.001s you will actually get 0.00100000000000000002081668171172168513294309377670 and then some...

• Hi bobflux, Thank you very much for your answer. I see now. The reason why I saw many tones on the dft for the sine wave was because of the quantization noise for the sine wave (approximation of an ideal sine due to limited precision) and noise from calculations such as windowing and dft. Is this correct :) Commented May 31 at 15:05
• Yes, that's the idea! Commented May 31 at 16:59
• Thank you very much! Commented Jun 2 at 11:11

TL;DR: You need to do the DFT symbolically to have exact values.

The proper term for “perfect” sine function values would be exact values of sine function.

Most values of the sine function are irrational numbers, so there is no exact representation of them using digits, irrespective of the base chosen.

If you did that DFT symbolically, and that’s certainly possible if time-consuming using something like Mathematica, you’d get a single peak of exact amplitude, and exact zeroes elsewhere because symbolic computations can be done exactly for certain problems, and DFT of certain functions happens to be one. In fact, DFT of a sum of sine waves is easy enough to do in class on a blackboard. More involved functions take longer to do or have no exact solutions in terms of elementary functions.

On a dB (logarithmic) scale, it is not possible to represent exactly zero amplitude. It will be "minus infinity dB"

If you switch to linear scale, you will pretty much get a flat zero floor and a single peak at any reasonable resolution.

On the other hand, your "noise floor" is well below -180dB. It means that your calculation noise (quantization, rounding, jitter, etc...) is impressively low.

I am not aware of a real-world circuit with noise levels like this.

For it to only be a single spike, it requires infinite time. The timeframe of your sinewave is basically a square function on its own - if you sample from negative infinity to infinity you would be left with a single spike/peak. Also, as another answer states the discrete form has finite steps/resolution, these are discontinuities that will affect the fineal DFT.

• Wrong. An FT already treats the input signal as if it repeats forever from negative infinity to positive infinity. Commented May 24 at 12:49
• @QuittingDueToAntisemitism Unless the sine wave has a period commensurate with the window, there will effectively be discontinuities with a period of the window width. The set of frequencies that avoids this has measure zero... Commented May 24 at 13:55