# Unexpected result with custom FFT implementation

To fully understand the Fourier Transform I have been working on a rather standard implementation of the FFT algorithm. I tried generating a 440 Hz sin wave and passing it through the algorithm, however, when plotting the real part of the result, I get a spiky mess, whereas I was expecting two spikes (as from my understanding it's mirrored, since the second half is just a representation of the first's complex conjugate).

Disappointed, I tried passing the sin wave through a third party library, but achieved the same result, so I suspect I am misunderstanding what the FFT actually outputs. Not sure how useful it is, but here is the GitHub project https://github.com/kradicati/fourier-transform

The two most important classes are: https://github.com/kradicati/fourier-transform/blob/master/src/test/kotlin/me/krb/transform/FastFourierTransformTest.kt (where the actual plotting is done) https://github.com/kradicati/fourier-transform/blob/master/src/main/kotlin/me/krb/transform/FastFourierTransform.kt (the FFT implementation)

• What is the sample rate for your input signal? Can you add that to the question? Jan 15, 2022 at 17:27
• Assuming I didn't make a mistake in the wave generation it should be 1000 samples per second Jan 15, 2022 at 17:30
• Thank you, just wanted to make sure your sampling rate is high enough for you signal and it appears to be fine. Jan 15, 2022 at 17:42
• Your sample rate is 16384 Hz since you create a time vector of 1 second length with 16384 points (or maybe 16385 depending on numerical behavior). Your y-axis is very strange. This seems to be primarily noise. It's way to small and is simply a small DC offset with some numerical noise on top of it. Suggestion: start with a unit impulse of 16 points and debug manually from there. Jan 15, 2022 at 17:51
• I did what the answer suggested, which is plotting the absolute value of the complex number, which ended up being exactly what I was looking for. And thank you for the clarification, I had misunderstood! Jan 15, 2022 at 18:09

$$\mathcal {F}[\sin(ax)] = \frac{\delta\left(\xi-\frac{a}{2\pi}\right)-\delta\left(\xi+\frac{a}{2\pi}\right)}{2i}$$
where $$\xi$$ is the frequency, $$\delta()$$ is the Dirac delta function, and $$i$$ is the imaginary unit.