Return to computing page for the first course APMA0330
Return to computing page for the second course APMA0340
Return to computing page for the fourth course APMA0360
Return to Mathematica tutorial for the first course APMA0330
Return to Mathematica tutorial for the second course APMA0340
Return to Mathematica tutorial for the fourth course APMA0360
Return to the main page for the first course APMA0330
Return to the main page for the second course APMA0340
Return to the main page for the fourth course APMA0360
Return to Part V of the course APMA0340
Introduction to Linear Algebra with Mathematica

Preface


Differentiation of Fourier Series


Theorem 2:

 

Term-by-term differentiation of infinite series


Not every Fourier series can be term-by-term differentiated, but those that correspond to functions having derivatives expanded into Fourier series. Term-by-term differentiation is not justified for functions having an unbounded jump discontinuity. In mathematics, there is a special class of functions, called absolute continuous that have derivatives almost everywhere.

Suppose that a periodic function f(x) is an integral, i.e., f(x) is absolutely continuous. Integrating by parts gives

\[ \hat{f}(n) = \frac{1}{2\ell} \int_{-\ell}^{\ell} f(x)\, e^{-{\bf j} \pi nx/\ell} {\text d} x = \frac{1}{2n\pi} \int_{-\ell}^{\ell} f' (x)\, e^{-{\bf j} \pi nx/\ell} {\text d} x = \frac{1}{{\bf j}n} \,\hat{f'}(n) , \qquad n\ne 0, \]
so that \( \hat{f'}(n) = {\bf j}n\,\hat{f}(n) , \) where \( \hat{f'}(n) \) is the Fourier coefficient of the derivative of f(x). Since f(x) is periodic, \( \hat{f'}(0) = 0. \) Similar for trigonometric series \eqref{EqFourier.3}, we have
\begin{align*} a_k (f') &= \frac{1}{\ell} \int_{-\ell}^{\ell} f' (x)\,\cos \left( \frac{k\pi x}{\ell} \right) {\text d} x = \left. \frac{1}{\ell} f (x)\,\cos \left( \frac{k\pi x}{\ell} \right)\right\vert_{x=-\ell}^{x=\ell} + \frac{n\pi}{\ell^2} \int_{-\ell}^{\ell} f(x) \,\sin \left( \frac{k\pi x}{\ell} \right) {\text d} x \\ &= \frac{n\pi}{\ell^2} \int_{-\ell}^{\ell} f(x) \,\sin \left( \frac{k\pi x}{\ell} \right) {\text d} x , \\ b_k (f') &= \frac{1}{\ell} \int_{-\ell}^{\ell} f' (x)\,\sin \left( \frac{k\pi x}{\ell} \right) {\text d} x = \left. \frac{1}{\ell} f (x)\,\sin \left( \frac{k\pi x}{\ell} \right)\right\vert_{x=-\ell}^{x=\ell} - \frac{n\pi}{\ell^2} \int_{-\ell}^{\ell} f(x) \,\cos \left( \frac{k\pi x}{\ell} \right) {\text d} x \\ &= \frac{n\pi}{\ell^2} \int_{-\ell}^{\ell} f(x) \,\cos \left( \frac{k\pi x}{\ell} \right) {\text d} x , \end{align*}
because f(−ℓ) = f(ℓ). Thus, if S'[f] denotes the result of differentiating S[f] term by term, we have
\[ f' (x) \sim {\mbox P.V.} \,{\bf j} \sum_{n=-\infty}^{+\infty} n\, \hat{f}(n) \, e^{{\bf j}n\pi x/\ell} = \sum_{k\ge 1} n \left( b_k \cos \frac{k\pi x}{\ell} - a_k \sin \frac{k\pi x}{\ell} \right) . \]
This is precisely what would be obtained by differentiating the Fourier series of f(x) term by term. Hence, even though the Fourier series S[f'] of f'(x) may not converge uniformly or even converge at all, it can still be obtained by differentiating the Fourier series S[f] of f(x) term by term.

Theorem 1: Let 𝑓(π‘₯) be a continuous function defined on [βˆ’ Ο€, Ο€] with an absolutely integrable derivative (which may not exist at certain points). Then its derivative \[ f' (x ) \,\sim\, \frac{c}{2} + \frac{\pi}{\ell}\,\sum_{n\ge 1} \left[ \left( n\,b_n + (-1)^n c\,\ell /\pi \right) \cos \left( \frac{n\pi x}{\ell} \right) - n\,a_n \,\sin \left( \frac{n\pi x}{\ell} \right) \right] , \] where π‘Žₙ and bₙ are the Fourier coefficients of 𝑓(π‘₯) and \( \displaystyle \quad c = \frac{1}{\pi} \left[ f(\pi ) - f(-\pi ) \right] . \)

Let the Fourier series for the derivative of 𝑓(π‘₯) be \[ f' (x) = \frac{1}{2}\,\alpha_0 + \sum_{n\ge 1} \left[ \alpha_n \cos \left( \frac{n\pi x}{\ell} \right) + \beta_n \sin \left( \frac{n\pi x}{\ell} \right) \right] , \] where \[ \alpha_0 = \frac{1}{\ell} \int_{-\ell}^{\ell} \,f'(x)\,{\text d} x = \frac{1}{\ell} \left[ f(\ell ) - f(-\ell ) \right] = c . \] According to section on integration of Fourier series, the integral \( \displaystyle \quad F(x) = \int_0^x \left[ f' (x) - \frac{1}{2}\,\alpha_0 \right] {\text d}x \quad \) can be obtained from the term-by-term integration of the corresponding Fourier series: \begin{align*} F(x) &= \int_0^x \left[ f' (x) - \frac{1}{2}\,\alpha_0 \right] {\text d}x = f(x) - f(0) - \frac{x}{2}\,\alpha_0 \\ &= \int_0^x \left[ \sum_{n\ge 1} \left[ \alpha_n \cos \left( \frac{n\pi x}{\ell} \right) + \beta_n \sin \left( \frac{n\pi x}{\ell} \right) \right] \right] {\text d}x \\ &= \frac{\ell}{\pi}\, \sum_{n\ge 1} \left[ \alpha_n \frac{1}{n}\,\sin \left( \frac{n\pi x}{\ell} \right) -\beta_n \frac{1}{n} \left[ \cos \left( \frac{n\pi x}{\ell} \right) - 1 \right] \right] . \end{align*} Substituting instead of 𝑓(π‘₯) its Fourier series, we obtain \begin{align*} F(x) &= \frac{1}{2}\,a_0 + \sum_{n\ge 1} \left[ a_n \cos \left( \frac{n\pi x}{\ell} \right) + b_n \sin \left( \frac{n\pi x}{\ell} \right) \right] - f(0) - \frac{x}{2}\,\alpha_0 \\ &= \frac{1}{2}\,a_0 + \sum_{n\ge 1} \left[ a_n \cos \left( \frac{n\pi x}{\ell} \right) + b_n \sin \left( \frac{n\pi x}{\ell} \right) \right] - \frac{1}{2}\,a_0 - \sum_{n\ge 1} a_n - \frac{x}{2}\,\alpha_0 \\ &= \frac{\ell}{\pi}\, \sum_{n\ge 1} \left[ \alpha_n \frac{1}{n}\,\sin \left( \frac{n\pi x}{\ell} \right) -\beta_n \frac{1}{n} \left[ \cos \left( \frac{n\pi x}{\ell} \right) - 1 \right] \right] . \end{align*} Expanding π‘₯ into Fourier series yields
2*Integrate[x*Sin[n*Pi*x/L], {x, 0, L}]/L
(2 L (-n \[Pi] Cos[n \[Pi]] + Sin[n \[Pi]]))/(n^2 \[Pi]^2)
\[ -x = \frac{2\ell}{\pi} \,\sum_{n\ge 1} \,\frac{(-1)^n}{n}\,\sin \left( \frac{n\pi x}{\ell} \right) . \] This leads to \begin{align*} F(x) &= \sum_{n\ge 1} \left[ a_n \cos \left( \frac{n\pi x}{\ell} \right) + b_n \sin \left( \frac{n\pi x}{\ell} \right) \right] - \sum_{n\ge 1} a_n + \alpha_0 \, \frac{\ell}{\pi} \,\sum_{n\ge 1} \,\frac{(-1)^b}{n}\,\sin \left( \frac{n\pi x}{\ell} \right) \\ &= \frac{\ell}{\pi}\, \sum_{n\ge 1} \left[ \alpha_n \frac{1}{n}\,\sin \left( \frac{n\pi x}{\ell} \right) -\beta_n \frac{1}{n} \left[ \cos \left( \frac{n\pi x}{\ell} \right) - 1 \right] \right] . \end{align*} By equating common terms, we have \begin{align*} \frac{\ell}{\pi}\,\beta_n &= - n\,a_n , \qquad n=1,2,\ldots ; \\ \frac{\ell}{\pi}\,\alpha_n &= n\,b_n + (-1)^n \alpha_0 \frac{\ell}{\pi} = n\,b_n + (-1)^n c\, \frac{\ell}{\pi} . \end{align*}

Tis theorem tells us that given a function 𝑓(π‘₯) on [βˆ’ℓ, ℓ], the Fourier series of its derivative cannot be generally obtained from the term-by-term differentiation of the Fourier series for 𝑓(π‘₯). However, if 𝑓(−ℓ) = 𝑓(ℓ) or c = 0, then we can differentiate the Fourier series term-by-term.

According to the Riemann--Lebesgue lemma, the Fourier coefficients of a differentiable function satisfy

\[ \lim_{n\to\infty} \, a_n n = \lim_{n\to\infty} \, b_n n = 0. \]
In other words, for a periodic function with an absolutely integrable derivative, its Fourier coefficients vanish faster than 1/𝑛 as 𝑛 β†’ ∞.

Theorem 13: Let 𝑓(π‘₯) be a continuous periodic function, which has π‘š derivatives, where π‘šβˆ’1 derivatives are continuous of the same period and the π‘š-th derivative is absolutely integrable (the π‘š-th derivative may not exist at certain points). Then the Fourier series of all π‘š derivatives can be obtained by term-by-term differentiations of the Fourier series of 𝑓(π‘₯), \( \ S^{(k)}[f] = S[f^{(k)}] , \quad k = 1, 2, \ldots m, \) where 𝑆[𝑓] is the Fourier series for function 𝑓(π‘₯). Moreover, all the series, except possibly the last, converge uniformly to the corresponding derivatives and the Fourier coefficients of the function 𝑓(π‘₯) satisfy the relations
\begin{equation} \label{EqDif.1} \lim_{n\to\infty} \, a_n n^m = \lim_{n\to\infty} \, b_n n^m = 0. \end{equation}
The proof of this theorem is straightforward; it simply involves applying integration by parts successively to all the Fourier series for the derivatives of up to the (π‘š βˆ’ 1)-th order, and recognizing the fact that in the process all the involved derivatives are absolutely integrable and their corresponding series can be directly obtained from term-by-term differentiations.

This Teorem is very useful in that it reveals the intrinsic connection between the smoothness of a periodic function and the convergence characteristic of its Fourier series expansion. In an ideal case, the Fourier series of a periodic analytic function can actually converge at an exponential rate (Tadmor 1986).

However, it must be emphasized that the periodicity is a prerequisite for this convergence theorem to hold. Once the periodicity condition is not met by a func- tion, the convergence of its Fourier series can be seriously deteriorated, even when the function is defined sufficiently smooth on the interval. The following example illustrates this point.

Example 19: Let us consider a function f(x) = x on the interval [0, ℓ]. Its Fourier series is

\[ x = \sum_{n\ge 1} \frac{2\ell}{n\pi} \,(-1)^{n+1} \,\sin \left( \frac{n\pi x}{\ell} \right) , \qquad \ell < x < \ell . \]
You will learn later in the even and odd section how to construct this series and determine the coefficients, but now you have to trust me or plot partial sums to verify the identity. If we differentiate the function on the left-hand side, then we get the function 1. However, if we formally differentiate term by term the function on the right, then we arrive at
\[ 1 \stackrel{?}{=} 2 \sum_{n\ge 1} (-1)^{n+1} \,\cos \left( \frac{n\pi x}{\ell} \right) , \qquad \ell < x < \ell . \]
The series at the left does not converge because its general term does not tern to zero. However, we will see later that if we use another definition of convergence, called CesΓ ro summation, the right-hand side series converges to 1. If we formally apply geometric series formula (see Example 2 in CesΓ ro summation section)
\[ \sum_{n\ge 1} q^n = \frac{q}{1-q} , \qquad \mbox{with} \quad q = -e^{{\bf j}x} , \]
we obtain
\begin{align*} \sum_{n\ge 1} (-1)^{n+1} \,\cos \left( nx \right) &= - \Re \sum_{n\ge 1} (-1)^{n} \, e^{{\bf j}nx} = - \Re \sum_{n\ge 1} \left( -e^{{\bf j}x} \right)^n - \\ &= - \Re \frac{-e^{{\bf j}x}}{1 + e^{{\bf j}x}} = - \Re \frac{-e^{{\bf j}x} \left( 1 + e^{-{\bf j}x} \right)}{\left( 1 + e^{{\bf j}x} \right) \left( 1 + e^{-{\bf j}x} \right)} = - \Re \frac{- e^{{\bf j}x} -1}{2 + 2\,\cos x} \\ &= \Re \frac{1 + e^{{\bf j}x}}{2 \left( 1 + \cos x \right)} = \frac{1 + \cos x}{2 + 2\,\cos x} = \frac{1}{2} . \end{align*}

 

However, wait a minute. There exist another Fourier series for the same function (if you open the same section):
\[ x = \frac{\ell}{2} - \frac{4\ell}{\pi^2} \sum_{n\ge 1} \frac{1}{n^2} \,\cos \left( \frac{n\pi x}{\ell} \right) , \qquad \ell < x < \ell . \]
Fourier sine series of the derivative f'(x) = 1 can be obtained by term-by-term differentiation of the Fourier cosine series of f(x) = x. Assuming that term-by-term differentiation is valid as claimed, it follows that
\[ 1 = \frac{4}{\pi} \sum_{n\ge 1} \frac{1}{n}\, \sin \left( \frac{n\pi x}{\ell} \right) , \qquad \ell < x < \ell , \]
which is, in fact, correct.    ■
End of Example 19

Example 20: The Bernoulli polynomials Bn(x) are solutions of the Appell differential equation

\[ \frac{{\text d} p_n (x)}{{\text d}x} = n\,p_{n-1} (x) , \]
which is similar to the power function. We list a few first Bernoulli polynomials:
\begin{align*} B_0 &= 1, \\ B_1 (x) &= x - \frac{1}{2} , \\ B_2 (x) &= x^2 -x + \frac{1}{6} , \\ B_3 (x) &= x^3 - \frac{3}{2}\, x^2 + \frac{1}{2}\, x , \\ B_4 (x) &= x^4 - 2x^3 + x^2 - \frac{1}{30} , \\ B_5 (x) &= x^5 - \frac{5}{2}\,x^4 + \frac{5}{3}\,x^3 - \frac{1}{6}\, x . \end{align*}
Mathematica has a build-in command for evaluation of Bernoulli polynomials.
Table[BernoulliB[k, x], {k, 0,5}]
So we expand Bernoulli's polynomials of order 3 and 4 into Fourier series
2*Integrate[BernoulliB[4, x]*Cos[Pi*n*x], {x, 0, 1}]/1
-((360 n \[Pi] + 360 n \[Pi] Cos[ n \[Pi]] + (-720 + 60 n^2 \[Pi]^2 + n^4 \[Pi]^4) Sin[n \[Pi]])/( 15 n^5 \[Pi]^5))
\[ a_n \left( B_4 \right) = 2 \int_0^1 B_4 (x)\,\cos (n\pi x)\,{\text d} x = -\frac{24}{n^4 \pi^4} - \frac{24}{n^4 \pi^4}\, (-1)^n = - \frac{48}{n^4 \pi^4} \times \begin{cases} 1, & \ \mbox{ if} \quad n = 2k , \\ 0, & \ \mbox{ if} \quad n = 2k +1. \end{cases} \]
Therefore,
\[ B_4 (x) = x^4 - 2x^3 + x^2 - \frac{1}{30} = - \frac{3}{\pi^4} \sum_{k\ge 1} \frac{1}{k^4}\,\cos \left( 2k\pi x \right) . \]
      We plot with Mathematica:
s20[x_] = -3/(1*Pi^4)*Sum[Cos[2*k*Pi*x]/k^4, {k, 1, 20}]; Plot[{BernoulliB[4, x], s20[x]}, {x, -0.2, 1.2}, PlotStyle -> Thickness[0.01]]
        20 term Fourier approximation to Bernoulli's polynomial B4(x).            Mathematica code

Now we expand Bernoulli's polynomial of order 3 into Fourier series
2*Integrate[BernoulliB[3, x]*Sin[Pi*n*x], {x, 0, 1}]/1
(6 n \[Pi] + 6 n \[Pi] Cos[n \[Pi]] + (-12 + n^2 \[Pi]^2) Sin[ n \[Pi]])/(n^4 \[Pi]^4)
\[ b_n \left( B_3 \right) = 2 \int_0^1 B_3 (x)\,\sin (n\pi x)\,{\text d} x = \frac{6}{n^3 \pi^3} + \frac{6}{n^3 \pi^3}\, (-1)^n = \frac{12}{n^3 \pi^3} \times \begin{cases} 1, & \ \mbox{ if} \quad n = 2k , \\ 0, & \ \mbox{ if} \quad n = 2k +1. \end{cases} \]
This yields
\[ B_3 (x) = x^3 - \frac{3}{2}\, x^2 + \frac{1}{2}\, x = \frac{3}{2\pi^3} \sum_{k\ge 1} \frac{1}{k^3}\,\sin \left( 2k\pi x \right) . \]
      We plot with Mathematica:
s20[x_] = 3/(2*Pi^3)*Sum[Sin[2*k*Pi*x]/k^4, {k, 1, 20}]; Plot[{BernoulliB[3, x], s20[x]}, {x, -0.2, 1.2}, PlotStyle -> Thickness[0.01]]
        20 term Fourier approximation to Bernoulli's polynomial B3(x).            Mathematica code

Term-by-term differentiation gives

\[ \frac{\text d}{{\text d}x}\, B_4 (x) = \frac{\text d}{{\text d}x}\left( x^4 - 2x^3 + x^2 - \frac{1}{30} \right) = 4\, B_3 (x) = 4 \left( x^3 - \frac{3}{2}\, x^2 + \frac{1}{2}\, x \right) = \frac{6}{\pi^3} \sum_{k\ge 1} \frac{1}{k^3}\,\sin \left( 2k\pi x \right) . \]
   ■
End of Example 20

Theorem 14: Suppose that f(x) has discontinuities of the first kind (finite jumps) at the points 0 < x1 < x2 < ··· < xm < 2π, and that f(x) is absolutely continuous in each of the subintervals (xi, xi+1), if completed by continuoity at the end points xi, xi+1. Let
\[ d_i = \frac{1}{\pi} \left[ f( x_i +0) - f(x_i -0) \right] , \qquad \delta (x) = \frac{1}{2} + \sum_{k\ge 1} \cos (kx) . \]
Then
\[ S' [f] - S[ f' ] = d_1 \delta \left( x- x_1 \right) + d_2 \delta \left( x- x_2 \right) + \cdots + d_m \delta \left( x- x_m \right) . \]
The series for the delta-function diverges for every x, but it is CesΓ ro summable to zero for every x ≠ 0; it is also converges in weak sense.
We may assume that \( f(x_i ) = \frac{1}{2} \left[ f(x_i +0) + f(x_i -0) \right] \) for all i. Let
\[ \phi (x) = \frac{\pi -x}{2} = \sum_{k\ge 1} \frac{\sin (kx)}{k} = \mbox{P.V.} \frac{1}{2} \sum_{n=-\infty}^{+\infty} \frac{1}{{\bf j}n} \,e^{{\bf j}nx}, \qquad 0 < x < 2\pi . \]
Then
\[ S'[\phi ] = \delta (x) - \frac{1}{2} . \]
The function
\[ \Phi (x) = d_1 \phi \left( x - x_1 \right) + d_2 \phi \left( x - x_2 \right) + \cdots + d_m \phi \left( x - x_m \right) \]
has the same points of discontinuity and the same jumps, as f(x). The difference g(x) = f(x) − Φ(x) is therefore continuous, indeed, absolutely continuous. Moreover,
\[ \Phi' (x) = -\frac{1}{2} \left( d_1 + d_2 + \cdots + d_m \right) = C \]
say, except at the points xi. so that \( g' = f' - C \) almost everywhere. Now
\begin{align*} S' [f] &= S' \left[ g + \Phi \right] = S' [f] + S' [\Phi ] \\ &= S[f' ] - C + \sum_i d_i \left[ \delta (x- x_i ) - \frac{1}{2} \right] = S[f' ] + \sum_i d_i \delta (x- x_i ) . \end{align*}

Example 21: Let us consider the function

\[ f(x) = \begin{cases} x+1 , & \ \mbox{ for} \quad -1 < x < 0 , \\ -x , & \ \mbox{ for} \quad 0 < x < 1 . \end{cases} \]
Its Fourier series is    ■
End of Example 21

 

 

  1. Gonzalez-Velasco, E.A., Fourier Analysis and Boundary Value Problems, 1996, Academic Press, San Diego, CA.
  2. Hardy, G.H. and Rogosinski W.W., Fourier series, Dover Publications, 2013.
  3. Iserles, A., and S. P. NΓΈrsett. 2008. From high oscillation to rapid approximation I: Modified Fourier expansions. IMA Journal of Numerical Analysis 28: 862–887.
  4. Tadmor, E. 1986. The exponential accuracy of Fourier and Chebyshev differencing methods. SIAM Journal on Numerical Analysis 23: 1--10.

 

Return to Mathematica page
Return to the main page (APMA0340)
Return to the Part 1 Matrix Algebra
Return to the Part 2 Linear Systems of Ordinary Differential Equations
Return to the Part 3 Non-linear Systems of Ordinary Differential Equations
Return to the Part 4 Numerical Methods
Return to the Part 5 Fourier Series
Return to the Part 6 Partial Differential Equations
Return to the Part 7 Special Functions