Fourier Series and the Fourier Transform

— Why trigonometric functions form an “orthogonal basis,” and why differential equations can be solved by division (for first-year undergraduates)

The Fourier series is one of the tools that physicists use most often. First-principles calculations expand wave functions in plane waves (that is, trigonometric functions), and the heat conduction equation and the wave equation can be solved by writing the solution as a superposition of waves. In lectures, though, only the formula “the coefficient is this” tends to appear out of nowhere, and why that formula extracts the coefficients is often left behind.

This document starts from the inner product of vectors. If you understand the a→·b→ you learned in high school, you will not stumble anywhere along the way, all the way to Thomas–Fermi screening at the end.

Outline of this document ① The components of a vector come out when you take the inner product with the basis vectors. The other components vanish on their own, “because they are orthogonal.”
② For functions, too, we define an inner product ⟨f,g⟩=∫fgdx.
③ It then turns out that trigonometric functions with different wavenumbers are orthogonal to one another. So the coefficients can be extracted by the same trick.
④ Differentiation becomes just multiplication by ik. So differential equations can be solved by division.
⑤ A worked example is Thomas–Fermi screening.

1. First, How to Extract the Components of a Vector

Consider the unit vectors e1,e2,e3 in three dimensions. They have the following property:

(1) ei·ej={1(i = j)0(i ≠ j)}

This property is called being orthonormal. “Normal” means that the length is 1, and “orthogonal” means that they are at 90° to one another. Now, when we write a certain vector as v=v1e1+v2e2+v3e3, suppose that we want to extract only the first component v1. What would you do?

You just take the inner product with e1.

(2) v·e1=v1⏟e1·e1=1+v2⏟e2·e1=0+v3⏟e3·e1=0=v1
This is the starting point of everything Thanks to orthogonality, only the component you want survives, and all the others become 0 and vanish. The whole point of “expanding in a basis” rests on this single fact.

What the Fourier series does is exactly this, not a hair’s breadth different. The only difference is that “vectors” become “functions” and “inner products” become “integrals.” Below, we will check this one step at a time.

2. Defining the “Inner Product” of Functions

The inner product of vectors was “multiply the components pairwise and add them all up.”

(3) a→·b→=∑i=1Naibi

What about functions? Divide the interval [a,b] into N equal parts and line up the values at each point. f→(f(x1),f(x2),…) — this is itself an N-dimensional vector. So the inner product is ∑if(xi)g(xi). Now we let N → ∞, but if we keep adding like this, the number of terms grows without bound. So we first multiply by the step width Δx=b−aN and then take the limit. This is the Riemann-sum method, and ∑if(xi)g(xi)Δx turns into an integral, giving

(4) ⟨f(x),g(x)⟩=∫abf(x)g(x)dx

This is the inner product of functions (lecture notes (6)). The length (norm) is defined in exactly the same way as for vectors.

(5) ‖f(x)‖=⟨f,f⟩=∫ab{f(x)}2dx
Functions are vectors This is the first hurdle, but what it says is simple. Think of a function as “a vector whose components are the values at each point, infinitely many of them.” Once you think of it this way, the inner product, the length, and the angle can all be carried over as they are. The remark in the lecture notes, “The inner product and the norm are similar to those of vectors!”, says exactly this.

By the way, the Schwarz inequality |⟨f,g⟩|≤‖f‖‖g‖ is also just the vector inequality |a→·b→|≤|a→||b→| carried over unchanged.

3. Actually Computing the Inner Products of Trigonometric Functions

We take the interval to be −π<x≤π. Let us follow the calculations of lecture notes (1)–(5) one by one. The only tools we use are the product-to-sum formulas and the half-angle formulas.

(a) The integral of a single wave

(6) ∫−ππsin⁡mxdx={−1mcos⁡mx}|x=−πx=π=−1mcos⁡mπ+1mcos⁡mπ=0

We only used cos⁡(−mπ)=cos⁡mπ. Similarly, ∫−ππcos⁡mxdx=0 (when m≠0). A wave swings equally far up and down, so adding up one full period gives 0 — that is all there is to it.

(b) The product of sin and cos

Using the product-to-sum formula sin⁡mxcos⁡nx=12{sin⁡(m+n)x+sin⁡(m−n)x}, both terms on the right-hand side are of the form in (a), so

(7) ∫−ππsin⁡mxcos⁡nxdx=0(for any integers m, n)
A faster way to see it sin⁡mx is an odd function, and cos⁡nx is an even function. Odd × even = odd, so integrating over an interval symmetric about the origin always gives 0. This is the “alternative proof” in the lecture notes. You can see it without any calculation.

(c) Products of cos with cos, and of sin with sin

Only here does the story depend on whether m=n. First, the case m≠n. Converting the product into a sum gives cos⁡mxcos⁡nx=12{cos⁡(m+n)x+cos⁡(m−n)x}. Since m±n are both nonzero integers, both terms are 0 by (a).

But when m=n, m−n=0, and therefore cos⁡0=1 — the result is not 0. Written with the half-angle formula,

(8) ∫−ππcos2⁡mxdx=∫−ππ1+cos⁡2mx2dx =12∫−ππ1dx+12∫−ππcos⁡2mxdx⏟= 0 (by (a))=12·2π=π

For sin⁡mx as well, it is exactly the same, using sin2⁡mx=1−cos⁡2mx2. To summarize:

(9) ∫−ππcos⁡mxcos⁡nxdx={π(m = n ≠ 0)0(m ≠ n)} ∫−ππsin⁡mxsin⁡nxdx={π(m = n ≠ 0)0(m ≠ n)}
Compare this with ei·ej in (1) The form is exactly the same. The only difference is that the value when the inner product is nonzero is π rather than 1. In other words, the trigonometric functions turned out to be “an orthogonal basis of length π.”

Note that for m=0 we have cos⁡0=1, and ∫−ππ1·1dx=2π. This one function alone has length 2π, unlike the others. This is the reason why only a0 gets the factor 1/2π later. (Since there is nothing left in sin⁡0=0, it is not counted as a basis function.)

4. So Trigonometric Functions Form an Orthogonal Basis

Let us look at the example in lecture notes (8) just as it is.

(10) y=∑k=13sin⁡(2k−1)x2k−1=sin⁡x+13sin⁡3x+15sin⁡5x

By (9), these three functions are mutually orthogonal.

⟨·, sin x⟩⟨·, sin 3x⟩⟨·, sin 5x⟩
sin xπ00
sin 3x0π0
sin 5x00π

So if we regard these three functions as axes, then e1=sin⁡x,e2=sin⁡3x,e3=sin⁡5x, y=e1+13e2+15e3. This has exactly the same structure as the three-dimensional vector Y=[1,13,15]. This is what Fig. 1.1 of the lecture notes depicted.

If the wavenumbers differ, the functions are orthogonal Trigonometric functions with different wavenumbers point at 90° to one another. So they do not mix when added together, and you can pull them out one at a time afterward. The only difference is that there are infinitely many axes — sin⁡x, sin⁡2x, sin⁡3x, … and so on without end. They span an infinite-dimensional orthogonal coordinate system.

5. Extracting the Coefficients — The Same Trick as in (2)

From here on, it is a straight road. Suppose a function of period 2π can be written as

(11) f(x)=∑k=0∞(akcos⁡kx+bksin⁡kx)

Suppose this holds. We want to extract only am. Just as in (2), we take the inner product with cos⁡mx. That is, we multiply both sides by cos⁡mx and integrate from −π to π.

(12) ∫−ππf(x)cos⁡mxdx=∑k=0∞ak∫−ππcos⁡kxcos⁡mxdx+∑k=0∞bk∫−ππsin⁡kxcos⁡mxdx =am·π+0=πam

The second term is always 0 by (7) (here we take m≥1; m=0 differs only in the length of its basis function, so it is written separately just below). The first term, too, is 0 by (9) for every term except the single one with k=m. Only the component we want has survived. Therefore

(13) am=1π∫−ππf(x)cos⁡mxdxbm=1π∫−ππf(x)sin⁡mxdx a0=12π∫−ππf(x)dx
Why is only a0 given a factor 1/2π? The basis function for k=0 is cos⁡0x=1, a “flat function.” The square of its length is ∫−ππ1·1dx=2π, which is 2π rather than the π of the other basis functions. The divisor is the square of the length, so only a0 gets the factor 1/2π. It is not a special rule; it is simply that this one function has a different length.

Incidentally, a0 is precisely the average height of f(x). Some textbooks write a0/2, but the content is the same.

Fig. 1: Where the coefficients get “extracted.” The upper panel shows f(x) and cos mx (or sin mx), and the lower panel shows their product. The area of the product (the green minus the red) is exactly π am (π bm if you choose sin, and 2π a0 when m = 0). Try changing m. For most values of m, the green and red cancel to give 0, and a value remains only for the m that actually has something in it — this is exactly the calculation in (12).

6. ak and bk Are Weights for Each “Number of Waves”

cos⁡kx is a wave that oscillates exactly k times over 0≤x<2π. In terms of wavelength, λ=2πk.

kNumber of waves in 2πWavelength λStructure it is responsible for
00 (flat)—Average height of f
11 wave2πThe roughest overall shape
22 wavesπLeft–right asymmetry, etc.
1010 wavesπ/5Fine undulations
100100 wavesπ/50Very fine structure such as corners and jumps
So the “spectrum” tells you the character of a function A function whose coefficients remain large even for large k has fine structure. Conversely, for a smooth function the coefficients become small quickly as k increases.

In fact, how fast the coefficients fall off is determined by smoothness. With a jump, ak∼1/k; with a corner (the first derivative jumps), ak∼1/k2; and for a function that can be differentiated any number of times, they fall off faster than any power (exponentially, for an analytic function). On tab ① of the simulator, compare the spectra of the square wave (jump) and the triangle wave (corner).
Next to a jump, the error never goes away — the Gibbs phenomenon However, the coefficients getting smaller is one thing, and the sum of the waves fitting the function cleanly is another. For a function with a jump, such as the square wave or the sawtooth wave, no matter how much you increase N, an overshoot remains right next to the jump. The width of the overshoot narrows as N grows, yet its height stays at about 8.95 % of the jump and does not decrease. This is the Gibbs phenomenon.

The partial sums approach f(x) at every point except the jump itself (pointwise convergence). The overshoot nonetheless does not disappear because the way the sums approach it is not uniform from place to place — that is, because the convergence is not uniform. On tab ① of the simulator, choose the square wave and, raising N from 10 to 30 to 60, watch only the region right at the jump. The peak becomes narrower, but its height does not shrink.
The “cutoff energy” in first-principles calculations In plane-wave basis calculations, the wave function is expressed as a superposition of eik·r, and the wavenumbers that satisfy ℏ2k22m<Ecut are used. Raising the cutoff means using finer waves. The wave function changes sharply right next to an atomic nucleus, so fine waves are needed to represent it. The reason a pseudopotential is a tool that “smooths out the region near the nucleus” is to make the coefficients fall off faster and reduce the number of waves needed.
Splitting does not lose the “length” — Parseval’s identity Since we have only split things into orthogonal axes, the length defined in (5) can also be counted on the coefficient side. ⟨f,f⟩=2πa02+π∑k≥1(ak2+bk2) — this is Parseval’s identity. In three dimensions, we had |v|2=v12+v22+v32 and this is exactly the same thing. The difference between π and 2π is exactly the difference in basis-function length that we saw in (9).

The square of a coefficient can be read as that mode’s “share.” Tab ① of the simulator shows “Parseval sum” and “‖f‖² (true value)” side by side, so you can follow, in numbers, the former approaching the latter as you increase N.

7. To Period 2L, and to the Complex Form

When the period is 2L rather than 2π, you only need to substitute t=πLx (lecture notes (12)).

(14) f(x)=∑k=0∞(akcos⁡kπLx+bksin⁡kπLx) ak=1L∫−LLf(x)cos⁡kπLxdxbk=1L∫−LLf(x)sin⁡kπLxdx(k≥1) a0=12L∫−LLf(x)dx

Next, using Euler’s formula eiθ=cos⁡θ+isin⁡θ, we combine cos and sin. For k≥1, set ck=ak−ibk2 and c−k=ak+ibk2. For k=0, set c0=a0. With this choice,

(15) f(x)=∑k=−∞∞ckeikπLx ck=12L∫−LLf(x)e−ikπLxdx
Why go to complex numbers? The two separate pieces, cos and sin, are combined into one. In exchange, k now runs over negative values as well, but the formulas become much easier to read. And as we will see in the next section, the greatest advantage is that differentiation takes a clean form. For a real function, c−k=ck∗, so no information is lost.

8. The Fourier Transform — Making the Period Infinitely Large

Let us take L → ∞ in (15). The wavenumber used to take the discrete values k→kπL, but its spacing Δk=πL approaches 0, so k becomes a continuous variable, and the sum becomes an integral. Writing only the result,

(16) F(k)=∫−∞∞f(x)e−ikxdx f(x)=12π∫−∞∞F(k)eikxdk

The upper one is the Fourier transform, and the lower one is the inverse Fourier transform. What we are doing is exactly the same as in (13) — we take the inner product with e−ikx to extract the component of wavenumber k, nothing more.

Now for the main point: differentiation becomes multiplication

What happens when we differentiate eikx with respect to x?

(17) ddxeikx=ikeikx d2dx2eikx=−k2eikx

The form does not change; it is merely multiplied by a single number. So in the world after the Fourier transform,

(18) f′⟶ikF(k)f″⟶−k2F(k)∇2⟶−k2
The most familiar examples — the heat conduction equation and the wave equation If we first split the initial shape into waves as u(x,t)=∑kuk(t)eikx, then by (17), ∂2∂x2 turns, for each mode, into −k2, an ordinary number.

Hence the heat conduction equation ∂u∂t=κ∂2u∂x2 separates, one wave at a time, into dukdt=−κk2uk a plain ordinary differential equation, and it is easily solved to give uk(t)=uk(0)e−κk2t. Because k2 appears in the exponent, the larger k is (the finer the wave), the faster the wave dies out. This is the reason why the bumps are smoothed out first, while only the rough overall shape decays slowly.

The procedure is the same for the wave equation ∂2u∂t2=c2∂2u∂x2, and we get d2ukdt2=−c2k2uk — the equation of simple harmonic motion. If we take the initial velocity to be 0, uk(t)=uk(0)cos⁡ckt, and this one does not die out but keeps going back and forth forever.

A partial differential equation splits into “separate ordinary differential equations, one for each wave” — this is what you are looking at on tab ③ of the simulator.
This is the greatest benefit of the Fourier transform A differential equation becomes a plain algebraic equation. Differentiation turns into “a number you can divide by,” so the task of “solving” becomes the task of “dividing.”

The procedure always has three steps. ① Fourier-transform, ② divide, ③ inverse-transform back to real space. In the next section, we will carry these three steps through to the end, once.

9. Thomas–Fermi Screening — The Three Steps Through to the End

(a) What are we considering?

Inside a metal, conduction electrons are packed like a sea. What happens if we drop a single point charge q into it?

In vacuum, the answer is the Coulomb potential φ=q/r. This is the solution of the Poisson equation

(19) ∇2φ=−4πqδ(r)

(in Gaussian units). Inside a metal, however, the surrounding electrons gather and try to cancel this charge. This is called screening.

(b) How many electrons gather?

If q>0, the potential energy of an electron near it is lowered by eφ (the electron’s charge is −e). That makes the spot “a good deal” energetically, so electrons gather there.

How many gather? In a metal, the Fermi level EF must be at the same height everywhere (otherwise electrons would flow). The bottom of the band has dropped by eφ while the Fermi level does not move, so that many more electrons are packed in. The number of added electrons is “the number of seats available per 1 eV” × “the amount of the drop,” that is,

(20) δn=N(EF)·eφ

Here N(EF) is the density of states (the number of states per unit volume per unit energy). Since each electron has charge −e, the added charge (the induced charge) is

(21) ρind=−e·δn=−e2N(EF)φ
Let us check the sign in plain words Place a positive charge (φ>0) → electrons gather → that region becomes negatively charged (ρind<0). This is why there is a minus sign on the right-hand side of (21). The response is in the direction that cancels the charge you placed — this is the substance of screening.

(c) Setting up the equation

The right-hand side of the Poisson equation must include all of the charge. That means both the point charge we placed and the electrons that have gathered.

(22) ∇2φ=−4π{qδ(r)+ρind}=−4πqδ(r)+4πe2N(EF)φ ∇2φ−kTF2φ=−4πqδ(r)

Here we have set kTF2≡4πe2N(EF). The lower equation in (22) is the equation to be solved. Only one term, −kTF2φ, has been added to the Poisson equation — but because φ appears on both sides, it cannot be solved as in the vacuum case.

(d) ① Take the Fourier transform

Now it is the Fourier transform’s turn. From (18), ∇2→−k2. Also, the Fourier transform of the delta function is ∫δ(r)e−ik·rd3r=1 — just 1. So (22) becomes

(23) −k2φ(k)−kTF2φ(k)=−4πq

There are no derivatives anywhere. It is just a linear equation.

(e) ② Divide

(24) φ(k)=4πqk2+kTF2
That is all there is to it The task of solving a partial differential equation ended with a single division. Setting kTF=0 (no screening) gives φ(k)=4πq/k2, which is the Fourier transform of the Coulomb potential q/r. kTF2 serves to stop the divergence at k → 0. “Not reaching far away” in real space corresponds to “not diverging at small k” in k-space.

(f) ③ Take the inverse transform and return to real space

φ(k) does not depend on the direction of k (it is a function of |k| only), so the angular integral can be done first. Using ∫dΩeik·r=4πsin⁡krkr,

(25) φ(r)=1(2π)3∫d3keik·rφ(k)=12π2r∫0∞ksin⁡krφ(k)dk

Now, using the integral formula ∫0∞ksin⁡krk2+a2dk=π2e−ar,

(26) φ(r)=12π2r·4πq·π2e−kTFr=qre−kTFr
For those who find the integral formula unsettling — let us verify by substituting the answer That (26) really satisfies (22) can be verified without knowing the formula. With spherical symmetry we have ∇2φ=1rd2dr2(rφ), so for r>0,
∇2φ=1rd2dr2(qe−kTFr)=1rqkTF2e−kTFr=kTF2φ.
That is, ∇2φ−kTF2φ=0 holds for r>0. And as r→0, e−kTFr → 1, so φ→q/r, that is, the behavior at the origin is the same as that of the bare Coulomb potential. From ∇2(1r)=−4πδ(r), the delta function on the right-hand side comes out exactly as well. This completes the proof.

10. Reading the Answer — How Long Is the Screening Length?

(26) is of the form called a Yukawa-type potential. 1/kTF is the screening length λ, and beyond this distance the potential decays exponentially.

For a free-electron gas, N(EF)=3n2EF, so substituting EF=ℏ2kF2/2m and n=kF3/3π2 gives

(27) kTF2=4kFπaBkFaB=(9π4)1/3rs=1.9192rs

Here rs is the radius per electron, measured in units of the Bohr radius. The smaller it is, the denser the electrons. To summarize, kTFaB=1.5632/rs.

MetalrskTF [1/aB]Screening length λ [aB]The same in Å
Al (aluminum)2.071.0860.9200.487
Mg (magnesium)2.660.9581.0430.552
Cu (copper)2.670.9571.0450.553
Na (sodium)3.930.7891.2680.671
K (potassium)4.860.7091.4100.746
0.5 Å — move away by as little as one atom, and the charge can no longer be seen The interatomic distance in a metal is 2–3 Å, so a screening length of 0.5 Å means that it does not even reach the neighboring atom.

That is why ions inside a metal do not exert long-range Coulomb forces on one another (all ions are positively charged, so the bare Coulomb force would be repulsive). The pictures “electrons in a metal can move around freely” and “ions behave like hard spheres” can be used thanks to this screening. Note, however, that screening removes only the long-range part; an interaction mediated by the electrons remains at short range. This is also why the cohesive energy and elasticity of metals have a character quite different from those of ionic crystals.
To be honest — Thomas–Fermi is an approximation In (21) we assumed that “the electron response is proportional to φ.” This tacitly assumes that φ varies slowly (a linear-response, long-wavelength approximation). If one does this more carefully (the Lindhard function), a subtle kink appears at k=2kF, and in real space a slowly decaying oscillation cos⁡2kFr/r3 remains. This is the Friedel oscillation, which can actually be seen with an STM. Even so, the conclusion that “the screening length is less than 1 Å, much shorter than the interatomic distance of 2–3 Å” does not change.

11. Another Application — Force Constants and Phonons

When we compute phonons (lattice vibrations) from first principles, too, a round trip between the Fourier transform and the inverse Fourier transform is used. This is exactly the calculation that the Mochizuki Research Group runs routinely.

How strongly the other atoms feel a force when one atom in a crystal is moved slightly is expressed by the force constants (in practice, the Hessian matrix). Explicitly, Φαβ(0κ,Rκ′)=∂2E∂uα∂uβ. The Fourier transform of these is the dynamical matrix, and

(28) Dαβ(q)=1MκMκ′∑RΦαβ(0κ,Rκ′)eiq·R Φαβ(R)=MκMκ′N∑qDαβ(q)e−iq·R

Diagonalizing this Dαβ(q) gives eigenvalues ω2 (in the diagonalization simulator, tab ③, you can see the case of two point masses).

Why “go and come back”? — Fourier interpolation In first-principles calculations, the q on a coarse mesh (for example, 4×4×4) are the only points at which D(q) can be computed, because the computational cost is too large.

So ① first take the inverse Fourier transform to get Φ(R) in real space. Force constants are smaller for more distant atoms, so the region where R is large can be ignored. In other words, a finite number of Φ(R) is enough.

② Now Fourier-transform that Φ(R) at any q you like, and you can construct D(q) even for a q that is not on the mesh. The reason the phonon dispersion curves can be drawn as smooth lines is this round trip. This is called Fourier interpolation.
The same idea appears in many places • Plane-wave basis: the kinetic energy −(ℏ2/2m)∇2 becomes just the number ℏ2k2/2m, so the matrix is diagonal.
• Ewald sum: the long-range Coulomb sum is split into a real-space part and a k-space part so that both converge quickly.
• Solving the Poisson equation: φ(k)=4πρ(k)/k2 — this division is carried out at every step.
• The convolution theorem: a convolution in real space becomes a plain multiplication in k-space.

12. Summary

  1. The components of a vector can be extracted by the inner product with the basis vectors, because the others are orthogonal and vanish.
  2. If we define an inner product ⟨f,g⟩=∫fgdx for functions as well, functions become vectors.
  3. Trigonometric functions have inner product 0 when their wavenumbers differ — they form an orthogonal basis. For identical functions it is π (except that only cos⁡0=1 gives 2π).
  4. Hence am can be extracted just by multiplying by cos⁡mx and integrating. am=(1/π)∫fcos⁡mxdx.
  5. ak and bk are the weights of “the waves that fit k times into 2π.” The smoother the function, the faster the coefficients with large k become small.
  6. Making the period infinitely large gives the Fourier transform, where differentiation is just multiplication by ik.
  7. Therefore differential equations can be solved by division: the three steps ① transform, ② divide, ③ inverse-transform.
  8. A worked example is Thomas–Fermi screening. Inverse-transforming φ(k)=4πqk2+kTF2 gives φ(r)=qre−kTFr. For aluminum, the screening length is 0.49 Å.
  9. Fourier interpolation in phonon calculations, the plane-wave basis, and the Ewald sum all have the same root.

Mochizuki Research Group, Tokyo University of Science / from the lecture notes “Fourier Series” (1)–(14). An interactive version that you can see and move is in the simulator. Related: Taylor expansion (an expansion that adds up terms around a single point), normal modes and phonons, the heat conduction equation, hydrogen atom orbitals.