Artificial Intelligence 🤖
Power & Fourier Series
The coefficients

The coefficients

The idea behind the derivation of the Fourier coefficients is as follows: we start from the Fourier series expansion of a periodic function, f(x)f(x), as in Eq. (1.3) and multiply the whole expression by a function that is orthogonal to the coefficient of ana_{n} (if we want to derive ana_{n} ) or bnb_{n} (if we want to derive bnb_{n} ). Then, the orthogonality property [see Eq. (1.9)] suggests that upon integration of the expression on the interval [π,π][-\pi, \pi], all terms but one will vanish, allowing us to isolate the coefficients ana_{n} or bnb_{n}. In what follows, we determine ana_{n} in detail and summarise the method for a0a_{0} and bnb_{n}.

Derivation

Determining ana_{n} where n1n \geq 1

Step 1: Multiply (1.3) by a set of functions that is mutually orthogonal to the coefficient of ana_{n} [i.e. cos(mx)\cos (m x) ]. We therefore multiply both sides of (1.3) by cos(mx)\cos (m x) :

f(x)cos(mx)=a02cos(mx)+n=1ancos(nx)cos(mx)+bnsin(nx)cos(mx),f(x) \cos (m x)=\frac{a_{0}}{2} \cos (m x)+\sum_{n=1}^{\infty} a_{n} \cos (n x) \cos (m x)+b_{n} \sin (n x) \cos (m x),

Step 2: Integrate (1.17) between π-\pi to π\pi :

ππf(x)cos(mx)dx=a02ππcos(mx)dx+ππn=1ancos(nx)cos(mx)+bnsin(nx)cos(mx)dx.\begin{aligned} \int_{-\pi}^{\pi} f(x) \cos (m x) d x & =\frac{a_{0}}{2} \int_{-\pi}^{\pi} \cos (m x) d x \\ + & \int_{-\pi}^{\pi} \sum_{n=1}^{\infty} a_{n} \cos (n x) \cos (m x)+b_{n} \sin (n x) \cos (m x) d x . \end{aligned}

Since f(x)f(x) is an arbitrary periodic function at this point, we leave the LHS of (1.18) as it is. The first term on the RHS (in blue) will be straightforward to deal with so what we are concerned with are the summation terms that are being integrated with respect to xx (shown in red). Let's deal with these next. It is possible to swap the order of the integral and the summation such that:

ππn=1ancosnxcosmx+bnsinnxcosmxdx=n=1(ππancosnxcosmx+bnsinnxcosmxdx).\begin{aligned} & \int_{-\pi}^{\pi} \sum_{n=1}^{\infty} a_{n} \cos n x \cos m x+b_{n} \sin n x \cos m x d x \\ = & \sum_{n=1}^{\infty}\left(\int_{-\pi}^{\pi} a_{n} \cos n x \cos m x+b_{n} \sin n x \cos m x d x\right) . \end{aligned}

Note: This can always be done if the series is finite. There are certain conditions for which the swapping can be done for infinite series (this is related to Fubini's theorem, which will be discussed in Topic A2 with Prof. Matar). Here, we assume we can in fact integrate the sum term by term and hence, Eq. (1.18) becomes:

ππf(x)cos(mx)dx=a02ππcos(mx)dx+n=1anππcos(nx)cos(mx)dx+n=1bnππsin(nx)cos(mx)dx\begin{aligned} \int_{-\pi}^{\pi} f(x) \cos (m x) d x & =\frac{a_{0}}{2} \int_{-\pi}^{\pi} \cos (m x) d x \\ & +\sum_{n=1}^{\infty} a_{n} \int_{-\pi}^{\pi} \cos (n x) \cos (m x) d x \\ & +\sum_{n=1}^{\infty} b_{n} \int_{-\pi}^{\pi} \sin (n x) \cos (m x) d x \end{aligned}

Evaluating each integral on the RHS,

a02ππcos(mx)dx=0\frac{a_{0}}{2} \int_{-\pi}^{\pi} \cos (m x) d x=0

Next,

anππcos(nx)cos(mx)dx={0 for nmanπ for n=m,a_{n} \int_{-\pi}^{\pi} \cos (n x) \cos (m x) d x=\left\{\begin{array}{ll} 0 & \text { for } n \neq m \\ a_{n} \pi & \text { for } n=m \end{array},\right.

and,

bnππsin(nx)cos(mx)dx=0b_{n} \int_{-\pi}^{\pi} \sin (n x) \cos (m x) d x=0

Again, the results in Eqs. (1.22) and (1.23) may be shown using the relations in (1.7a)-(1.7c). Substituting Eqs. (1.21)-(1.23) in Eq. (1.20), yields,

ππf(x)cos(mx)dx=amπ\int_{-\pi}^{\pi} f(x) \cos (m x) d x=a_{m} \pi

Finally, noticing that mm is simply an index letter, we can replace mm by nn yileding the Fourier coefficient, ana_{n} :

an=1πππf(x)cos(nx)dx.a_{n}=\frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos (n x) d x .

Determining a0a_{0}

We integrate (1.3) between π-\pi to π\pi and, using the orthogonality relations, we can show that the terms multiplying the ana_{n} and bnb_{n} coefficients vanish leaving us with:

ππf(x)cos(nx)dx=a02ππ1dx=a0π.\int_{-\pi}^{\pi} f(x) \cos (n x) d x=\frac{a_{0}}{2} \int_{-\pi}^{\pi} 1 d x=a_{0} \pi .

Solving for a0a_{0} gives:

a0=1πππf(x)dxa_{0}=\frac{1}{\pi} \int_{-\pi}^{\pi} f(x) d x

Determining bnb_{n} where n1n \geq 1

Similarly to the method used to obtain ana_{n} (for n1n \geq 1 ), to determine bnb_{n}, we multiply (1.3) by sinmx\sin m x and integrate between π-\pi and π\pi. Applying orthogonality relations and upon simplifying, yields

bn=1πππf(x)sin(nx)dx.b_{n}=\frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \sin (n x) d x .

Consider a function, f(x)f(x) satisfying the periodicity condition [given by Eq. (1.4) ] then, its Fourier series is given by Eq. (1.3) and the coefficients a0,ana_{0}, a_{n} and bnb_{n} are determined using Eqs. (1.25), (1.27) and (1.28), respectively. Note that Eq. (1.27) may be recovered from (1.25) if n=0n=0. These results are summarised in the box below.

Definition 1.3 The Fourier series of a periodic function f(x)f(x) defined on [π,π][-\pi, \pi] is given as:

f(x)=a02+n=1ancos(nx)+bnsin(nx),f(x)=\frac{a_{0}}{2}+\sum_{n=1}^{\infty} a_{n} \cos (n x)+b_{n} \sin (n x),

where the Fourier coefficients are given by:

an=1πππf(x)cos(nx)dxn0a_{n}=\frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos (n x) d x \quad n \geq 0

and

bn=1πππf(x)sin(nx)dxn1b_{n}=\frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \sin (n x) d x \quad n \geq 1

Even/odd coefficients

Given a periodic function, f(x)f(x), we can represent it using the Fourier series expansion by calculating the coefficients derived in the previous section. The work involved may be reduced significantly if the function f(x)f(x) is odd or even. If the function f(x)f(x) is odd then the Fourier series will represent an expansion in sine modes only and therefore all even coefficients, ana_{n} are zero-valued:

 for odd f(x)an=0 for all integer n\text { for odd } f(x) \Longrightarrow a_{n}=0 \text { for all integer } n

If the function f(x)f(x) is even, then the Fourier series will represent a series expansion of cosine modes only and therefore all odd coefficients, bnb_{n} are zerovalued:

 for even f(x)bn=0 for n1\text { for even } f(x) \Longrightarrow b_{n}=0 \text { for } n \geq 1 \text {. }

If the function is neither odd nor even then we need to compute a0a_{0} and all coefficients ana_{n} and bnb_{n}. We look at an example next.

Example 1.1 Find the Fourier series of f(x)=xf(x)=x defined in [π,π][-\pi, \pi].

Solution For a function f(x)f(x) to have a Fourier series representation, it must be periodic. We have the following periodicity condition: f(x+2π)=f(x)f(x+2 \pi)=f(x). This implies that every 2π2 \pi, the function repeats it self (see Sec. 1.4 for more details on periodic extension). We need to determine the even coefficients ana_{n} (for n0n \geq 0 ) and the odd coefficients bnb_{n} (for n1n \geq 1 ). We check whether the function is odd, even or neither:

f(x)=x=f(x) function is odd. f(-x)=-x=-f(x) \rightarrow \text { function is odd. }

Since the function is odd, the even coefficients are zero an=0,n\rightarrow a_{n}=0, \forall n. We only need to compute the odd coefficients, bnb_{n}. Using Eq. (1.31), we have:

bn=1πππxodd sin(nx)odd dx=2π0πxsin(nx)even dx=2ncos(nπ) using integration by parts; \begin{aligned} b_{n} & =\frac{1}{\pi} \int_{-\pi}^{\pi} \underbrace{x}_{\text {odd }} \underbrace{\sin (n x)}_{\text {odd }} d x \\ & =\frac{2}{\pi} \int_{0}^{\pi} \underbrace{x \sin (n x)}_{\text {even }} d x \\ & =-\frac{2}{n} \cos (n \pi) \quad \text { using integration by parts; } \end{aligned}

but, cos(nπ)=(1)n\cos (n \pi)=(-1)^{n} (this is a useful result to remember) and therefore bnb_{n} are given by:

bn=2(1)n+1n.b_{n}=\frac{2(-1)^{n+1}}{n} .

Substituting an=0a_{n}=0 (for n0n \geq 0 ) and bn=2(1)n+1nb_{n}=\frac{2(-1)^{n+1}}{n} (for n1n \geq 1 ) in Eq. (1.29), we have:

x=n=12(1)n+1nsin(nx).x=\sum_{n=1}^{\infty} \frac{2(-1)^{n+1}}{n} \sin (n x) .

Extension to arbitrary intervals

So far, we have looked at functions which are defined on an interval [π,π][-\pi, \pi] with periodic extension 2π2 \pi. We want to look at situations where the function is defined on an arbitrary interval [L,L][-L, L], where Lπ,L>0L \neq \pi, L>0, with a periodic extension of 2L2 L. We achieve this through a change of interval. If we introduce a new variable,

t=πxL,t=\frac{\pi x}{L},

and define a new function, g(t)g(t) such that g(t)=f(x)g(t)=f(x), then g(t)g(t) is defined on [π,π][-\pi, \pi]. If f(x)f(x) is periodic with period 2L2 L, then g(t)g(t) is periodic with period 2π2 \pi. If f(x)f(x) is piecewise continuous with continuous derivatives, so is g(t)g(t). Hence, following Definition 1.3, the Fourier series of g(t)g(t) is given by:

g(t)=a02+n=1ancos(nt)+bnsin(nt),g(t)=\frac{a_{0}}{2}+\sum_{n=1}^{\infty} a_{n} \cos (n t)+b_{n} \sin (n t),

where the Fourier coefficients are given by:

an=1πππg(t)cos(nt)dtn0,a_{n}=\frac{1}{\pi} \int_{-\pi}^{\pi} g(t) \cos (n t) d t \quad n \geq 0,

and

bn=1πππg(t)sin(nt)dtn1.b_{n}=\frac{1}{\pi} \int_{-\pi}^{\pi} g(t) \sin (n t) d t \quad n \geq 1 .

Now, by undoing the change of variable, the formulae given in Eqs. (1.33)(1.35) become:

f(x)=a02+n=1ancos[nπxL]+bnsin[nπxL],f(x)=\frac{a_{0}}{2}+\sum_{n=1}^{\infty} a_{n} \cos \left[\frac{n \pi x}{L}\right]+b_{n} \sin \left[\frac{n \pi x}{L}\right],

where,

an=1LLLf(x)cos[nπxL]dxn0a_{n}=\frac{1}{L} \int_{-L}^{L} f(x) \cos \left[\frac{n \pi x}{L}\right] d x \quad n \geq 0

and

bn=1LLLf(x)sin[nπxL]dxn1.b_{n}=\frac{1}{L} \int_{-L}^{L} f(x) \sin \left[\frac{n \pi x}{L}\right] d x \quad n \geq 1 .

The constants ana_{n} and bnb_{n} (Eqs. (1.37) and (1.38), respectively) are the Fourier coefficients of f(x)f(x) on [L,L][-L, L] and Eq. (1.36) is the Fourier series of f(x)f(x) on [L,L][-L, L]. Example 1.2 Find the Fourier series of the function f(x)f(x) defined as:

f(x)={1, if 4x52 if 5<x6f(x)=\left\{\begin{array}{ccc} 1, & \text { if } \quad 4 \leq x \leq 5 \\ 2 & \text { if } \quad 5<x \leq 6 \end{array}\right.

Solution Observe that the interval is defined on [4,6] while Eqs. (1.36)(1.38) are defined on [L,L][-L, L]. We still use Eqs. (1.36)-(1.38) but we shift them to reflect the interval [4,6][4,6]. Let us first deal with the argument of the sine and cosine functions, i.e. nπxL\frac{n \pi x}{L}. The constant LL represents half the periodic extension so L=12(64)=1L=\frac{1}{2}(6-4)=1. The lower limit in Eqs. (1.37)(1.38) is L=1-L=-1; since the left boundary is equal to 4 , we need to shift xx by 5 units to the right x5\Rightarrow x-5. With L=1L=1 and the aforementioned shift, the argument becomes nπ(x5)n \pi(x-5). We have the following equations:

f(x)=a02+n=1ancos[nπ(x5)]+bnsin[nπ(x5)],an=46f(x)cos[nπ(x5)]dxn0,bn=46f(x)sin[nπ(x5)]dxn1.\begin{aligned} f(x) & =\frac{a_{0}}{2}+\sum_{n=1}^{\infty} a_{n} \cos [n \pi(x-5)]+b_{n} \sin [n \pi(x-5)], \\ a_{n} & =\int_{4}^{6} f(x) \cos [n \pi(x-5)] d x \quad n \geq 0, \\ b_{n} & =\int_{4}^{6} f(x) \sin [n \pi(x-5)] d x \quad n \geq 1 . \end{aligned}

For n=0,a0=451dx+562dx=3n=0, \quad a_{0}=\int_{4}^{5} 1 d x+\int_{5}^{6} 2 d x=3,

For n1,an=45cos[nπ(x5)]dx+562cos[nπ(x5)]dxn \geq 1, \quad a_{n}=\int_{4}^{5} \cos [n \pi(x-5)] d x+\int_{5}^{6} 2 \cos [n \pi(x-5)] d x,

=0=0 bn=45sin[nπ(x5)]dx+562sin[nπ(x5)]dx,={0, if n is even 2nπ if n is odd \begin{aligned} b_{n} & =\int_{4}^{5} \sin [n \pi(x-5)] d x+\int_{5}^{6} 2 \sin [n \pi(x-5)] d x, \\ & =\left\{\begin{array}{l} 0, \text { if } n \text { is even } \\ \frac{2}{n \pi} \text { if } n \text { is odd } \end{array}\right. \end{aligned}

We distinguish between even and odd nn by setting 2n2 n for even and 2n12 n-1 for odd. This allows us to include only the nonzero terms of the Fourier expansion as follows:

f(x)=32+2πn=11(2n1)sin[(2n1)π(x5)]f(x)=\frac{3}{2}+\frac{2}{\pi} \sum_{n=1}^{\infty} \frac{1}{(2 n-1)} \sin [(2 n-1) \pi(x-5)]