Jezzamonn / fourier

An Interactive Introduction to Fourier Transforms
http://www.jezzamon.com/fourier
MIT License
2.47k stars 217 forks source link

Fourier decomposition doesn't work with a constant function #18

Open VictorLamoine opened 5 years ago

VictorLamoine commented 5 years ago

If you draw a perfectly constant function the decomposition doesn't work: image

JoniRousu commented 5 years ago

From my academic background (electrical engineering student) I can say that a fourier transformation of a constant doesn't exist in the real world. The result would be a so called dirac delta function (https://en.m.wikipedia.org/wiki/Dirac_delta_function). But it would be nice to indicate that.

Jezzamonn commented 5 years ago

I guess it depends on what context you're talking about, but in some contexts you definitely can do a fourier transform of a constant! One of the terms will be the constant term, essentially with a frequency of zero.

This is more due to the implementation though, but there's maybe two reasons why you can't see it on the page: The first is because to make it visually simpler, as well as keep the page running smoothly, it doesn't draw sine waves that are very small (and 0 is as small as you can get). I guess the second thing is I might also be filtering out the constant term anyway because it's kind of different to represent it. If you see a line by itself it's hard to tell how far away that line is from zero without having a line at zero. Same with the circles, I don't draw the constant term there, I just zero it out (also to keep the image balanced in the middle).

But there's not really a good reason not to show it, particularly for that case. I'll see if I can get some time to adjust it

JoniRousu commented 5 years ago

I guess it depends on what context you're talking about, but in some contexts you definitely can do a fourier transform of a constant! One of the terms will be the constant term, essentially with a frequency of zero.

I was talking about time constant functions. As I said, a fourier transform is possible. The solution is a dirac function with the value of the constant as "weight". The problem is that the width is infinitely small and thus the only frequency is 0. That's what I meant with "doesn't exist in the real world". If you take a look at the Wikipedia page, you will find a schematic representation of a dirac function.