Home :: Articles :: Fourier Primer

Fourier Primer

Ivan Papusha

July 31, 2007

Abstract

Why does the Fourier transform show us the frequency components of a signal? The fundamentals lie in a more basic construct called the Fourier series. Traditionally used for periodic functions, they can be extended into arbitrary domains to give us an honest representation of any (“nice” enough) function. Theorems in linear algebra tell us why that can be done. A few definitions later, and the Fourier transform is born. This article does not attempt to explain discrete Fourier methods (such as the discrete and discrete-time Fourier transforms), because to maintain the rigor of this article I would need to provide a thorough introduction to signal processing. This topic has been overdone anyway. Instead, the article takes a more intuitive, mathematical approach, which may not appear in your favorite book on digital signal processing.

This article grew out of a series of shorter articles on the Fourier series and transform I wrote while in high school. Those, in turn, can be attributed to articles in Mathworld, Wikipedia, and chapters in Lay’s Linear Algebra, Karniadakis et al.’s Parallel Scientific Computing in C++ and MPI, as well as other similar publications. They were originally written for myself, but eventually became something I could share with my microelectronics classmates. Over the summer between high school and college, I compiled them into this article, hoping that it would help others, particularly in engineering, use and, most importantly, understand the mechanics of all things Fourier. It should be accessible to a first-year calculus student, although parts rely on techniques of linear algebra.

This article is also available as a pdf.

Contents

1 Fourier Series
 1.1 Fourier Series on a Specific Domain
  1.1.1 Definition
  1.1.2 Verification
  1.1.3 Derivation
  1.1.4 Example
 1.2 Fourier Series on a General Domain
  1.2.1 Definition
  1.2.2 Example
2 Fourier Transform
 2.1 Definition
 2.2 Example and Discussion

1 Fourier Series

1.1 Fourier Series on a Specific Domain

1.1.1 Definition

If we have an integrable1 function f(θ) that is defined2 everywhere on θ ∈[-π, π], then it can be expressed3 as

       1     ∞
f(θ) = 2a0+ ∑  [ancos(nθ)+ bnsin(n θ)]
            n=1
(1)

over this domain, where the coefficients an and bn are

       ∫ π
an = 1-    f(θ)cos(nθ)dθ
     π  -π
(2)

       ∫ π
bn = 1-    f(θ) sin(nθ)dθ
     π  -π
(3)
1.1.2 Verification

To see why the definition is true, let’s substitute (1) into (2) and evaluate the right side to see if we come up with an:

       ∫  (                              )
     1-  π  1     ∞
an = π  -π  2a0 +n∑= 1[ancos(nθ)+ bnsin(nθ)]  cos(nθ)dθ
(4)

To “do” the tough trigonometric integral (4), it’s easier to first investigate the properties of the simpler family of integrals

( ∫ π
||{     cos(kθ)cos(nθ)dθ
  ∫-ππ
||(     sin(kθ)sin(nθ)dθ
   -π
(5)

where k and n are integers (k, n ∈Z). In particular, we need to convince ourselves that both vanish to zero if kn or if k or n are zero4, and are equal to π if k = n, i.e. that

∫                    ∫                    {
  π                    π                    0,    k orn = 0
 -π cos(kθ)cos(nθ)dθ = - πsin (kθ)sin(nθ)dθ =   πδk,n, otherwise
(6)

where δk,n is the Kronecker delta. We will do the first definite integral in (5) under these conditions here, and leave the second to the reader as an exercise.

First, if k is zero, then the integrand is an even sinusoidal periodic (cosine) function with period 2π/n, which is being integrated over the domain θ ∈[-π, π]. This domain contains exactly π-(-π)
 2π/n = n periods of the cosine function. As such, the area over n periods is always zero. A similar situation holds for n = 0. Figure 1 shows plots of representative such cosine functions.


PIC

Figure 1: Plot of the functions sin(θ) and sin(3θ). The domain θ ∈[-π, π] contains 1 and 3 periods of the respective sinusoid. The total signed area under each over this domain is zero.


The general anti derivative

∫
   cos(kθ)cos(nθ) = sin[(k--n-)θ] + sin[(k+-n)θ]
                    2(k- n)       2(k + n)

this means that

∫ π                     [sin[(k- n)θ]  sin[(k+ n )θ]]θ=π
   cos(kθ)cos(n θ)dθ  =    --2(k--n)--+ --2(k+-n)--
 -π                                               θ=-π
                    =   sin[(k--n)π]+-sin[(k--n)π-]+ sin-[(k+-n)π]+-sin[(k-+-n)θ]
                                 2(k - n)                    2(k + n)
                        sin[(k--n)π]-  sin[(k+-n)π]-
                    =      k -n     +    k+ n
Whether or not k = n, the second term is automatically zero, because the argument to the sine function is an integer multiple of π. If kn, then the first term also vanishes for the same reason. But if k = n, then we have a 00 indeterminate form, which we will correct by using the rule of my good friend G. de l’Hôpital5:
    [           ]      [               ]
     sin[(k--n)π]-       --π-cos[(k--n)π]
lnim→k     k- n      = lnim→k       - 1        = π cos0 = π □

Returning to (4), we expand and distribute to get the integral

      ∫ π (             ∞                                  )
an =-1      1a cos(nθ)+   [a cos(kθ) cos(nθ)+ b sin(kθ)cos(nθ)] dθ
    π  - π  2 0         ∑k= 1 k                k
(7)

In the case n = 0, (7) becomes

            ∫   (                            )
          1-  π  1     ∞
an=0  =   π  -π  2a0 + ∑k=1[akcos(kθ)+ bksin(kθ)]  dθ
            ∫            ∫   ( ∞                     )
      =   1-  π 1a dθ+ 1-  π     [a co s(kθ)+ b sin (kθ)]  dθ
          π  -π 2 0    π  -π  k∑=1  k         k
              1  ∞ (∫ π             ∫ π           )
      =   a0+ --∑       akcos(kθ)dθ+     bksin(kθ)dθ
              π k=1  -π               -π
      =   a0
In the case n 1, (7) becomes

            ∫ π               ∫ π ( ∞                                  )
an≥1  =   1-    1cos(nθ)dθ + 1-     ∑  [akcos(kθ)cos(n θ) + bksin(kθ)cos(n θ)]  dθ
          π  -π 2           π  -π  k=1
             1  ∞ (∫ π                    ∫ π                )
      =  0 + π-∑       akcos(kθ) cos(nθ)dθ+     bksin(kθ)cos(nθ)
               k=1  - π                    -π
The first term in the sum we have already computed in (6). Thus, -ππakcos() cos()= akπ for k = n, and zero otherwise. Convince yourself that the second term in the sum -ππbksin() cos() = 0 for all k, n ∈Z. This leaves us with

               (∫                    )
          1-∞     π
an≥1  =   π ∑k= 1  -π akcos(kθ)cos(nθ)dθ
          1
      =   -anπ = an □
          π

By similar labor, we can substitute (1) into (3) to complete our verification of the Fourier series.

1.1.3 Derivation

Here we employ concepts from linear algebra to derive a formula for the Fourier series. By computing (6), we showed that for {n | n ∈ Z,n ≥ 1}, the subset

S = {1,cos(θ),cos(2θ),...,cos(nθ),sin(θ),sin(2θ),...,sin(nθ)}

of sinusoids in C[-π, π] (the vector space of all continuous functions on the domain θ ∈[-π, π]) is orthogonal with respect to the inner product

            ∫ π
⟨f(θ),g(θ)⟩ ≡    f(θ)g(θ)dθ
             -π

that is, every member of S is orthogonal to every other member, except itself. We can therefore enforce an orthogonal coordinate system on a subset W = Span {S } of C[-π, π] using S as a spanning set. All that remains is to find the corresponding weights on each basis function such that a generic function f(θ) ∈C[-π, π] is approximated as closely as possible in W-space. This will give us an arbitrary approximation to f(θ) using elements of S. Then, to extend this to an exact representation of f(θ), we need to increase the dimensionality of W to (by letting n →∞), showing that the approximation error 0. This is equivalent to the statement W C[-π, π] as n →∞.

First, we will find the weights for a finite n. Since S is orthogonal, the best approximation to f(θ) using S as the spanning set is the orthogonal projection of f(θ) onto W. The standard formula for orthogonal projections shows that the coefficients for k 1

         ⟨f(θ),cos(kθ)⟩
ak  =   ---------------
        ⟨cos(kθ),cos(kθ)⟩
bk  =   -⟨f(θ),sin-(kθ)⟩--
        ⟨sin(kθ),sin(kθ)⟩
By “doing” the inner products, we get the familiar results

         ∫ π
ak  =  1-    f(θ)cos(kθ)dθ
       π ∫-π
b   =  1-  π f(θ)sin(kθ)dθ
 k     π  -π
which are equivalent to (2) and (3). The coefficient of the element 1 of S is
          ∫
⟨f(θ),1⟩-  --ππf(θ)⋅1dθ   -1-∫ π         1 [1-∫ π              ]   1
  ⟨1,1⟩  =   ∫π 1 ⋅1dθ  = 2π  -π f(θ)dθ = 2  π  -π f(θ) cos(0⋅θ)dθ  = 2a0
             -π

Thus, the nth approximation fn(θ) to f(θ) is

fn(θ)  =  1 a0⋅1+ a1⋅cos(1⋅θ)+ ⋅⋅⋅+ an⋅cos(n θ)+ b1⋅sin(1⋅θ)+ ⋅⋅⋅+ bn⋅sin(nθ)
          2
          1      n
       =  2 a0+ ∑k= 1[akcos(kθ)+ bksin(kθ)]                                         (8)

The error Δn of this approximation can be quantified in Euclidean-like terms as the norm of the difference between the approximation fn(θ) and f(θ):

                      ∘ ------------------------
Δn  =  ∥fn(θ)- f(θ)∥ =  ⟨fn(θ)- f(θ),fn(θ)- f(θ)⟩
       ┌ ---------------------------------------------
       ││ ∫ π ( 1     n                           )2
    =  ∘       -a0+ ∑  [akco s(kθ)+ bksin(kθ)]- f(θ)  dθ
          - π  2    k=1
The square of this error (Δn2) is termed the mean-square error. The direct computation of this Lebesgue integral is difficult without employing some high-power theorems. You now have my permission to choose one of a couple options:

  1. Chant whatever magic you like, so long as you conclude that lim n→∞Δn2 = 0. Actually “doing” this limit is, of course, left as an exercise to the reader.
  2. Change the little n at the top of the little sign in the partial sum equation (8) to and don’t tell anyone that you cheated.
  3. Employ your “get out of proof free” card6.

By convincing ourselves that the limit of the mean-square error as n →∞ is zero, we conclude that the set S is a complete orthogonal system over the domain θ ∈[-π, π], spanning the complete inner product space W. This has important ramifications in the study of Hilbert spaces, but for us it means that almost all functions f(θ) can be approximated exactly over our domain by an infinite Fourier series. Thus, we establish the relations (1), (2), and (3).

1.1.4 Example

Now that we’ve gained insight into the truth of the Fourier series, an example is in order. Let’s find the Fourier series representation of the periodic sawtooth function seen in Figure 2.


PIC

Figure 2: Sawtooth function


The function is periodic with period 2π, defined everywhere on θ ∈[-π, π], of bounded variation – the whole nine yards. It is a simple one with which to start, because it does not require a change of variables to extend the domain over which the function is periodic. In the domain θ ∈[-π, π], the function f(θ) = 12θ. Beyond that, the function is periodic. Let’s compute the Fourier coefficients an and bn using (2) and (3):

        1 ∫ π                1 ∫ π 1
an  =   --   f (θ)cos(nθ)dθ = --    -θcos(nθ)dθ = 0
        π ∫-π                π∫ -π 2
b   =   1-  πf (θ)sin(nθ)dθ =-1  π 1 θsin(nθ)dθ = sin(nπ-)--nπ-cos(nπ-)
 n      π  -π               π  - π2                    n 2π
Since n is an integer, the expression for bn can be simplified to bn = (-1)nn+1. Note that we do not have to worry about the case n = 0, because the only Fourier coefficient that requires n = 0 is a0 according to (1), and we have already shown that an = 0 for all n. Now let’s substitute our expressions for the Fourier coefficients into (1) to get the Fourier series for f(θ).
       ∞  (-1)n+1-                1         1         1
f(θ) = ∑n= 1   n   sin(nθ) = sin(θ)- 2 sin(2θ)+ 3 sin(3θ)- 4 sin(4θ)+ ⋅⋅⋅ ■
(9)

Note that (9) consists only of sines, and that both f(θ) and sin(θ) are odd functions. This is not a coincidence, but rather a direct consequence of a Fourier expansion. Now let’s get an intuitive look at the convergence of (9) by truncating the series at 2, 5, and 10 terms (Figure 3).


PIC
(a) two terms
PIC
(b) five terms
PIC
(c) ten terms

Figure 3: Convergence of Fourier series for the periodic sawtooth function.


It appears that as the number of terms →∞, the Fourier series approaches the periodic function. Note how we only used the value of the function f(θ) = 12θ on the interval θ ∈[-π, π], and the series became periodic on the entire domain θ ∈[-∞, ]. This means that we only need information about one period of the function we are approximating to write the Fourier series for it. What happens when we have information about only half of a period? Easy. Make up the rest. Set it all to zero, or do what is called an “even” or “odd” extension by reflecting the function through the y-axis or the origin. Granted, the information you didn’t have doesn’t magically appear, but the part of the period you did have is faithfully reproduced in every period of the approximation. Try doing that with a Taylor series!

1.2 Fourier Series on a General Domain

1.2.1 Definition

In Section 1.1.4 , we found the Fourier series representation of a nice sawtooth function with a convenient period of 2π and defined over the specific domain θ ∈[-π, π]. But with a simple change of variables, we can extend (1), (2), and (3) to a generic function f(t) defined on the domain t ∈[t0 -T, t0 + T], where the new period is 2T, and the new center point is t0. This allows us to glean a Fourier series for an arbitrary-period function that was shifted laterally in any fashion. Let t = t0 + T-
πθ. Then dt = T-
π. With this substitution, the definitions become

         1     ∞ [     ( nπ       )       ( nπ       )]
f(t) =   2a0+  ∑  ancos  T--(t- t0) + bnsin  T-(t- t0)                (10)
           ∫  n=1
         1-  t0+T       ( nπ-      )
  an  =   T  t0-T  f(t)cos  T (t- t0) dt                                (11)
           ∫ t0+T       (         )
  bn  =   1-      f(t)sin n-π(t- t0)  dt                                (12)
         T  t0-T          T

1.2.2 Example

With the extended definition, let’s express the general square wave with period 2T depicted in Figure 4 as a Fourier series.


PIC

Figure 4: General square wave, with period 2T


Though we can set t0 = 0, evaluating (11) and (12) on the domain t ∈[-T, T], we’ll make our calculations more instructive by using the information on t ∈[0, 2T], thereby setting t0 = T. Since f(t) is odd, the even (cosine) coefficients are zero7, meaning an = 0. Here we define the single period of f(t) piecewise as

      {
        A,   0 ≤ t < T
f(t) =  -A , T ≤ t < 2T

where A is the amplitude. Substituting the relevant information into (12) to calculate bn, we get

        1 ∫ 2T       ( nπ      )
bn  =   T- 0  f(t)sin  T-(t- T)  dt
          (∫ T      (         )     ∫ 2T        (         )  )
    =   1-    (A) sin  nπ-(t- T ) dt+     (-A  )sin  nπ-(t -T ) dt
        T   0         T              T            T
        2A((-1)n -1)
    =   -----nπ------
Therefore,
       ∞ [2A ((-1)n- 1)   ( nπ      )]
f(t) = ∑  -----n-π-----sin  T-(t- T)   ■
      n=1


PIC

Figure 5: Convergence of Fourier series for a general square wave


Figure 5 shows how this series converges to the square wave. For a square wave with period 2π (that is, T = π) and amplitude π/4, the expansion for f(t) takes on a pattern that makes it easier to see that odd harmonics add to make a square wave:

             1         1
f(t) = sin(t)+ - sin(3t)+ - sin(5t) + ⋅⋅⋅
             3         5

2 Fourier Transform

2.1 Definition

A wonderful and accessible tutorial on the Fourier transform is available through Mathworld’s “Fourier Transform” page. Subscribing to Mathworld’s notation, we will define the forward (13) and inverse (14) Fourier transforms on the function f(x) as

                   ∫ ∞      -2πjkx
F(k)  ≡  Fx [f(x)] = -∞ f(x)e     dx                        (13)
                     ∫ ∞
f(x)  ≡  F -k1[F(k)] =    F (k)e2πjkxdk                        (14)
                      -∞
where j is the imaginary unit8. By virtue of this symmetric definition,
F -1[F[f(x)]] = f(x)
(15)

The property (15) is very important, because it allows us to analyze the same function in two equivalent forms.

By performing the forward Fourier transform on a signal as a function of time, we can view the signal as a function of frequency. Hence, we transform into the frequency domain. This point of view allows for recognition of its spectral structure – harmonics, noise components, beats – and results in frequency power data that can naturally be split into frequency channels.

By performing the inverse Fourier transform on the frequency data, we can transform back into the time domain.

2.2 Example and Discussion

To get a feel for the Fourier transform, let’s find Fx[ -x2]
 e, since (13) is easily computed for this function. Using -∞e-x2 dx = √ --
  π, you should see that Fx[   ]
 e-x2= F(k) = e-k2π2 √--
 π. Then, by substituting F(k) back into (14), we get Fk-1[F(k)] = e-x2 , showing (but not proving) that, in fact, F-1[F[f(x)]] = f(x).

But what if we wanted to take the Fourier transform of a function like f(x) = cos(2πk0x)? It appears that (13) does not converge. In particular, -∞e-2πjkxdx does not appear to converge.

To solve this problem, we have to use a little complex arithmetic and the Dirac delta function δ(x), which turns out to be

       {
δ(x) =  ∞ , x = 0
        0,  otherwise

in such a way, that

∫ ∞
    δ(x)dx = 1
 -∞
(16)

It is easier to think of δ(x) as a limit of a sequence of vanishingly thin, normalized Gaussian functions, rather than a true function. However, it can also be thought of as a limit of a sequence of vanishingly thin, scaled “sinc” functions, or any such sequence termed a “delta sequence,” so long as the normalization condition (16) holds (Figure 6).


PIC
(a) gaussians
PIC
(b) sin(xx)-like

Figure 6: Dirac delta function δ(x) can be thought of as a limit of a sequence of a certain class of vanishingly thin, unity-area functions.


By convention, a Dirac delta function is drawn as a vertical arrow (Figure 7) emanating from the origin and ending at 1 (representing its area), even though at zero, the value of the delta function is . This way, when the Dirac function is multiplied by a constant, this constant can be easily inferred from the point at which the arrow representing the function ends.


PIC

Figure 7: Conventional representation of δ(x) as an arrow


A vital property of the Dirac delta function is

∫ ∞
    δ(x- x0)g(x)dx = g(x0)
 -∞
(17)

In this sense, the Dirac delta function is known as an impulse, or sampling function, because it defines the mathematical notion of sampling a function g(x) at x0 in terms of convolutions9. In fact, (17) is central to the formulation of Nyquist’s sampling theorem. With that said, let’s compute F-1[δ(k)]:

∫
  ∞      2πjkx     2πj(0)x
 - ∞δ(k)e   dk = e     =  1

by using x0 = 0 and x = k in (17). The above calculation tells us that F-1[δ(k)] = 1. More importantly, because of the symmetry of the Fourier transform (15), it tells us that F[        ]
 F- 1[δ(k)]= F[1] = δ(k). This means that we can define

       ∫ ∞
Fx[1] =    (1)e-2πjkxdx ≡ δ(k)
        -∞

and therefore be able to “do” the integral -∞e-2πjkxdx wherever it appears10. Using this new found knowledge, we can perform Fx[cos(2πk0x)], using cos(u) = (eju + e-ju)/2. Substituting for f(x), it now becomes easy to see that Fx[cos(2πk0x)] = 1
2[δ(k-k0) + δ(k+ k0)].


PIC

Figure 8: The general cosine function and its Fourier transform


But what does this mean? According to a plot of our result (Figure 8), the Fourier transform of a cosine function of frequency k0 is a sum of two Dirac delta functions each centered at either of ±k0, and normalized in such a way that the integral of the sum is 1. It tells us that there is a positive and a negative frequency component to our cosine function, and both components have the same magnitude. Notice how the arrows end at 1/2, rather than at 1, signifying that even though the value of the Fourier transform at ±k0 is technically , not all infinities are created equal.

Similar to the pattern seen in Fourier series, the plot of the Fourier transform of a function is even for an even function and odd for an odd function. Try doing a Fourier transform of f(x) = sin(2πk0x), which is an odd function, to see what is meant.

It is important to note that the Fourier transform does not (generally) produce results that are immediately useful in digital signal processing. For example, there is no easy way to physically interpret negative frequencies or imaginary powers. This is why in actual signal analysis, magnitudes are generally used. That is, when the Fourier transform of a signal says that the relative power of the frequency 2.1 (frequency units) is (2.73 -3.2j)δ (power units), we generally simplify that to ∘ -------------
  (2.73)2+ (3.2)2 (power units)11. But as soon as we take the magnitude of a frequency or power, we lose the imaginary and negative information of the Fourier transform that is crucial in reconstructing the original signal with the inverse Fourier transform. For example, a sine and a cosine wave of the same frequency have different exact Fourier transforms, but the same magnitudes and powers. Clearly, a sine and a cosine are different signals, even if they have the same amplitude and frequency. Therefore, any method that does not keep track of exact values, with all the requisite δ’s and imaginary components, is inherently lossy, and property (15) cannot be true. There are methods of correcting or even finessing this issue, but that is in the realm of signal processing.

Footnotes

1One of the consequences of this criterion is that the function must be of bounded variation, or having a finite number of extrema; e.g. f(θ) = sin(1/θ) would not satisfy this condition because it has an infinite number of extrema on this domain

2perhaps in a piecewise fashion

3exactly if the function is “nice” enough, or almost exactly if it is not

4We neglect the case where both k and n are zero, because this will not happen in the sum. If we didn’t, the two integrals in (5) would differ.

5which was really the rule of my other good friend J. Bernoulli which he wanted to steal back from the first friend, who filched the rule fair and square in the first place from the second friend, who really shouldn’t have taken it so close to heart because his son will have had a rule (principle) named after himself, which is oh so close to the second friend’s name that it might seem he was its inventor anyway.

6based loosely on a special card Dr. Dell claims to have

7Check if you don’t believe me

8Don’t let that bother you too much

9See your favorite book on digital signal processing

10This is a consequence of the convention that we really define the inverse Fourier transform of the delta function as one (F-1[δ(k)] 1), because one could just as easily have computed the forward Fourier transform and gotten the same answer (F[δ(x)] = -∞δ(x)e-2πjkxdx = e-2πjk(0) = 1) and defined F[δ(x)] 1. These conventions are not mutually compatible, and it is not true that the forward and inverse Fourier transforms of the delta function are the same (F[δ(x)]F-1[δ(k)]). The delta function is a finicky creature, because it is defined in terms of its properties (such as (16) and (17)), rather than in a traditional input-output way. This is why property (15) is so important.

11Notice that exact representations with all the requisite δ’s in place are used in this article. I again defer you to a book on signal processing to learn about sampling, quantization, and fast implementations of the Fourier transform.

 

References

[1]   Wolfram Mathworld (www.mathworld.com) articles on “Fourier Transform,” “Generalized Fourier Series,” “Orthogonal Functions,” “Hilbert Space,” “Fourier Transform - Sine,” and others.

[2]   Wikipedia (www.wikipedia.org) articles “Fourier Series,” “Fourier Transform,” and others.

[3]   Karniadakis, G.E., Kirby, R.M. II. Parallel Scientific Computing in C++ and MPI. Cambridge University Press. Chapters on “Polynomial Approximation” and “Fourier Series Representation”.

[4]   Lay, D.C. Linear Algebra and its Applications. Chapter on “Fourier Series”.

[5]   Vandevenne, L. Computer Graphics Tutorial. “Fourier Transform.”
(http://student.kuleuven.be/~m0216922/CG/fourier.html).

Contents copyright (c) 2006-2008 by Ivan Papusha. Last modified: August 20, 2008. Hosted at 000webhost.