Derivation of the Fourier Cosine Coefficients
The previous articles built the machinery required for Fourier coefficient extraction. FS02
introduced the function inner product and projection coefficient. FS03 proved that the
functions
are mutually orthogonal on [−π,π], and that every sine harmonic is orthogonal to every cosine
harmonic there.
This article now uses those facts to derive the cosine coefficients of a Fourier series from first
principles. The central idea is simple:
| multiply by the harmonic you want, | (2)
|
| integrate over a full period, | (3)
|
| and let orthogonality remove the others. | (4) |
The algebra deserves to be seen slowly, because the same mechanism appears throughout Fourier
analysis, eigenfunction expansions, normal modes, and quantum mechanics.
Figure 1. Fourier coefficient extraction is function-space projection. The coefficient of a cosine
harmonic is found by measuring the component of f along that harmonic.
1 What we are trying to determine
For now, work on the interval
A real trigonometric expansion has the form
The quantities
measure the constant and cosine content, while
measure the sine content.
In FS04 our main goal is to derive
and to understand why this formula is a projection formula rather than a rule to memorize.
We will also derive the constant coefficient
The full derivation of the sine coefficients is reserved for FS05.
2 First work with a finite trigonometric polynomial
There is a subtle mathematical point worth handling cleanly.
If we begin immediately with an infinite Fourier series and integrate term by term, we have already
assumed that interchanging the sum and the integral is legitimate. The conditions under which this
is allowed belong to the later convergence articles.
So begin with the finite expression in Equation (6). For a finite sum there is no difficulty:
integration distributes across the sum exactly.
Assume therefore that
We ask:
3 Choose the cosine harmonic we want
Suppose we want the coefficient am multiplying
Multiply both sides of Equation (11) by cos(mx):
| f(x) cos(mx) | = cos(mx) | (14)
|
| + ∑
n=1Na
n cos(nx) cos(mx) | (15)
|
| + ∑
n=1Nb
n sin(nx) cos(mx). | (16) |
Nothing has been integrated yet. We have only multiplied the entire expansion by the basis
function whose coefficient we want.
Figure 2. The extraction procedure has two deliberate operations: multiply the entire expansion
by the target harmonic and then integrate across one complete symmetric period.
4 Integrate across the full interval
Integrate Equation (16) from −π to π:
| ∫
−ππf(x) cos(mx) dx | = ∫
−ππ cos(mx) dx | (17)
|
| + ∫
−ππ ∑
n=1Na
n cos(nx) cos(mx) dx | (18)
|
| + ∫
−ππ ∑
n=1Nb
n sin(nx) cos(mx) dx. | (19) |
Because the sums are finite, move the integrals through the sums:
| ∫
−ππf(x) cos(mx) dx | = ∫
−ππ cos(mx) dx | (20)
|
| + ∑
n=1Na
n ∫
−ππ cos(nx) cos(mx) dx | (21)
|
| + ∑
n=1Nb
n ∫
−ππ sin(nx) cos(mx) dx. | (22) |
Equation (22) is the crucial line. FS03 tells us the value of every integral on the right-hand
side.
5 The constant term disappears
For any positive integer m,
Therefore
The constant component cannot contaminate the measurement of a nonzero cosine harmonic
because the constant basis function and cos(mx) are orthogonal.
6 Every sine term disappears
FS03 proved
for all positive integers m and n.
Consequently,
So none of the sine coefficients affects the extraction of am.
7 All the wrong cosine harmonics disappear
The cosine-cosine orthogonality relation is
The sum
therefore contains many zero terms.
Write a small portion explicitly:
| a1 ∫
−ππ cos x cos(mx) dx | (29)
|
| + a2 ∫
−ππ cos 2x cos(mx) dx | (30)
|
| +  | (31)
|
| + am ∫
−ππ cos 2(mx) dx | (32)
|
| +  | (33)
|
| + aN ∫
−ππ cos Nx cos(mx) dx. | (34) |
Every term with n≠m is zero.
Only the n = m term survives:
But FS03 also established
Hence the entire cosine sum reduces to
Figure 3. Orthogonality acts like a harmonic filter. The constant term, all sine harmonics, and all
cosine harmonics except the selected mth cosine give zero inner product with cos(mx).
8 The surviving equation
Substitute Equations (24), (26), and (37) into Equation (22).
We obtain
Now divide both sides by π:
This is the Fourier cosine-coefficient formula on [−π,π].
The result was not guessed. It followed from three facts:
- the cosine harmonics are mutually orthogonal,
- sine harmonics are orthogonal to cosine harmonics,
- the squared norm of cos(mx) on [−π,π] is π.
9 The same result as a projection formula
FS02 derived the coefficient for projection of a function f onto a nonzero basis function
ϕ:
Choose
Then
and
Therefore
| cm | =  | (44)
|
| = am. | (45) |
Thus the Fourier cosine coefficient is exactly the ordinary function-space projection coefficient onto
cos(mx).
This is the deeper meaning of Equation (39).
10 Why the denominator is π
It is tempting to memorize the factor 1∕π. It is better to understand where it comes
from.
The denominator is simply the squared norm of the basis function:
If we instead used the normalized basis function
then
The corresponding normalized-basis coefficient would simply be
Because
and
the two descriptions contain the same information.
11 Deriving the constant coefficient a0
The constant term must be handled separately because its basis function is
rather than cos(mx) with m ≥ 1.
Start again from
This time multiply by 1. That changes nothing:
Integrate from −π to π:
| ∫
−ππf(x) dx | = ∫
−ππ1 dx | (55)
|
| + ∑
n=1Na
n ∫
−ππ cos(nx) dx | (56)
|
| + ∑
n=1Nb
n ∫
−ππ sin(nx) dx. | (57) |
All sine and cosine integrals vanish over the complete symmetric period.
Also,
Therefore
| ∫
−ππf(x) dx | = (2π) | (59)
|
| = πa0. | (60) |
Hence
Figure 4. The constant component is the projection of f onto the constant basis function. The
Fourier convention writes this projection as a0∕2.
12 Why the series contains a0∕2 instead of a0
This convention often looks arbitrary until it is compared with the nonzero harmonics.
The projection coefficient onto the constant basis function 1 is
Now
Thus
But Equation (61) gives
Therefore
So the actual constant component in the Fourier series is
The right-hand side is precisely the average value of f over an interval of length 2π.
Therefore the term
is the DC component, or mean value, of the periodic function.
13 Formal definitions
13.1 Fourier cosine coefficient
For positive integer n, the Fourier cosine coefficient of f on [−π,π] is
It is the projection coefficient of f onto the non-normalized basis function cos(nx).
13.2 Constant Fourier coefficient
The constant Fourier coefficient is
The constant term appearing in the Fourier series is a0∕2.
13.3 DC component
The DC component is the mean value of the function over one complete period. On
[−π,π],
13.4 Harmonic coefficient extraction
Harmonic coefficient extraction is the procedure of multiplying a function by a selected basis
harmonic, integrating over a complete orthogonality interval, and dividing by the squared norm of
that basis harmonic.
13.5 Cosine projection coefficient
The cosine projection coefficient onto cos(nx) is
On [−π,π], this quantity equals an.
14 Example 1: extracting a coefficient from a known finite sum
Let
Find a3 using the integral formula, even though the answer can already be read from the
expression.
Start with
Substitute f:
| a3 | = ∫
−ππ cos 3xdx. | (75) |
Distribute:
| a3 | =  5 ∫
−ππ cos 3xdx | (76)
|
| + 2 ∫
−ππ cos x cos 3xdx | (77)
|
| − 4 ∫
−ππ sin 2x cos 3xdx | (78)
|
| + 7 ∫
−ππ cos 23xdx . | (79) |
The first three integrals are zero by orthogonality. The final integral is π.
Thus
| a3 | = [7π] | (80)
|
| = 7. | (81) |
The integral has isolated the third cosine harmonic exactly.
15 Example 2: x2 on [−π,π]
Consider
We first calculate a0:
| a0 | = ∫
−ππx2 dx. | (83) |
Because x2 is even,
| a0 | = ∫
0πx2 dx | (84)
|
| =  0π | (85)
|
| =   | (86)
|
| = . | (87) |
Therefore the constant term is
Now find an for n ≥ 1:
| an | = ∫
−ππx2 cos(nx) dx | (89)
|
| = ∫
0πx2 cos(nx) dx. | (90) |
The remaining integral requires integration by parts twice.
Let
Then
Hence
| ∫
0πx2 cos(nx) dx | = 0π − ∫
0πx sin(nx) dx. | (93) |
Because
the boundary term vanishes:
Integrate again. Let
Then
Therefore
| ∫
0πx sin(nx) dx | = 0π + ∫
0π cos(nx) dx. | (98) |
The last integral is zero, so
| ∫
0πx sin(nx) dx | = − | (99)
|
| = − . | (100) |
Insert this into Equation (95):
| ∫
0πx2 cos(nx) dx | = − ![[ π(− 1)n]
− --------
n](https://images.physicslibrary.org/cache/objects/1537/make4ht/DerivationOfTheFourierCosineCoefficients87x.png) | (101)
|
| = . | (102) |
Finally use Equation (90):
Thus the cosine coefficients are
Figure 5. The cosine coefficients of x2 alternate in sign and decay like 1∕n2. The coefficient
pattern already hints at the later connection between smoothness and spectral decay.
16 Example 3: an even rectangular pulse
Define a 2π-periodic function by specifying one period:
The value at the two jump points will not affect the coefficient integrals.
First find a0:
| a0 | = ∫
−ππf(x) dx | (107)
|
| = ∫
−π∕2π∕21 dx | (108)
|
| =   | (109)
|
| = 1. | (110) |
So the mean value is
Now calculate an:
| an | = ∫
−ππf(x) cos(nx) dx | (112)
|
| = ∫
−π∕2π∕2 cos(nx) dx. | (113) |
Integrate:
| an | =  −π∕2π∕2 | (114)
|
| =  . | (115) |
Because sine is odd,
so
This immediately gives
| a1 | = , | (118)
|
| a2 | = 0, | (119)
|
| a3 | = − , | (120)
|
| a4 | = 0, | (121)
|
| a5 | = . | (122) |
Only odd cosine harmonics survive for this particular pulse.
Figure 6. A centered rectangular pulse has a nonzero mean and an alternating sequence of odd
cosine coefficients, while the even cosine harmonics vanish.
17 Example 4: an odd function has zero cosine coefficients
Consider
on [−π,π].
For n ≥ 1,
Now x is odd and cos(nx) is even. Therefore the product
is odd.
Hence
so
Also,
Thus an odd function has no constant or cosine component on a symmetric interval.
A systematic treatment of even and odd symmetry appears later in FS09. Here the example simply
demonstrates how symmetry can make a coefficient integral vanish before any antiderivative is
computed.
18 From coefficients to a cosine spectrum
Once the numbers
have been calculated, they can be plotted against harmonic number n.
Such a plot is a discrete cosine spectrum.
It answers the question:
Large |an| means a strong cosine projection at harmonic n. Small |an| means a weak projection. A
zero coefficient means the function is orthogonal to that cosine harmonic over the chosen
interval.
Figure 7. Fourier cosine coefficients may be viewed as coordinates of the function along the
orthogonal cosine directions. Plotting coefficient amplitude against harmonic number produces a
discrete spectrum.
19 The general projection pattern
The derivation can now be summarized without referring specifically to cosine.
Suppose
are mutually orthogonal basis functions and
Take the inner product with ϕm:
Use linearity:
Orthogonality eliminates all terms except n = m:
Therefore
The Fourier cosine coefficient formula is simply this statement with
20 A short preview of a general interval
FS06 will derive the full rescaling carefully. For orientation, on [−L,L] the cosine basis
becomes
Its squared norm is
Therefore the corresponding projection coefficient is
The factor 1∕L plays exactly the same role that 1∕π plays on [−π,π].
21 What has and has not been proved
The calculations above rigorously extract coefficients from a finite trigonometric polynomial.
For a more general function f, the same integrals define its Fourier coefficients. However, several
deeper questions remain:
- Does the resulting infinite Fourier series converge?
- If it converges, does it converge to f?
- What happens at a discontinuity?
- In what sense can a non-smooth function be represented by the series?
- When is term-by-term integration or differentiation justified?
Those questions are postponed deliberately to the convergence part of the FS sequence.
At this stage, the important result is that orthogonal projection gives a unique and natural number
measuring the cosine content of f.
22 Common mistakes
- Forgetting the factor 1∕π in an on [−π,π].
- Assuming the 1∕π factor is arbitrary rather than recognizing it as the reciprocal squared
norm of cos(nx).
- Forgetting that the constant basis function has squared norm 2π, not π.
- Writing the Fourier series with a0 as the constant term instead of a0∕2 under the
standard convention used here.
- Confusing the coefficient a0 with the mean value. The mean value is a0∕2.
- Multiplying by cos(mx) but failing to integrate over the full orthogonality interval.
- Assuming every product integral vanishes. The selected equal-frequency cosine product
has integral π rather than zero.
- Using sine-cosine orthogonality on an interval where the required symmetry or
full-period condition is absent.
- Reading a coefficient from a graph without remembering that its sign matters.
- Treating coefficient extraction as an unrelated Fourier trick instead of recognizing the
projection formula from FS02.
23 Self-check questions
- Why do we multiply by cos(mx) when trying to determine am?
- Why does the constant term disappear from the am derivation for m ≥ 1?
- Why do all sine terms disappear?
- What is special about the n = m cosine term?
- Where does the denominator π come from?
- What is the difference between a0 and the DC component?
- Why is it mathematically cleaner to perform the first derivation with a finite
trigonometric sum?
- Explain the coefficient formula using the language of function projection.
- If f is odd on [−π,π], what can you say about all its cosine coefficients?
- What changes in the coefficient denominator when the interval becomes [−L,L]?
24 Summary
For m ≥ 1, multiplying a trigonometric expansion by cos(mx) and integrating over [−π,π]
gives
Therefore
The constant coefficient is
while the actual constant or DC term in the series is
Most importantly,
The Fourier cosine coefficient is therefore a projection coordinate in function space.
References
[1] R. V. Churchill and J. W. Brown, Fourier Series and Boundary Value Problems,
McGraw-Hill.
[2] E. Kreyszig, Advanced Engineering Mathematics, Wiley.
[3] G. B. Arfken, H. J. Weber, and F. E. Harris, Mathematical Methods for Physicists,
Academic Press.
[4] M. L. Boas, Mathematical Methods in the Physical Sciences, Wiley.