## Fourier Series and Fourier Transform

I want to show you something that I think is really neat. (Whether you think it is neat is your decision, not mine. I don’t like it when people tell me what I will think about something they’re about to show me.)

I do not know why this calculation is not readily available. All I know is that I had to search high and low to find an example with sufficient detail that I could duplicate it. In fact, it is difficult to find a text which actually states the result at all, never mind one which works it out for a particular case.

• I intend to take a function which is zero outside the interval [-1/2, 1/2]…
• I will compute several terms in the associated Fourier series…
• I will compute its Fourier transform…
• and I will hit you between the eyes with the relationship between them.

I won’t even keep it a secret:

• the coefficients in the Fourier series are samples of the Fourier transform.
• alternatively, the Fourier transform of the Fourier series is discrete samples of the original continuous Fourier transform.

I think that’s marvelous. But even knowing that it’s true, I don’t see it stated very often.

There are several things I will not do in this post.

• I will use but not discuss Fourier series or the Fourier transform;
• I will work the example for a very specific set of parameters;
• that is, I will not yet try changing the interval to, say, [0, 2 $\pi\$];
• I won’t even prove the relationship;
• I will not show you the relationship to the discrete Fourier transform (i.e. the FFT);

I should say that the proof really just amounts to showing that the Fourier transform of the cosine exists and is a pair of delta functions.

It may be that the FFT is so important that most people do not care about the relationship between a Fourier series and a Fourier transform. Well, I do.

Having told you all the things I will not do in this post, let me emphasize that I think this example — or, frankly, any similar example — is marvelous and worthwhile. There are a lot of things that have to be done right to get the details to come out right. And given one good example, I can make a whole lot of sense out of theory.

This example is based on one in Bracewell (Bracewell, Ronald N.; The Fourier Transformation and Its Applications. McGraw Hill, 2000 (3rd ed). ISBN 0 07 303938 1), around p. 244, slightly modified. It is a most excellent book for insight; the mathematics is there, and right, but in the background. The text is marred by typos, but is extraordinary despite them.

I need some pictures. To get them, I need four things. I start with a Fourier transform, namely the square of a sinc function, which itself is some form of sin(x) / x:

$F(s) = \frac{1}{5} \text{sinc}\left(\frac{\pi\ s}{5}\right)^2$

We find the inverse Fourier transform:

$f(t) = \frac{5}{2} t \text{sgn}\left(t-\frac{1}{5}\right)-\frac{1}{2} \text{sgn}\left(t-\frac{1}{5}\right)-5 t \text{sgn}(t)+\frac{5}{2} t \text{sgn}\left(t+\frac{1}{5}\right)+\frac{1}{2} \text{sgn}\left(t+\frac{1}{5}\right)$

Hey, it’s our favorite counterexample for wavelets: the linear spline scaling function. Ok, it’s skinnier, not of width 2, but it is a triangle. This one does not even fill up the interval [-1/2, 1/2].

Next, I need the Fourier Series of that triangle. Well, I don’t really want an infinite series; I just want a finite approximation. Let’s get 7 terms icluding the constant:

$0.350056 \cos (2 \pi t)+0.229115 \cos (4 \pi t)+0.101829 \cos (6 \pi t)+0.0218785 \cos (8 \pi t)+0.00972378 \cos (12 \pi t)+0.2$

Mathematica complains about convergence, but it turns out, it’s good enough. We see that there is no term in $Cos[10 \pi t]\$, so it looks like we only got 6 terms.

I have shown both the Fourier Series in red and the original single triangle in blue. Strictly speaking, and we need to be strict on this point, that is not the Fourier series of the triangle, but of its periodic extension. We might call it the Fourier series associated with the single triangular pulse.

Finally, just for the drawings, I want to sample the Fourier Transform at the integers:

$\left(\begin{array}{cc} -6. & 0.00486189 \\ -5. & 0. \\ -4. & 0.0109393 \\ -3. & 0.0509144 \\ -2. & 0.114557 \\ -1. & 0.175028 \\ 0. & 0.2 \\ 1. & 0.175028 \\ 2. & 0.114557 \\ 3. & 0.0509144 \\ 4. & 0.0109393 \\ 5. & 0. \\ 6. & 0.00486189\end{array}\right)\$.

Let me put it all together.

The top left is a single triangular pulse in the time domain, of height 1, centered at the origin, of width 0.4. We might say it is band-limited in time, or that it is of compact support.

The top right is the Fourier transform of that triangular pulse. It is continuous, and not of compact support.

The bottom left shows the triangular pulse and (the first 7 terms of) its fourier series. Although the triangular pulse is not periodic, the Fourier series is.

The bottom right shows two things. The continuous Fourier transform and red dots which are, by definition, samples of that transform.

Drum roll, please. They are also the coefficients of the fourier series.

How can that be? For crying out loud, there are 13 samples but 7 coefficients! Worse, although the constant term in the Fourier series is .2, and that is equal to the sample F[0], the first cosine term has coefficient 0.350056 while the sample F[1] = 0.175028 .

Hey, if we multiply the sample value by 2, we get: 0.350056 . Which is our leading cosine coefficient.

Conceptually, some of our samples are for negative frequencies, but we wrote the Fourier series with positive frequencies only. If we use complex exponentials instead of cosines, then we get negative frequencies too, and the series coefficients will be cut in half (except the constant term).

Alternatively (but equivalently), since $Cos[-2 \pi t] = Cos[2 \pi t]\$, an individual series term such as

$0.350056 \cos (2 \pi t)\$

could be wriiten as

$0.175028 Cos[2 \pi t] + 0.175028 Cos[-2 \pi t]\$,

and there are our sample values equal to 0.175028 at -1 and 1.

Let me take a longer look.

We started with the Fourier transform:

$F(s) = \frac{1}{5} \text{sinc}\left(\frac{\pi s}{5}\right)^2\$.

If we remember that the sinc function is the Fourier transform of a rectangle, then the sinc^2 function is the Fourier transform of the convolution of two rectangles.

But the convolution of two rectangles is a triangle. That the inverse Fourier transform is a triangle should seem more than plausible.

Specifically, it turns out to be:

$f(t) = \frac{5}{2} t\ \text{sgn}\left(t-\frac{1}{5}\right)-\frac{1}{2} \text{sgn}\left(t-\frac{1}{5}\right)-5 t\ \text{sgn}(t)+\frac{5}{2} t\ \text{sgn}\left(t+\frac{1}{5}\right)+\frac{1}{2} \text{sgn}\left(t+\frac{1}{5}\right)\$.

I can’t say I like the way Mathematica writes it, but the graph showed that we do in fact have a single triangular pulse.

Then I asked Mathematica for the first 7 terms of the Fourier series of the triangle:

$fs(t) = 0.350056 \cos (2 \pi t)+0.229115 \cos (4 \pi t)+0.101829 \cos (6 \pi t)+0.0218785 \cos (8 \pi t)+0.00972378 \cos (12 \pi t)+0.2\$.

As I said, it turns out there are in fact only 6 terms: we are missing one in $Cos[10 \pi t]\$. (Strictly speaking, my command probably asked Mathematica for the first 6 non-zero terms. Whatever.)

Finally, I computed and plotted samples of the fourier transform. What were the samples? The plotted points were

$\left(\begin{array}{cc} -6. & 0.00486189 \\ -5. & 0. \\ -4. & 0.0109393 \\ -3. & 0.0509144 \\ -2. & 0.114557 \\ -1. & 0.175028 \\ 0. & 0.2 \\ 1. & 0.175028 \\ 2. & 0.114557 \\ 3. & 0.0509144 \\ 4. & 0.0109393 \\ 5. & 0. \\ 6. & 0.00486189\end{array}\right)\$

so the y-values were the right column of that array.

Let me explicitly convert the fourier series to complex exponentials, using

$(e^{i t} + e^{i t})/2 = Cos (t)\$

$fs(t) = 0.2+0.175028 e^{-2 i \pi t}+0.175028 e^{2 i \pi t}+0.114557 e^{-4 i \pi t}+0.114557 e^{4 i \pi t}+0.0509144 e^{-6 i \pi t}+0.0509144 e^{6 i \pi t}+0.0109393 e^{-8 i \pi t}+0.0109393 e^{8 i \pi t}+0.00486189 e^{-12 i \pi t}+0.00486189 e^{12 i \pi t}\$.

It takes me a little work to get Mathematica to display those coefficients in order (i.e. the coefficient of $E^{-12 i \pi t} \$ followed by the coefficient of $E^{-8 i \pi t}\$, and so on). but when I have them, the ordered list is:

{0.00486189, 0, 0.0109393, 0.0509144, 0.114557, 0.175028, 0.2,
0.175028, 0.114557, 0.0509144, 0.0109393, 0, 0.00486189}

so there we have the 13 fourier series coefficients for the first several powers of $e^{2 i n \pi t}\$, where “several” is n = -6 to 6.

I observe that the missing term $Cos[10 \pi t]\$ in the Fourier series corresponds to a sample value of… 0.

Hit that drum again, maestro, while I repeat myself. Those 13 coefficients are exactly the 13 samples of the fourier transform.

I am not quite done. What we have is a fascinating observation. The Fourier series coefficients are samples of the Fourier transform.

But why?

Consider that we have two different functions of time: the triangle and the (truncated) Fourier series.

Maybe we should find the Fourier transform of the Fourier series instead of the Fourier transform of the single triangle.

Recall the truncated fourier series

$fs(t) = 0.350056 \cos (2 \pi t)+0.229115 \cos (4 \pi t)+0.101829 \cos (6 \pi t)+0.0218785 \cos (8 \pi t)+0.00972378 \cos (12 \pi t)+0.2\$.

Ask for its fourier transform and get

$FS(s) = 0.00486189\ \delta (s-6)+0.0109393\ \delta (s-4)+0.0509144\ \delta (s-3)+0.114557\ \delta (s-2)+0.175028\ \delta (s-1)+ 0.2\ \delta (s)+0.175028\ \delta (s+1)+0.114557\ \delta (s+2)+0.0509144\ \delta (s+3)+0.0109393\ \delta(s+4)+0.00486189\ \delta (s+6)\$.

We see two things. One, Dirac deltas at the integers. This tells us that the Fourier transform of the Fourier series is discrete not continuous. Two, the coefficients in front of the Dirac deltas are precisely the coefficients in the Fourier series. This is why the coefficients of the Fourier series match the samples — because the samples are the Fourier transform of the Fourier series.

• we have a continuous Fourier transform for the triangular pulse,
• we have a discrete Fourier transform for the (periodic) Fourier series associated with the triangular pulse,
• and that discrete Fourier transform consists of samples of the continuous Fourier transform.

I’m not sure that a drawing of the Fourier transform of the Fourier series will be convincing. After all, the easiest way to draw it is to plot the samples of the continuous Fourier transform! Those red dots on the picture, by themselves, are the Fourier transform of the Fourier series.

Maybe it’s okay to ask and emphasize: why are the two Fourier transforms not the same? Because we’ve taken Fourier transforms of two different functions. The (infinite) Fourier series is not equal to the triangular pulse (nor is the finite approximation); the series and the finite approximation correspond to a periodic extension of the triangular pulse, and an approximation of that periodic extension. In our first math class about Fourier series we ignored that difference, and focused on one period of the periodic extension; the Fourier transform shows us that we sometimes need to honor the difference between a non-periodic function and a periodic extension of it.

That it works out exactly depends on the Fourier transform of a cosine being precisely a (pair of) Dirac delta(s). If there’s a proportionality constant there, then we’ll be off by that constant factor. Similarly, that the samples were at the integers just required that we be taking the fourier transform of, e.g. $Cos[2 \pi t]\$ rather than of Cos[t].

This may be why this example is so hard to find. You will discover that most of your books use a different form of the Fourier transform (different choices of the FourierParameters).

Let me state my Fourier transform pair explicitly. I used the Mathematica option FourierParameters -> $\{0, -2 \pi\}\$. Then the Fourier transform F(s) of a function f(t) is

and the inverse Fourier transform recovers f(t) from F(s):

Oh, there’s one other convention to be aware of, the definition of the sinc function.

Mathematica is using

sinc(x) = (sin x)/x,

and Bracewell is using

$sinc(x) = (sin\ (\pi\ x))/(\pi\ x)\$ .

Where Bracewell wrote (for the transform of a triangle of half-width 1/10)

$\frac{1}{10}\ sinc^2(s/10)\$,

I would have needed to write

$1/10 sinc^2((\pi s)/10) = 1/10 sin^2((\pi s)/10) / (\pi s/10)^2\$.

(In fact, I arranged to use a triangle of half-width 1/5, instead.)

Let me close with a Mathematica detail. If you attempt to confirm either of those transform integrals directly, you should define a function using “set-delayed”, i.e. “:=”, instead of “=”. There’s a parameter inside each of those integrals, and you want to evaluate the integral first, then the parameter. That is, for example, if we write the inverse transform as… then we get…

and in particular, f1[0] = 1/2, which is wrong.