Mathematica Activities: Fourier Transform on the Real Line and Application to Differential Equations






Fourier Transform — In-Class Activities (Mathematica)





Applied Mathematics — Fourier Methods (Mathematica Lab)

Fourier Transform — In-Class Activities


Purpose, Conventions, and Learning Outcomes

These activities consolidate last lecture’s definitions and rules for the Fourier transform on $\mathbb{R}$ using Mathematica. We adopt the $2\pi i$ convention:
\[
\widehat f(\xi)=\int_{\mathbb{R}} f(x)\,e^{-2\pi i x\xi}\,dx,\qquad
f(x)=\int_{\mathbb{R}}\widehat f(\xi)\,e^{2\pi i \xi x}\,d\xi.
\]
I advise that in the activities below, students do not use the built-in function for the Fourier transform and instead, define a function that computes the Fourier transform with $2\pi i x \xi$ in the exponent.

Learning outcomes. By the end, you should be able to:
(i) compute transforms symbolically and numerically; (ii) verify differentiation/multiplication rules;
(iii) observe Riemann–Lebesgue decay numerically; (iv) solve a linear ODE via transforms; (v) implement and visualize the heat kernel solution.

Activity 1 — Canonical Example: Gaussian Self-Duality

Task. Let $f(x)=e^{-\pi x^2}$. Use Mathematica to compute $\widehat f$ and verify $\widehat f(\xi)=e^{-\pi \xi^2}$. Then plot $f$ and $\widehat f$ (separately or side-by-side) on $[-5,5]$.

Mathematica starter.

f[x_] := Exp[-Pi x^2];
ft[ξ_] = FourierTransform[f[x], x, ξ];
Simplify[ft[ξ] == Exp[-Pi ξ^2]]
GraphicsRow[{
  Plot[f[x], {x, -5, 5}, PlotLegends -> {"f(x)"}],
  Plot[ft[ξ], {ξ, -5, 5}, PlotLegends -> {"f̂(ξ)"}]
}]

Pedagogical focus. Normalize conventions; establish a benchmark for smoothness $\leftrightarrow$ rapid decay.

Activity 2 — Non-Smooth Prototype: $f(x)=e^{-|x|}$

Task. Compute $\widehat f$ for $f(x)=e^{-|x|}$ and confirm
\[
\widehat f(\xi)=\frac{2}{1+4\pi^2\xi^2}.
\]
Plot $f$ and $\widehat f$, and discuss why the cusp at $x=0$ corresponds to algebraic (not exponential) decay of $\widehat f$.

Mathematica starter.

f[x_] := Exp[-Abs[x]];
ft[ξ_] := 2/(1 + (2 Pi ξ)^2);
GraphicsRow[{
  Plot[f[x], {x, -6, 6}, PlotLegends -> {"f(x)"}],
  Plot[ft[ξ], {ξ, -6, 6}, PlotLegends -> {"f̂(ξ)"}]
}]

Guiding questions. (i) Where is $f$ non-differentiable? (ii) How does that loss of smoothness “show up” in $\widehat f$? (iii) Compare with Activity 1.

Activity 3 — Verifying the Differentiation Rule

Task. For $f(x)=e^{-x^2}$, verify
\[
\mathcal{F}(f’)( \xi ) = (2\pi i \xi)\,\widehat f(\xi).
\]
Compute both sides symbolically and test identity with Simplify. Then sample numerically (e.g., $\xi\in\{-3,-2,\dots,3\}$) to confirm.

f[x_] := Exp[-x^2];
lhs = FourierTransform[D[f[x], x], x, ξ];
rhs = (2 Pi I ξ) FourierTransform[f[x], x, ξ];
Simplify[lhs == rhs]
Table[{ξ, N[lhs /. ξ -> k], N[rhs /. ξ -> k]}, {k, -3, 3}]

Pedagogical focus. Link algebraic operations in $x$ to multiplicative factors in frequency.

Activity 4 — Multiplication by $x$ and $\partial_\xi$

Task. Verify, for a rapidly decaying $f$ (e.g., $e^{-x^2}$),
\[
\mathcal{F}(x f(x))(\xi) = \frac{i}{2\pi}\,\frac{d}{d\xi}\widehat f(\xi).
\]
Compute both sides and plot their real/imag parts to visualize equality.

f[x_] := Exp[-x^2];
lhs = FourierTransform[x f[x], x, ξ];
rhs = (I/(2 Pi)) D[FourierTransform[f[x], x, ξ], ξ];
Simplify[lhs == rhs]
Plot[Evaluate[{Re[lhs], Re[rhs]} /. ξ -> t], {t, -4, 4},
  PlotLegends -> {"Re lhs", "Re rhs"}]
]

Pedagogical focus. Duality between position and frequency differentiation (Heisenberg pair).

Activity 5 — Riemann–Lebesgue Theorem (Numerical Experiment)

Task. Take $f(x)=\frac{1}{1+x^2}$. Compute $\widehat f$ and numerically sample $\widehat f(\xi)$ for large $|\xi|$ (e.g., $50,100,200$) to observe $\widehat f(\xi)\to 0$.

f[x_] := 1/(1 + x^2);
ft[ξ_] = FourierTransform[f[x], x, ξ];  (* returns a closed form *)
N[ft[50]], N[ft[100]], N[ft[200]]
Plot[Abs[ft[ξ]], {ξ, 0, 50}, PlotLabel -> "|f̂(ξ)|"]

Pedagogical focus. Connect the proved theorem to computation; note the rate of decay versus smoothness.

Activity 6 — Solving a First-Order ODE with Fourier Transform

Task. Solve $u'(x)+2u(x)=e^{-|x|}$ via transforms:
(i) take Fourier transforms of both sides; (ii) solve for $\widehat u$;
(iii) compute the inverse transform; (iv) validate with DSolve.

f[x_] := Exp[-Abs[x]];
uhat[ξ_] = FourierTransform[Evaluate[.], x, ξ]; (* placeholder to show structure *)
(* Work explicitly: *)
lhs = FourierTransform[D[u[x], x] + 2 u[x], x, ξ];
(* Replace F{u'} -> (2π i ξ)Û and F{u} -> Û to solve algebraically: *)
(* Alternatively do purely symbolic with assumptions: *)
fu[ξ_] = FourierTransform[u[x], x, ξ];
eq = (2 Pi I ξ) fu[ξ] + 2 fu[ξ] == FourierTransform[f[x], x, ξ];
sol = Solve[eq, fu[ξ]][[1,1,2]];
uSol[x_] = InverseFourierTransform[sol, ξ, x] // Simplify;
uCheck = DSolveValue[D[u[x], x] + 2 u[x] == f[x], u, x] // Simplify;
Simplify[uSol[x] == uCheck]

Pedagogical focus. Show transform method as an operator-diagonalization technique and verify with an independent solver.

Activity 7 — Heat Equation via Fourier Transform and Animation

Task. Solve $u_t=\kappa u_{xx}$ with $u(x,0)=e^{-x^2}$ using the $x$-Fourier transform.
Derive
\[
\widehat u(\xi,t)=\widehat u(\xi,0)\,e^{-4\pi^2\kappa \xi^2 t},\qquad
u(x,t)=\int_{\mathbb{R}} \widehat u(\xi,0)\,e^{-4\pi^2\kappa \xi^2 t}\,e^{2\pi i \xi x}\,d\xi.
\]
For $\kappa=1$ this reduces to the explicit Gaussian evolution
\[
u(x,t)=\frac{1}{\sqrt{1+4t}}\exp\!\Big(-\frac{x^2}{1+4t}\Big).
\]
Animate $u(\cdot,t)$ for $t\in[0,2]$.

κ = 1;
u[x_, t_] := 1/Sqrt[1 + 4 κ t] Exp[-x^2/(1 + 4 κ t)];
Animate[
  Plot[u[x, t], {x, -5, 5}, PlotRange -> {0, 1}, AxesLabel -> {"x","u"}],
  {t, 0, 2}
]

Pedagogical focus. Connect frequency-space ODE to physical diffusion; visualize smoothing and mass conservation.

Short Reflection (Exit Ticket)

  1. Compare the decay of $\widehat f$ for Activities 1 and 2. What regularity features of $f$ drive the difference?
  2. In Activities 3–4, summarize the $x \leftrightarrow \xi$ operator dictionary in one sentence.
  3. From Activities 6–7, when would you prefer a transform method over direct ODE/PDE solvers?
© 2025 — V. Oussa. Prepared for in-class use (BSU).