This page is the practice arena for Fourier series . The parent note derived the recipe; here we run it on every kind of function you can be handed — even, odd, neither, constant, discontinuous, with a period that isn't the friendly 2 π , and a real heat-flow word problem. By the end there is no case class that can surprise you.
Intuition What "every scenario" means
A Fourier problem is decided by four questions. (1) Is f even, odd, or neither? (decides which coefficients vanish). (2) What is the period 2 L ? (decides whether you write n x or L nπ x ). (3) Is f continuous or does it jump? (decides whether the series hits f or a midpoint). (4) Is this pure maths or a physics starting shape? (decides what the answer means ). We tabulate all combinations, then hit each one.
Every example below plugs into the same three formulas from the parent note . State them once here so this page stands alone.
Intuition The symmetry shortcut we lean on repeatedly
Using Even and Odd Functions : if f is even (f ( − x ) = f ( x ) ) then all b n = 0 (only cosines); if f is odd (f ( − x ) = − f ( x ) ) then all a n = 0 (only sines). Reason: an odd integrand over the symmetric interval [ − L , L ] integrates to 0 .
The decision-tree has three symmetry classes (even / odd / neither) crossed with two continuity classes (continuous / has a jump) crossed with the period (2 π or general 2 L ). The eight examples below hit each reachable branch at least once ; the last column names which branch.
Cell
Symmetry
Period 2 L
Continuity
Twist
Example
A
Odd
2 π (L = π )
Jump
classic odd+jump
Ex 1: square wave
B
Even
2 π (L = π )
Continuous (corner)
corner, no jump
Ex 2: ∣ x ∣
C
Neither
2 π (L = π )
Jump
both a n and b n nonzero
Ex 3: f ( x ) = x + 1 on ( − π , π )
D
Even
General 2 L = 2 π
Continuous
keep L nπ x
Ex 4: x 2 on ( − 2 , 2 )
E
Constant
any
Continuous
degenerate: no waves
Ex 5: f = 3
F
Odd
2 π
Jump
value at the jump (not new coeffs)
Ex 6: square-wave series at x = 0
G
Half-range
L only given
choose extension
exam twist
Ex 7: sine vs cosine series of f = 1
H
Physics
2 π
Jump (block)
word problem, units
Ex 8: initial heat profile
Intuition Why cells A and F share a symmetry/continuity type
Cells A and F are both "odd + jump", but they teach different lessons . Cell A (Ex 1) asks "what are the coefficients?" — a computation. Cell F (Ex 6) asks "what does the finished series output at the discontinuity?" — a convergence question the coefficients don't answer directly. Same function, two genuinely different skills, so they get separate examples.
Note also the matrix spans the full decision-tree: even+jump appears in Ex 8 (a block that is symmetric but discontinuous), neither+jump appears in Ex 3, and even+continuous on a general period in Ex 4. No reachable branch is skipped.
Worked example Square wave
f ( x ) = { − 1 + 1 − π < x < 0 0 < x < π , period 2 π
Forecast: Before reading — which of a n , b n are zero, and will the answer contain all n or only some?
Step 1. f ( − x ) = − f ( x ) , so f is odd . Hence a n = 0 for all n .
Why this step? Odd × cosine (even) is odd, and an odd function integrated over the symmetric interval [ − π , π ] gives 0 . This deletes every cosine integral before we start.
Step 2. b n = π 1 ∫ − π π f ( x ) sin n x d x = π 2 ∫ 0 π sin n x d x .
Why this step? f sin n x is odd× odd = even, symmetric about 0 , so the integral over [ − π , π ] is twice the integral over [ 0 , π ] , where f = + 1 .
Step 3. ∫ 0 π sin n x d x = [ n − c o s n x ] 0 π = n 1 − cos nπ = n 1 − ( − 1 ) n .
Why this step? cos nπ = ( − 1 ) n : it is + 1 for even n (giving 0 ) and − 1 for odd n (giving 2/ n ). Only odd harmonics survive.
Step 4. So b n = π 2 ⋅ n 1 − ( − 1 ) n , i.e. b 1 = π 4 , b 3 = 3 π 4 , …
f ( x ) = π 4 ( sin x + 3 s i n 3 x + 5 s i n 5 x + ⋯ )
Verify: b 1 = π 4 ≈ 1.2732 , b 2 = 0 , b 3 = 3 π 4 ≈ 0.4244 . This is exactly the parent's result — consistent.
The figure below carries the geometry of this convergence.
Intuition What to observe in the figure above
The navy step is the target square wave. The orange curve is just π 4 sin x (one term) — a single hump that already captures the up-then-down shape. The violet curve adds n = 3 , 5 and the magenta curve uses eight odd harmonics: each extra term flattens the plateaus toward ± 1 and steepens the vertical edge. Two things to notice: (1) at x = 0 every sine is zero, so all partial sums pass through the midpoint value 0 — the pink/violet curves cross the origin, never reaching ± 1 there; (2) the little spike that overshoots just beside the jump does not shrink as you add terms — that is the Gibbs Phenomenon , a permanent ≈ 9% overshoot.
Worked example Triangle-like
f ( x ) = ∣ x ∣ on ( − π , π ) , period 2 π
Forecast: ∣ x ∣ is even and has no jump (just a sharp corner at 0 ). Guess: which coefficients vanish, and will the series converge fast or slow?
Step 1. f ( − x ) = ∣ − x ∣ = ∣ x ∣ = f ( x ) — even . So b n = 0 .
Why this step? Even× sine (odd) is odd ⇒ integrates to 0 . Only cosines remain.
Step 2. a 0 = π 1 ∫ − π π ∣ x ∣ d x = π 2 ∫ 0 π x d x = π 2 ⋅ 2 π 2 = π .
Why this step? a 0 /2 is the average height. Average of ∣ x ∣ is π /2 , and indeed a 0 /2 = π /2 . A built-in sanity check.
Step 3. a n = π 2 ∫ 0 π x cos n x d x . Integrate by parts:
∫ 0 π x cos n x d x = [ n x s i n n x ] 0 π − ∫ 0 π n s i n n x d x = 0 + [ n 2 c o s n x ] 0 π = n 2 ( − 1 ) n − 1 .
Why this step? Integration by parts is the right tool because the integrand is a polynomial × trig — differentiating x kills the polynomial, moving us toward a pure trig integral we can do. (The boundary term n x s i n n x vanishes at both ends because sin nπ = 0 and x = 0 at the lower limit.)
Step 4. a n = π 2 ⋅ n 2 ( − 1 ) n − 1 : zero for even n , and − π n 2 4 for odd n .
∣ x ∣ = 2 π − π 4 ( cos x + 9 c o s 3 x + 25 c o s 5 x + ⋯ )
Verify: a 1 = − π 4 ≈ − 1.2732 , a 2 = 0 , a 3 = − 9 π 4 ≈ − 0.1415 . Because coefficients shrink like 1/ n 2 (vs 1/ n for the jump square wave), this converges faster — the corner is milder than a jump. Plug x = 0 : 0 = 2 π − π 4 ∑ odd n 2 1 , giving ∑ odd n 2 1 = 8 π 2 , a known identity.
f ( x ) = x + 1 on ( − π , π ) , period 2 π
Forecast: Adding the constant 1 to x breaks odd symmetry: f ( − x ) = − x + 1 = ± f ( x ) . So this is neither even nor odd — and it still jumps at ± π . Guess: which coefficients survive now?
Step 1. Split f = x + 1 . The constant 1 contributes only to a 0 ; the linear x is odd and contributes only to b n .
Why this step? Fourier coefficients are linear in f , so we compute each piece and add. This is far easier than attacking x + 1 whole.
Step 2. From the constant: a 0 = π 1 ∫ − π π 1 d x = 2 , and all other a n = π 1 ∫ − π π 1 ⋅ cos n x d x = 0 .
Why this step? ∫ − π π cos n x d x = n s i n nπ ⋅ 2 -type terms vanish because sin nπ = 0 ; a constant needs no non-constant cosine.
Step 3. From the linear part (reusing the sawtooth work): b n = π 1 ∫ − π π x sin n x d x = n 2 ( − 1 ) n + 1 .
Why this step? x is odd, sin n x is odd, product even; by parts ∫ − π π x sin n x d x = 2 ∫ 0 π x sin n x d x = n − 2 π ( − 1 ) n , and dividing by π gives n 2 ( − 1 ) n + 1 .
Step 4 (the twist). Both a nonzero average (a 0 /2 = 1 ) and a full set of sines appear:
x + 1 = 1 + 2 ( sin x − 2 s i n 2 x + 3 s i n 3 x − ⋯ ) .
Every n is present in b n , and there is a standalone constant — the signature of a "neither" function.
Verify: a 0 = 2 (so average = 1 ✓, matches 2 π 1 ∫ − π π ( x + 1 ) d x = 1 ), b 1 = 2 , b 2 = − 1 , b 3 = 3 2 . At x = π /2 : 2 π + 1 = 1 + 2 ( 1 − 3 1 + 5 1 − ⋯ ) = 1 + 2 ⋅ 4 π ✓ (Leibniz again). At the jump x = π the series converges to the midpoint 2 1 [ f ( π − ) + f ( − π + )] = 2 1 [( π + 1 ) + ( − π + 1 )] = 1 .
f ( x ) = x 2 on ( − 2 , 2 ) , period 4 (so L = 2 )
Forecast: The period is now 4 , not 2 π . Which of the three formulas break if you forget and write n x instead of 2 nπ x ?
Step 1. x 2 is even ⇒ b n = 0 . Use L nπ x = 2 nπ x everywhere.
Why this step? The wave must complete whole cycles in the period 2 L = 4 ; the argument L nπ x guarantees that. Writing n x would use the wrong period and give nonsense.
Step 2. a 0 = L 1 ∫ − L L x 2 d x = 2 1 ∫ − 2 2 x 2 d x = 2 1 ⋅ 3 2 ⋅ 2 3 = 2 1 ⋅ 3 16 = 3 8 .
So the average is a 0 /2 = 3 4 . (Average of x 2 on [ − 2 , 2 ] is 4 1 ∫ − 2 2 x 2 = 3 4 ✓.)
Step 3a (parity reduction). a n = L 1 ∫ − L L x 2 cos L nπ x d x . The integrand is even× even = even, so it is symmetric about x = 0 :
a n = L 1 ∫ − L L x 2 cos L nπ x d x = L 2 ∫ 0 L x 2 cos L nπ x d x .
Why this step? Folding the symmetric integral in half halves the algebra and keeps the limits clean (starting from 0 ).
Step 3b (first integration by parts). Let k = L nπ . With u = x 2 , d v = cos ( k x ) d x :
∫ 0 L x 2 cos ( k x ) d x = [ k x 2 s i n k x ] 0 L − ∫ 0 L k 2 x s i n k x d x .
The boundary term is k L 2 s i n ( k L ) = k L 2 s i n ( nπ ) = 0 (since k L = nπ and sin nπ = 0 ).
Why this step? Differentiating x 2 drops it to 2 x — one power gone, one to go.
Step 3c (second integration by parts). For the remaining ∫ 0 L 2 x sin ( k x ) d x , take u = 2 x , d v = sin ( k x ) d x :
∫ 0 L 2 x sin ( k x ) d x = [ k − 2 x c o s k x ] 0 L + ∫ 0 L k 2 c o s k x d x = k − 2 L c o s ( nπ ) + k 2 2 s i n ( nπ ) = k − 2 L ( − 1 ) n .
Putting Step 3b and 3c together (mind the minus sign in 3b):
∫ 0 L x 2 cos ( k x ) d x = 0 − k 1 ( k − 2 L ( − 1 ) n ) = k 2 2 L ( − 1 ) n = n 2 π 2 2 L ( − 1 ) n L 2 = n 2 π 2 2 L 3 ( − 1 ) n .
Why this step? 2 x differentiates to a constant, so the second part-step finishes the job.
Step 3d. Therefore
a n = L 2 ⋅ n 2 π 2 2 L 3 ( − 1 ) n = n 2 π 2 4 L 2 ( − 1 ) n = n 2 π 2 16 ( − 1 ) n ( L = 2 ) .
Step 4. x 2 = 3 4 + π 2 16 ∑ n = 1 ∞ n 2 ( − 1 ) n cos 2 nπ x .
Verify: a 1 = π 2 − 16 ≈ − 1.6211 , a 2 = 4 π 2 16 = π 2 4 ≈ 0.4053 . At x = 2 (where cos 2 nπ ⋅ 2 = cos nπ = ( − 1 ) n ) the series gives 3 4 + π 2 16 ∑ n 2 ( − 1 ) n ( − 1 ) n = 3 4 + π 2 16 ⋅ 6 π 2 = 3 4 + 3 8 = 4 = 2 2 ✓ (used ∑ 1/ n 2 = π 2 /6 ).
f ( x ) = 3 on ( − π , π )
Forecast: A flat line — how many waves does it take to build "no wave"?
Step 1. a 0 = π 1 ∫ − π π 3 d x = π 1 ⋅ 6 π = 6 .
Why this step? a 0 /2 must equal the average value 3 , and 6/2 = 3 ✓.
Step 2. a n = π 1 ∫ − π π 3 cos n x d x = 0 (whole cycles of cosine integrate to 0 ), and b n = 0 likewise.
Why this step? A constant has no oscillation, so it needs zero of every non-constant wave.
Result: series = a 0 /2 = 3 . Verify: trivially 3 = 3 for all x . This is the limiting/degenerate corner of the whole theory: the "0 -frequency" term alone.
Worked example Where does the square-wave series converge at
x = 0 ?
Forecast: At x = 0 the square wave is undefined (it jumps from − 1 to + 1 ). What number does π 4 ( sin x + ⋯ ) actually output there?
Step 1. Plug x = 0 into π 4 ( sin x + 3 s i n 3 x + ⋯ ) . Every sin ( n ⋅ 0 ) = 0 , so the sum is 0 .
Why this step? We test the series numerically at the danger point.
Step 2. The convergence theorem says at a jump the series equals the midpoint 2 1 [ f ( 0 + ) + f ( 0 − )] = 2 1 [( + 1 ) + ( − 1 )] = 0 .
Why this step? This is not a coincidence — the series always splits the difference at a jump (see Gibbs Phenomenon for the overshoot near the jump).
Verify: predicted 0 from the theorem = computed 0 from the sum ✓. Lesson: "= " in Fourier series is a midpoint equality at discontinuities, not literal equality.
Intuition What a half-range expansion is, and where the
π 2 comes from
Sometimes f is given only on ( 0 , π ) — half of a full 2 π -period. To use the Fourier machinery we must first invent the missing half on ( − π , 0 ) . We are free to choose it, and two choices are special: extend oddly (mirror-and-flip, forcing a sine-only series) or evenly (mirror straight across, forcing a cosine-only series). Either way the period becomes 2 π , so L = π .
Why the coefficient formula gains a π 2 : start from the general b n = L 1 ∫ − L L f sin L nπ x d x with L = π , giving b n = π 1 ∫ − π π f sin n x d x . For the odd extension the integrand f sin n x is even (odd× odd), symmetric about 0 , so the [ − π , π ] integral is twice the [ 0 , π ] integral — and the π 1 becomes π 2 :
b n = π 2 ∫ 0 π f ( x ) sin n x d x .
Identically, for the even extension f cos n x is even, so a n = π 2 ∫ 0 π f ( x ) cos n x d x . The π 2 is nothing new — it is the standard formula folded in half by symmetry.
f ( x ) = 1 on ( 0 , π ) as (a) a sine series, (b) a cosine series
Forecast: Same function, same interval — yet you can get two different valid Fourier series. How? Because you choose how to extend f to ( − π , 0 ) .
Step 1 (sine series — odd extension). Reflect f oddly: f ( − x ) = − 1 on ( − π , 0 ) . Then a n = 0 and, by the half-range formula above,
b n = π 2 ∫ 0 π 1 ⋅ sin n x d x = π 2 [ n − c o s n x ] 0 π = π 2 ⋅ n 1 − c o s nπ = π 2 ⋅ n 1 − ( − 1 ) n .
Why this step? An odd extension forces a sine-only series; this is exactly what a PDE with f = 0 at both ends (Dirichlet boundary) demands.
Step 2 (evaluate the sine coefficients). b n is 0 for even n and π n 4 for odd n , so
1 = π 4 ( sin x + 3 s i n 3 x + 5 s i n 5 x + ⋯ ) ( 0 < x < π ) .
Why this step? The odd extension of the constant 1 is the ± 1 square wave, so the coefficients match Ex 1 exactly — a satisfying consistency check.
Step 3 (cosine series — even extension). Reflect f evenly: f ( − x ) = + 1 . Then b n = 0 , and
a 0 = π 2 ∫ 0 π 1 d x = 2 , a n = π 2 ∫ 0 π cos n x d x = π 2 ⋅ n s i n nπ = 0 ( n ≥ 1 ) .
Why this step? The even extension of a constant is just the constant again — a flat line needs no cosines beyond its average.
Step 4 (write the cosine series).
1 = 2 a 0 = 1 ( 0 < x < π ) .
The two series look utterly different (an infinite sine sum vs. a single constant) yet represent the same f on ( 0 , π ) — that is the exam twist.
Verify: sine version at x = π /2 : π 4 ( 1 − 3 1 + 5 1 − ⋯ ) = π 4 ⋅ 4 π = 1 ✓. Cosine version = 1 trivially ✓. Both equal 1 on the given half-interval.
Worked example A rod of length
π m starts at temperature u ( x , 0 ) = 100 °C in the middle third ( π /3 , 2 π /3 ) and 0 °C elsewhere. Find the sine coefficients of the initial profile.
Forecast: The hot block sits symmetrically in the middle, so the profile is symmetric about the rod's centre yet discontinuous (jumps at the block edges) — the "even+jump" branch. Separation of Variables on the Heat Equation gives modes sin ( n x ) ; we must expand this blocky initial temperature in them. Which coefficients dominate?
Step 1. Model: u ( x , 0 ) = { 100 0 π /3 < x < 2 π /3 else on ( 0 , π ) . Use the sine (odd, half-range) expansion because the rod ends are held at 0 °C, i.e. u ( 0 ) = u ( π ) = 0 .
Why sine? The boundary conditions kill cosines; only sin ( n x ) satisfies u ( 0 ) = u ( π ) = 0 . We reuse the half-range formula b n = π 2 ∫ 0 π u sin n x d x from Ex 7.
Step 2. b n = π 2 ∫ π /3 2 π /3 100 sin n x d x = π 200 [ n − cos n x ] π /3 2 π /3 = nπ 200 ( cos 3 nπ − cos 3 2 nπ ) .
Why this step? Integrate only where u = 100 ; elsewhere the integrand is 0 .
Step 3. Compute the amplitudes (°C): with n = 1 , cos 3 π − cos 3 2 π = 2 1 − ( − 2 1 ) = 1 , so b 1 = π 200 ≈ 63.66 . With n = 2 , cos 3 2 π − cos 3 4 π = − 2 1 − ( − 2 1 ) = 0 , so b 2 = 0 . With n = 3 , cos π − cos 2 π = − 1 − 1 = − 2 , so b 3 = 3 π 200 ⋅ ( − 2 ) = 3 π − 400 ≈ − 42.44 .
Why check units? b n carries the same unit as u , i.e. °C — it is the amplitude of that temperature mode.
Step 4. The initial profile is u ( x , 0 ) = ∑ n = 1 ∞ b n sin n x , and as time runs the Heat Equation multiplies mode n by e − n 2 t , so high-n modes decay fastest — the sharp block smooths quickly. (Compare the Wave Equation , where each mode instead oscillates in time.)
Verify: b 1 ≈ 63.66 °C, b 2 = 0 , b 3 ≈ − 42.44 °C. The dominant b 1 hump is the slowest-decaying, so late-time temperature looks like a single sin x arch — physically sensible.
Recall Scenario checklist before any Fourier problem
Symmetry? ::: Even ⇒ only a n ; odd ⇒ only b n ; neither ⇒ both.
Period 2 L = ? ::: Always write L nπ x ; only simplify to n x when L = π .
Jump present? ::: Series converges to the midpoint there (Gibbs overshoot nearby).
Half-range given? ::: You choose even (cosine) or odd (sine) extension per the boundary conditions; the π 1 becomes π 2 by symmetry.
Parent recipe & derivation: Fourier series motivation
Why coefficients isolate: Orthogonality of Functions
Symmetry shortcuts: Even and Odd Functions
Where these series come from: Separation of Variables , applied to the Heat Equation and Wave Equation
The overshoot at jumps: Gibbs Phenomenon
The continuous-spectrum sibling: Fourier Transform