Fourier Transform

APAM 1601y
Columbia University

Baron Joseph Fourier

Joseph Fourier, the son of a tailor, was born in Auxerre, France in 1768 and died in Paris in 1830.

Joseph Fourier was mathematician, known also as an Egyptologist and administrator, who exerted strong influence on mathematical physics through his Théorie analytique de la chaleur (1822; The Analytical Theory of Heat). He showed how the conduction of heat in solid bodies may be analyzed in terms of infinite mathematical series now called by his name, the Fourier series. Far transcending the particular subject of heat conduction, his work stimulated research in mathematical physics, which has since been often identified with the solution of boundary-value problems, encompassing many natural occurrences such as sunspots, tides, and the weather.

After working as a teacher in mathematics at the military school of his youth and later as a Professor of mathematics at the École Polytechnique, Fourier accompanied Napoleon on his expedition to Egypt. Until 1801 he was engaged in extensive research on Egyptian antiquities, gave advice on engineering and diplomatic undertakings, and served for three years as the secretary of the Institut d'Égypte, which Napoleon establishedin Cairo in 1798.

After his return to France, Fourier was charged with the publication of the enormous mass of Egyptian materials. This became the Description de l'Égypte, to which he also wrote a lengthy historical preface on the ancient civilization of Egypt. He was also appointed prefect (administrator for the national government and département) of the Isère département, a position he held from 1802 to 1814, with his headquarters at Grenoble. He showed great administrative ability, as in directing the drainage of swamps, while continuing his Egyptological and mathematical work. In 1809 Napoleon made him a baron. Following Napoleon's fall from power in 1815, Fourier was appointed director of the Statistical Bureau of the Seine, allowing him a period of quiet academic life in Paris. In 1817 he was elected to the Académie des Sciences, of which, in 1822, he became perpetual secretary. Because of his work in Egyptology he was elected in 1826 to the Académie Française and the Académie de Médecine.

Fourier began his work on the Théorie analytique de la chaleur in Grenoble in 1807 and completed it in Paris in 1822. His work enabled him to express the conduction of heat in two-dimensional objects (i.e., very thin sheets of material) in terms of the differential equation
	(∂_t) T = k ((∂_(x,x))T + (∂_(y,y))T)
that describes the flow of heat from hot to cold on a uniform plane. The constant k is the thermal conductivity.

Fourier introduced a  series expansion for T(x, y) in terms of Cos[...] and Sin[...] functions. Although this series expansion was occasionally used by Leonhard Euler and other 18th-century mathematicians, Fourier elevated this technique to an important position in modern mathematics. He also extended this concept into the so-called Fourier integral.

Today, Fourier, or spectral, techniques play an essential role in the solution of partial differential equations. The digitial variant, called the discrete Fourier transform (DFT), is essential to digital signal processing.

(Adapted from Encyclopedia Britannica)

Off[General::"spell1"];

Introduction to PDEs

In this section, NDSolve[…] is used to solve the one-dimensional heat conduction equation. This equation is also called the diffusion equation. It is an example of a "parabolic" PDE.

?NDSolve

From the Help Browser…

eq =(∂_t) u[x,t] == (∂_(x,x))u[x,t]

f0[x_]:=6 x-6 (x^4)+(x^2);
p0=Plot[f0[x],{x,0,1},PlotLabel->"Initial Temperature Distribution",AxesLabel->{"x","T(x,0)"}]

initial = {u[0,t] == 0, u[1,t] == 1, u[x,0] == f0[x]}

sol=NDSolve[{eq }~Join ~ initial,u,{x,0,1},{t,0,.5}]

Graphing the solution

p1=Plot[Evaluate[u[x,t]/.sol/.t->0],{x,0,1},AxesLabel->{"x","u[x,0]"},PlotStyle->RGBColor[1,0,0]]

p2=Plot[Evaluate[u[x,t]/.sol/.t->0.5`],{x,0,1},AxesLabel->{"x","u[x,0.5]"}]

Show[p1,p2,PlotLabel->"T(x) Beginning & End",AxesLabel->{"x","u[x,t]"}]

Plot3D[Evaluate[u[x,t]/.First[sol]],{x,0,1},{t,0,0.5`},PlotLabel->"NDSolve's Solution"]

ContourPlot[Evaluate[u[x,t]/.First[sol]],{x,0,1},{t,0,0.5`},ColorFunction->Hue,FrameLabel->{"x","t"},PlotLabel->"NDSolve PDE Solution"]

The Analysis of Fourier

In this section, we introduce the method of Baron Fourier. The solution u[x,t] is represented as a truncated summation of sin(kx) and cos(kx) functions.

Sine and Cosine Modes

Fourier represented a function, f[x], as a summation of Sines and Cosines with different wavelengths that match the boundaries of our problem.

nModes = 5;

f[x_] := Sum[a[i] Cos[2 π i x], {i,0,nModes}] + Sum[b[i] Sin[2 π i x], {i,1, nModes}]

f[x]

Plot[Evaluate[Table[Cos[2 π i x],{i,0,nModes}]],{x,0,1},PlotStyle->Table[{Hue[(i/nModes)]},{i,0,nModes}]]

Plot[Evaluate[Table[Sin[2 π i x],{i,1,nModes}]],{x,0,1},PlotStyle->Table[{Hue[(i/nModes)]},{i,1,nModes}]]

Orthogonal Modes

If the wavelengths are integer fractions of the rod length, then each "mode" is orthogonal. This property can be used to define the coefficients (Subscript[a, n])and (Subscript[b, n])…

Integrate[f[x] Cos[2π x], {x, 0, 1}]

Integrate[f[x] Sin[2π 3 x], {x, 0, 1}]

Integrate[f[x] Cos[2π 0 x], {x, 0, 1}]

Modal Expansion

For a function defined between 0 ≤ x ≤ 1, the coefficients of the Fourier expansion can be found by using the property of orthogonal modes.

h[x_] := x - (x^3)

getCosMode[f_][n_Integer] := If[n > 0, 2, 1]Integrate[f[x] Cos[2 π x n], {x, 0, 1}]

getCosMode[h][2]

getSinMode[f_][n_Integer] := 2 Integrate[f[x] Sin[2 π x n], {x, 0, 1}]

getSinMode[h][2]

Now, let's form a Fourier expansion of h[x] and plot the expansion and the original function.

nModes = 10; (* the max number of modes in expansion *)

Do[fa[n] = N[getCosMode[h][n]], {n, 0, nModes}];

Do[fb[n] = N[getSinMode[h][n]], {n, 1, nModes}];

funcFourier[n_Integer][x_] := Sum[fa[i] Cos[2 π i x], {i, 0, n}] + Sum[fb[i] Sin[2 π i x], {i, 1, n}]

Plot[{h[x],funcFourier[1][x],funcFourier[2][x],funcFourier[3][x],funcFourier[nModes][x]},{x,0,1},PlotStyle->{{Thickness[0.01`]},{Hue[(1/nModes)]},{Hue[(2/nModes)]},{Hue[(3/nModes)]},{Hue[1]}},PlotLabel->"Fourier Approx to h[x]",AxesLabel->{"x","h[x]"}]

Time Evolutions of the Modes (Exact)

Fourier represented the temperature function as a summation of Sines and Cosines. He found that the time evolution of each mode was easily determined.

nModes = 5;

g[x_,t_] := Sum[a[i,t] Cos[2 π i x], {i,0,nModes}] + Sum[b[i,t] Sin[2 π i x], {i,1, nModes}]

g[x,t]

eqf = D[g[x,t],t] == D[g[x,t],{x,2}]

{Coefficient[Part[eqf,1], Cos[2π x]],Coefficient[Part[eqf,2], Cos[2π x]]}

eqfa[1] = Coefficient[Part[eqf,1], Cos[2π x]] == Coefficient[Part[eqf,2], Cos[2π x]]

DSolve[eqfa[1], a[1,t], t]

eqfa[nModes] = Coefficient[Part[eqf,1], Cos[nModes 2π x]] == Coefficient[Part[eqf,2], Cos[nModes 2π x]]

DSolve[eqfa[nModes], a[nModes,t], t]

a[0,t] is special…

eqfa[0] = D[a[0,t],t] == 0

DSolve[eqfa[0], a[0,t], t]

Notice the modes decay in time as

gamma = Table[(((2π n))^2), {n, 0, nModes}]

These coefficients represent Fourier's solution to the heat diffusion equation!

The Sin[…] equations are the same…

eqfb[1] = Coefficient[Part[eqf,1], Sin[2π x]] == Coefficient[Part[eqf,2], Sin[2π x]]

eqfb[nModes] = Coefficient[Part[eqf,1], Sin[nModes 2 π x]] == Coefficient[Part[eqf,2], Sin[nModes 2 π x]]

DSolve[eqfb[nModes], b[nModes,t], t]

The solution is known once the initial conditions, the coefficients "C[1]", are known for each mode.

Fourier's Solution

Now, we'll apply Fourier's method to our particular heat diffusion problem. We will carefully select the modes that both match the boundary conditions and represent the time dependance of the temperature.

nModes = 10;

final[x_]:=x;
Plot[f0[x]-final[x],{x,0,1},PlotLabel->"Difference from Final",AxesLabel->{"x","ΔT"}]

We only need Sine coefficients to represent this difference. This is an essential part of the modal expansion. Modes must be selected in order to satisfy the boundary conditions. (This is usually a very natural!) In our example problem, the difference between the initial and final (steady-state) solution is zero at x = 0 and x = 1. Therefore, we need a series of modes that also vanish at x = 0 and x = 1.

Plot[Evaluate[Table[Sin[n π x],{n,1,5}]],{x,0,1},PlotStyle->Table[{Hue[(i/5)]},{i,1,5}],PlotLabel->"Modes with Compatible Boundaries"]

Initial Coefficients:

getSinMode2[f_][n_Integer] := 2 Integrate[f[x] Sin[π x n], {x, 0, 1}]

b0 = Table[N[getSinMode2[(f0[#]-final[#])&][n]], {n, 1, nModes}]

Notice: once the initial coefficients are determined, so is the solution! The spatial dependance is set by the modal expansion, and the heat diffusion equation sets the decay rate for each mode. Once the time-constants are calculated, Fourier's solution requires only integrals of the initial condition, u(x, t = 0).

Time Constants:

gamma = Table[(((π n))^2), {n, 0, nModes}]

Complete Solution:

uf[x_,t_] := final[x] + Sum[b0[[n]]Exp[-gamma[[n+1]] t] Sin[n π x], {n, 1, nModes}]

uf[x,t]

Plot[{uf[x,0.`],uf[x,0.5`]},{x,0,1},PlotLabel->"Initial and Final Solution",AxesLabel->{"x","T[x]"}]

Plot3D[uf[x,t],{x,0,1},{t,0,0.5`},PlotRange->All,PlotLabel->"Fourier's Solution"]

ContourPlot[Evaluate[uf[x,t]/.First[sol]],{x,0,1},{t,0,0.5`},ColorFunction->Hue,FrameLabel->{"x","t"},PlotLabel->"Fourier's Solution"]

Comparing Solutions

When the solutions are compared, the difference is less than ±0.001 or ±0.1%.

Plot3D[Evaluate[u[x,t]/.First[sol]]-uf[x,t],{x,0,1},{t,0,0.5`},PlotLabel->"Solution Difference", PlotRange -> 0.005 {-1,1}]

ContourPlot[Evaluate[u[x,t]/.First[sol]]-uf[x,t],{x,0,1},{t,0,0.5},ColorFunction->Hue]

Summary

Baron Joseph Fourier was an early mathematical physicist who demonstrated the use of a series of Sine and Cosine functions to solve partial differential equations. He invented the Fourier series. His theory motivated an entire field of mathematical analysis using orthonormal modes and expansions.

The one-dimensional heat conduction equation was solved using both NDSolve[…] and Fourier's method. Both solutions produced equivalent results. However, the simplicity of Fourier's method can be used to define an approximate solution without a computer.