FS04E1: Fourier Cosine-Coefficient Derivation and Projection Exercises
FS04 derived the cosine coefficient formula
and the constant coefficient
This companion is calculation practice for those results. The emphasis is not on memorizing
Equation (1). The emphasis is on repeatedly seeing why it is a projection formula, when symmetry
can shorten the integral, how the constant term differs from the nonzero harmonics, and how
integration by parts produces useful coefficient formulas.
The sine coefficient formula is deliberately not derived here. That belongs to FS05.
Figure 1. The exercise sequence moves from direct harmonic isolation to the DC coefficient,
projection geometry, parity shortcuts, integration by parts, piecewise even functions, and finally
the general interval [−L,L].
1 Three reusable checks
Cosine-coefficient extraction check
A cosine-coefficient extraction check verifies that multiplying a finite trigonometric sum by
cos(mx) and integrating over [−π,π] leaves only the mth cosine term multiplied by its norm
squared π.
DC-coefficient check
A DC-coefficient check verifies the distinction
versus the actual constant term in the Fourier series,
Thus a0∕2 is the mean value of f over the interval.
Cosine-projection residual check
After projecting f onto a cosine harmonic,
define the residual
A correct projection satisfies
Figure 2. Harmonic isolation acts like a filter. Multiplication by the target cosine and integration
over a complete period removes the constant term, all sine terms, and all cosine harmonics with
the wrong index.
2 Problems
All problems are stated before the hints and complete solutions.
Problem 1: isolate one known cosine coefficient
Let
Evaluate
by expanding every term. Do not simply read the answer from f(x).
Problem 2: rebuild the general extraction formula
Assume
Multiply by cos(mx), integrate over [−π,π], and derive Equation (1) for 1 ≤ m ≤ N.
Problem 3: extract the constant coefficient from a finite sum
For
compute a0 by integration and identify the actual DC component a0∕2.
Problem 4: projection formula versus Fourier formula
Using the FS02 projection formula
set
on [−π,π] and derive the Fourier cosine coefficient formula directly.
Problem 5: residual orthogonality
Let
and suppose that
Define
Verify directly that
Problem 6: even-function shortcut
Suppose f is even. Show that
Explain why the shortcut works.
Problem 7: odd functions have zero cosine coefficients
Suppose f is odd. Show, without using the sine coefficient formula, that
for every n ≥ 0.
Problem 8: the DC coefficient of x2
For
compute a0 and the mean value a0∕2.
Problem 9: cosine coefficients of x2
Starting from
perform integration by parts twice and derive
Show every boundary term.
Problem 10: first cosine projection of x2
Using Problems 8 and 9, write the constant-plus-first-cosine approximation
Evaluate it at x = 0 and x = π and compare with x2.
Problem 11: cosine coefficients of |x|
For
compute a0 and derive an by integration by parts. Simplify the result separately for even and odd
n.
Problem 12: centered rectangular pulse
Let
Compute a0 and an. Evaluate a1,a2,a3,a4,a5.
Problem 13: centered pulse of arbitrary half-width
Generalize Problem 12 to
Derive a0 and an in terms of A and α.
Problem 14: triangular even function
Let
Compute a0 and derive the cosine coefficients. Identify which harmonics vanish.
Problem 15: general interval [−L,L]
For the basis
use the projection formula to derive
Also derive the corresponding a0 formula.
Problem 16: normalized-basis coefficient
Define
If
show that
Explain why cn and an are different numbers even though they describe the same projected
function.
3 Hints
- Expand the four terms and use the FS03 orthogonality relations one at a time.
- Keep the sum finite. The cosine-cosine integral is π only when n = m.
- Every nonconstant integer sine or cosine integrates to zero over [−π,π].
- Compute ⟨cos(mx), cos(mx)⟩ explicitly.
- Use ∫
x2 cos xdx from the n = 1 case of Problem 9, or derive it directly twice by parts.
- The product of two even functions is even.
- Odd times even is odd.
- Use evenness before integrating.
- First choose u = x2 and dv = cos(nx)dx; then integrate the remaining x sin(nx) term
by parts.
- From Problem 9, a1 = −4.
- |x| is even, so work only on [0,π].
- Only the interval [−π∕2,π∕2] contributes.
- Replace π∕2 by α and include amplitude A.
- Write π −|x| as π − x on [0,π].
- The norm squared of each nonzero cosine basis function on [−L,L] is L.
- The normalized basis has norm one, so its coordinate is the inner product itself.
4 Worked solutions
Solution 1: isolate one known cosine coefficient
Begin with
| I | = ∫
−ππ cos 3xdx | (33)
|
| =   | (34)
|
| . | (35) |
The first three integrals are zero by orthogonality. The final integral is
Therefore
The operation has isolated the coefficient of cos 3x.
Solution 2: rebuild the general extraction formula
Multiply the finite expansion by cos(mx):
| f(x) cos(mx) | = cos(mx) | (38)
|
| + ∑
n=1Na
n cos(nx) cos(mx) | (39)
|
| + ∑
n=1Nb
n sin(nx) cos(mx). | (40) |
Integrate over [−π,π]:
| ∫
−ππf(x) cos(mx) dx | = ∫
−ππ cos(mx) dx | (41)
|
| + ∑
n=1Na
n ∫
−ππ cos(nx) cos(mx) dx | (42)
|
| + ∑
n=1Nb
n ∫
−ππ sin(nx) cos(mx) dx. | (43) |
The constant-cosine integral vanishes. Every sine-cosine integral vanishes. Every cosine-cosine
integral with n≠m vanishes. Only the n = m term remains:
Divide by π:
Figure 3. The constant basis function has norm squared 2π, so its projection coefficient is the
mean value a0∕2. The Fourier symbol a0 is twice that mean.
Solution 3: extract the constant coefficient
Integrate the function:
| ∫
−ππf(x) dx | = ∫
−ππ dx | (46)
|
| = 12π. | (47) |
Therefore
The actual constant term is
That agrees with the constant visible in the original finite sum.
Solution 4: projection formula versus Fourier formula
Set
The projection coefficient is
The numerator is
The denominator is
Therefore
Thus c = am.
Figure 4. The projection coefficient is chosen so that the residual has zero inner product with the
target basis function. Fourier cosine extraction is this same geometric construction in function
space.
Solution 5: residual orthogonality
We must evaluate
Split the integral:
The second integral is
For the first integral, evenness gives
Integrate by parts twice:
| ∫
0πx2 cos xdx | =
0π − 2 ∫
0πx sin xdx | (59)
|
| = −2![( ∫ π )
π
[− x cosx ]0 + 0 cosx dx](https://images.physicslibrary.org/cache/objects/1538/make4ht/FourierCosineCoefficientDerivationAndProjectionExercises56x.png) | (60)
|
| = −2π. | (61) |
Hence
Therefore the residual inner product is
Solution 6: even-function shortcut
If f is even, then cos(nx) is also even. Their product is even:
Therefore
Substitute into the coefficient formula:
Solution 7: odd functions have zero cosine coefficients
If f is odd and cos(nx) is even, then
is odd. Hence
for n ≥ 1, so
For n = 0 the integrand is simply f(x), which is odd, so
Figure 5. Parity can replace half of the integration work. Even functions reinforce across the
symmetric interval, while an odd target function multiplied by an even cosine cancels exactly.
Solution 8: the DC coefficient of x2
Because x2 is even,
| a0 | = ∫
0πx2 dx | (71)
|
| =  0π | (72)
|
| = . | (73) |
Therefore the mean value is
Solution 9: cosine coefficients of x2
Start with
Let
Then
Thus
| ∫
0πx2 cos(nx) dx | = 0π − ∫
0πx sin(nx) dx | (78)
|
| = − ∫
0πx sin(nx) dx, | (79) |
because sin(nπ) = 0.
For the remaining integral, choose
so
Then
| ∫
0πx sin(nx) dx | = 0π + ∫
0π cos(nx) dx | (82)
|
| = − | (83)
|
| = − . | (84) |
Therefore
Finally,
Figure 6. The x2 coefficient calculation requires two integrations by parts. The first removes one
Power of x; the second converts the remaining integral into boundary terms containing
cos(nπ) = (−1)n.
Solution 10: first cosine projection of x2
From Problems 8 and 9,
Therefore
At x = 0,
whereas
At x = π,
while
One harmonic is only a low-order projection, so pointwise agreement is not expected to be
exact.
Solution 11: cosine coefficients of |x|
Because |x| is even,
Thus
For n ≥ 1,
Integrate by parts:
| ∫
0πx cos(nx) dx | = 0π − ∫
0π sin(nx) dx | (96)
|
| = . | (97) |
Therefore
If n is even,
If n is odd,
Solution 12: centered rectangular pulse
The pulse is even. Its constant coefficient is
| a0 | = ∫
0π∕21 dx | (101)
|
| = 1. | (102) |
Thus its mean value is 1∕2.
For n ≥ 1,
| an | = ∫
0π∕2 cos(nx) dx | (103)
|
| = sin . | (104) |
Hence
| a1 | = , | (105)
|
| a2 | = 0, | (106)
|
| a3 | = − , | (107)
|
| a4 | = 0, | (108)
|
| a5 | = . | (109) |
Figure 7. The centered half-duty pulse has alternating nonzero odd cosine coefficients and
vanishing even cosine coefficients. The pattern comes directly from sin(nπ∕2).
Solution 13: centered pulse of arbitrary half-width
Again use evenness. The constant coefficient is
| a0 | = ∫
0αAdx | (110)
|
| = . | (111) |
Therefore the mean value is
For n ≥ 1,
| an | = ∫
0α cos(nx) dx | (113)
|
| = sin(nα). | (114) |
Problem 12 follows by setting
Solution 14: triangular even function
On [0,π],
The constant coefficient is
| a0 | = ∫
0π(π − x)dx | (117)
|
| = π. | (118) |
Hence the mean is π∕2.
For n ≥ 1,
| an | = ∫
0π(π − x) cos(nx)dx. | (119) |
The π cos(nx) term integrates to zero, so
From Problem 11,
Thus
For even n,
For odd n,
Solution 15: general interval [−L,L]
Take
The projection formula gives
FS03 gives
for n ≥ 1. Therefore
For the constant basis function,
The actual constant projection is therefore
Since the Fourier convention writes this constant as a0∕2,
Solution 16: normalized-basis coefficient
The normalized cosine basis function is
Its coordinate is
| cn | =  | (133)
|
| = ∫
−ππf(x) cos(nx)dx. | (134) |
But
Therefore
The two numerical coefficients differ because they multiply differently scaled basis functions:
| an cos(nx) | =   | (137)
|
| = cnϕn(x). | (138) |
The projected function is the same.
5 Additional practice
- For f(x) = 2−3 cos 2x+8 sin 5x+6 cos 6x, isolate the coefficient of cos 6x by integration.
- Compute a0 for f(x) = 5 + cos 7x − 4 sin 2x.
- Show directly that all cosine coefficients of f(x) = x3 vanish on [−π,π].
- Compute a0 and a1 for f(x) = 1 + x2.
- Compute a2 and a3 for f(x) = x2 using the closed formula from Problem 9.
- For f(x) = |x|, evaluate a1,a2,a3,a4.
- For a centered pulse with A = 3 and α = π∕3, compute a0,a1,a2,a3.
- For f(x) = π −|x|, write the constant plus first three nonzero cosine terms.
- On [−2, 2], derive the coefficient multiplying cos(nπx∕2).
- Explain why replacing cos(nx) by 5 cos(nx) changes the projection coefficient but not
the projected function.
6 What these exercises establish
The main lessons are:
- A Fourier cosine coefficient is an ordinary function-space projection coefficient.
- Orthogonality performs the harmonic isolation.
- The factor 1∕π is the reciprocal norm squared of cos(nx) on [−π,π].
- The quantity a0∕2, not a0, is the mean or DC component.
- Evenness can reduce symmetric-interval integrals to twice a half-interval integral.
- Odd functions have no constant or cosine content on a symmetric interval.
- Integration by parts converts polynomial-times-cosine integrals into boundary terms
that reveal coefficient decay and sign patterns.
- Piecewise even functions often produce transparent spectral selection rules such as
vanishing even harmonics.
Figure 8. FS04E1 completes the cosine side of coefficient extraction. FS05 will apply the same
projection logic to sine harmonics and place the cosine, sine, and constant coefficients into one
unified Fourier-series formula.
References
[1] PhysicsLibrary, FS04: Derivation of the Fourier Cosine Coefficients.
[2] PhysicsLibrary, FS03: Orthogonality of Sines and Cosines.
[3] R. V. Churchill and J. W. Brown, Fourier Series and Boundary Value Problems,
McGraw-Hill.
[4] E. Kreyszig, Advanced Engineering Mathematics, Wiley.