Fourier series are very suitable for representing a periodic function with period #2\pi# in terms of the trigonometric functions cosine and sine. Terms of the series can be used as approximations of periodic piecewise continuous functions. Here we provide the Euler formulas which enable us to compute these approximations.
A trigonometric series is a series of functions #s_n# #(n = 1,2,\ldots)# defined by
\[s_n(x) = \frac{a_0}{2} + \sum_{k=1}^{n} \left(a_k\cos(kx)+b_k\sin(kx)\right)\]
Here, #a_k# for integers #k\ge0# and #b_k# for integers #k \gt 0# are constants. These are called the coefficients of the trigonometric series.
We say that the series converges at #x# if #\lim_{n\to\infty} s_n(x) # exists.
Let #f# be a real periodic function with period #2\pi#. A Fourier series of #f# is a trigonometric series of functions #s_n# #(n = 1,2,\ldots)# such that, for all #x# at which #f# is continuous, we have
\[f(x) = \lim_{n\to\infty} s_n(x) \]
The coefficients of a Fourier series pertaining to #f# are also called Fourier coefficients.
Later, we will show that a periodic function has a Fourier series if it is piecewise smooth. Under the additional restriction of continuity, we will also prove a stronger form of convergence, known as uniform convergence.
Also, it will become clear that, under the given assumption regarding #f#, the Fourier series is uniquely determined by #f#, so the notion of Fourier coefficients does not depend on the choice of Fourier series for #f#.
If the limits exist, the trigonometric series as defined represent periodic functions of period #2\pi#. By scaling we can arrange for a trigonometric series to represent period functions of arbitrary period #p#. To this end, the argument #x# should be replaced by #\frac{2\pi x}{p}#. This amounts to scaling of the argument of the function by the factor #\frac{2\pi}{p}#. Later we will treat arbitrary periods in greater detail.
Often we write a trigonometric series without explicit use of the partial sums #s_n#:
\[ \frac{a_0}{2} + a_1\cos(x) + b_1\sin(x) +a_2\cos(2x) +b_2\sin(2x)+ \cdots \]
or, more compactly,
\[ \frac{a_0}{2} + \sum_{k=1}^{\infty}\left( a_k\cos(kx)+b_k\sin(kx)\right) \]
In these terms, a Fourier series for #f# satisfies
\[ f(x) = \frac{a_0}{2} + \sum_{k=1}^{\infty} \left(a_k\cos(kx)+b_k\sin(kx)\right) \]
for all #x# at which #f# is continuous. This will be shown to hold in later, in Dirichlet's theorem for Fourier series. We often write #s(x)# for the right-hand side, so #s(x) = \lim_{n\to\infty}s_n(x)#.
If #a# and #b# are constants and #f# and #g# are #2\pi#-periodic functions with Fourier series #s# and #t#, then the collection of terms from #a\cdot s+ b\cdot t# containing the same trigonometric function gives the Fourier series of #a\cdot f+b\cdot g#.
For example, using the facts that \[ \begin{array}{rcl} x&\text{has Fourier series}&\displaystyle {2}\sum_{k=1}^\infty\frac{(-1)^{k+1}}{n}\sin(k x)\\ &\text{ and }&\\ x^2&\text{has Fourier series}&\displaystyle \frac{\pi^2}{3}+{4}\sum_{k=1}^\infty\frac{(-1)^{k}}{n^2}\cos(k x)\end{array}\]
we conclude that\[\begin{array}{rcl} 2x^2+x&\text{has Fourier series}&\displaystyle \frac{2\pi^2}{3}+{4}\sum_{k=1}^\infty\left(\frac{(-1)^{k+1}}{n}\sin(k x)+\frac{(-1)^{k}}{n^2}\cos(k x)\right)\end{array} \]
Since #0# has a trivial Fourier series, these observations show that the set of #2\pi#-periodic functions having a Fourier series is a subspace of the vector space of #2\pi#-periodic functions.
The denominator #2# involved in the term containing #a_0# makes sense in the context of an inner product space. More precisely, the functions #\frac{1}{\sqrt2}#, #\cos(k x)#, #\sin(k x)# #(k=1,2,\ldots)# form an orthonormal system in the inner product space of all piecewise continuous #2\pi#-periodic functions with inner product \[\dotprod{f}{g} = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\cdot g(x)\,\dd x\]
The verification of this fact is a matter of calculation of some definite integrals.
First, we verify that #\sqrt12# has norm #1#.
\[\begin{array}{rcl}\displaystyle\dotprod{\sqrt12}{\sqrt12}&=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}\frac12\,\dd x \\ &=& \frac{1}{2\pi}\left[x\right]_{-\pi}^{\pi}\\ &=& 1\end{array}\]
Next, we verify that #\cos(k x)# has norm #1# for each positive integer #k#.
\[\begin{array}{rcl}\displaystyle\dotprod{\cos(k x)}{\cos(k x)}&=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}\cos(k x)^2\,\dd x \\ &=& \displaystyle\frac{1}{4\pi k}\left[\sin \left(2k x\right)+2kx\right]_{-\pi}^{\pi}\\&=&\displaystyle \frac{1}{4\pi k}\left(0+4\pi k\right)\\ &=& 1\end{array}\]
Similarly, we verify that #\sin(k x)# has norm #1# for each positive integer #k#.
\[\begin{array}{rcl}\displaystyle\dotprod{\sin(k x)}{\cos(k x)}&=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}\sin(k x)^2\,\dd x \\ &=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}\left(1-\cos(k x)^2\right)\,\dd x \\ &=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}1\,\dd x-\frac{1}{\pi}\int_{-\pi}^{\pi}\cos(k x)^2\,\dd x \\ &=&\displaystyle 2- 1\\ &&\phantom{xxx}\color{blue}{\text{ by the above computations}}\\ &=& 1\end{array}\]
The constant function #\frac{1}{\sqrt2}# is orthogonal to #\cos(k x)# for each positive integer #k#.
\[\begin{array}{rcl}\displaystyle\dotprod{\frac{1}{\sqrt2}}{\cos(k x)}&=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}\frac{1}{\sqrt2}\cos(k x)\,\dd x \\ &=&\displaystyle \frac{1}{\sqrt2 \pi k}\left[\sin(k x)\,\right]_{-\pi}^{\pi} \\&=& 0\end{array}\]
The constant function #\frac{1}{\sqrt2}# is also orthogonal to #\sin(k x)# for each positive integer #k#.
\[\begin{array}{rcl}\displaystyle\dotprod{\frac{1}{\sqrt2}}{\sin(k x)}&=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}\frac{1}{\sqrt2}\sin(k x)\,\dd x \\ &=&\displaystyle \frac{-1}{\sqrt2 \pi k}\left[\cos(k x)\,\right]_{-\pi}^{\pi} \\&=&\displaystyle \frac{-1}{\sqrt2 \pi k}\left((-1)^k-(-1)^k \right)\\&=& 0\end{array}\]
The function #\cos(kx)# is orthogonal to #\cos(\ell x)# for all positive integers #k# and #\ell# with #k\ne\ell#.
\[\begin{array}{rcl}\displaystyle\dotprod{\cos(kx)}{\cos(\ell x)}&=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}\cos(kx)\cos(\ell x)\,\dd x \\&=&\displaystyle \frac{-1}{2\pi (\ell^2-k^2)}\left[ {{\left(\ell-k\right)\,\sin \left(\left(\ell+k\right)\,x\right)+\left(-\ell-
k\right)\,\sin \left(\left(k-\ell\right)\,x\right)}}\right]_{-\pi}^{\pi} \\&=& 0\end{array}\]
The function #\sin(kx)# is orthogonal to #\sin(\ell x)# for all positive integers #k# and #\ell# with #k\ne\ell#.
\[\begin{array}{rcl}\displaystyle\dotprod{\sin(kx)}{\sin(\ell x)}&=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}\sin(kx)\sin(\ell x)\,\dd x \\&=&\displaystyle \frac{-1}{2\pi (\ell^2-k^2)}\left[ -{{\left(\ell-k\right)\,\sin \left(\left(\ell+k\right)\,x\right)+\left(\ell+
k\right)\,\sin \left(\left(k-\ell\right)\,x\right)}}\right]_{-\pi}^{\pi} \\&=& 0\end{array}\]
Finally, the function #\cos(kx)# is orthogonal to #\sin(\ell x)# for all positive integers #k# and #\ell# with #k\ne\ell#. This is immediate from the fact that the interval is symmetric about the origin and that the integrand is an odd function (this notion will be handled soon), but here is a proof by means of a calculation.
\[\begin{array}{rcl}\displaystyle\dotprod{\cos(kx)}{\sin(\ell x)}&=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}\cos(kx)\sin(\ell x)\,\dd x \\&=&\displaystyle \frac{-1}{2\pi (\ell^2-k^2)}\left[ -{{\left(\ell-k\right)\,\cos \left(\left(\ell+k\right)\,x\right)+\left(\ell+
k\right)\,\cos \left(\left(\ell-k\right)\,x\right)}} \right]_{-\pi}^{\pi} \\&=& 0\\&&\phantom{xxx}\color{blue}{\text{the value of the antiderivative at }\pi\text{ is equal to the value at }-\pi}\end{array}\]
The Fourier series given are for real functions and are expressed in terms of real functions.
The complex Fourier series is of the form \[\sum_{k=-\infty}^\infty c_k\cdot\ee^{kx\ii}\]
where #c_k# are complex numbers.
After all, \(\ee^{kx\ii} =\cos(kx)+\ii\sin(kx)\), so the real part of the above series is equal to
\[\frac{a_0}{2} + \sum_{k=1}^{\infty} \left(a_k\cos(kx)+b_k\sin(kx)\right)\] where
\[ a_0=2\Re(c_0),\qquad a_k = \Re(c_k) ,\qquad b_k = -\Im(c_k)\quad (k=1,2,\ldots)\]
at least, if the limit of the real parts of the finite sums #s_n# is equal to the real part of the limit #s# of the #s_n# and likewise for the imaginary parts. Often this is a consequence of convergence of the series.
Fourier series were introduced by the French mathematician Joseph Fourier as a tool in his work on differential equations.
For now, we shall not be concerned with convergence issues and simply assume that the Fourier series exist for the functions at hand. First, we will deal with the computation of the Fourier coefficients.
Suppose that #f# is a piecewise continuous #2\pi#-periodic function. The Euler formulas for #f# are the following equalities \[\begin{array}{rcl}a_0&=&\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi} f(x) \dd x\\ a_n&=&\displaystyle \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos(n x) \dd x\\ b_n&=&\displaystyle \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \sin(n x) \dd x \end{array}\] for #n\gt0#.
The constants #a_0#, #a_n#, #b_n# #(n=1,2,\ldots)# will be called the Euler coefficients of #f#.
If #f# is piecewise smooth, then the trigonometric series \[ s_n (x)=\frac{a_0}{2} + \sum_{k=1}^{\infty} \left(a_k\cos(kx)+b_k\sin(kx)\right)\]whose coefficients are the Euler coefficients, is a Fourier series of #f#.
Calculate the Euler coefficients of the function
\[f(x) = \begin{cases} -1 &\mbox{if } -\pi \leq x \lt 0 \\ 1 &\mbox{if } 0 \leq x \lt \pi \end{cases} \]
extended to a periodic function on the real numbers by #f(x+2\pi)=f(x)#.

We begin by calculating #a_0#. From the formula above, we obtain
\[a_0=\frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \dd x =0\]
This integral vanishes because #f# is an odd function on the open interval #\ivoo{-\pi}{\pi}#.
Similarly, since #f# is odd and #\cos# is even on #\ivoo{-\pi}{\pi}#, the product #f(x)\cos(nx)# is odd for each #n#, so we have
\[a_n=\displaystyle\frac{1}{\pi} \int_{-\pi}^{\pi} f(x)\cos(nx)\, \dd x =0\]
As for #b_n#, we calculate
\[\begin{array}{rcl} b_n&=&\displaystyle\frac{1}{\pi} \int_{-\pi}^{\pi} f(x)\sin(nx)\,\dd x \\&&\phantom{xxx}\blue{\text{Euler formula}} \\&=&\displaystyle \frac{1}{\pi} \left( \int_{-\pi}^{0} -\sin(nx)\, \dd x + \int_{0}^{\pi} \sin(nx) \dd x \right)\\&&\phantom{xxx}\blue{\text{function rule for }f} \\&=&\displaystyle \frac{1}{\pi} \left( \left. \frac{\cos(nx)}{n}\right|_{-\pi}^{0} + \left. - \frac{\cos(nx)}{n} \right|_{0}^{\pi} \right) \\&&\phantom{xxx}\blue{\text{antiderivative determined}} \\&=&\displaystyle\frac{1}{n\pi}(1-\cos(-n\pi) - \cos(n\pi) + 1) \\ &&\phantom{xxx}\blue{\text{boundary values filled in}} \\&=&\displaystyle \frac{2}{n\pi}(1-(-1)^n)\\ &&\phantom{xxx}\blue{\cos(n\pi)=-(1)^n} \\ \end{array}\]
Since #b_k=0# if #k# is odd, we replace summation over #k# by summation over #n# where #k=2n+1#, to get the following expression for the Fourier series of #f#.
\[\frac{2}{\pi}\sum_{k=1}^{\infty}\frac{(1-(-1)^k)}{k}\sin(kx) = \frac{4}{\pi}\sum_{n=0}^{\infty} \frac{\sin((2n+1)x)}{2n+1}\]
The value of the Fourier series at #0# is #0#, because #\sin(0) =0#. This is equal to half the sum of the left-hand limit #f_-(0) = \lim_{x\uparrow0}f(x)# and the right-hand limit #f_+(0)=\lim_{x\downarrow0}f(x)#. Later we will see that this is not a coincidence.
The formulas suggests that the Fourier series of #f# is uniquely determined by #f# under the conditions of the statement. Later, when dealing with the stronger form of convergence, we will show that this is indeed the case.
The converse, that is, the statement that #f# is uniquely determined by a Fourier series, is only true for continuous functions. Indeed,
- for continuous functions this follows directly from the statement that a Fourier series converges to #f# at all points where #f# is continuous;
- it need not be true for piecewise continuous functions, since, if we take #f# to be the constant function #0# except at a finite number of points in #\ivcc{-\pi}{\pi}#, then the Euler formulas lead to #a_k=b_k=0#. Thus all such functions will have the same Fourier series as the constant function #0#.
The proof of convergence will be given
later. In the parts subsequent to this one, the Euler formulas will be derived under the assumption that an infinite sum and an integral can be interchanged. This assumption is a consequence of
uniform convergence of the Fourier series of #f# which will be shown to hold
later if #f# is also continuous.
Assuming that term-by-term integration of the series is allowed (which we will show
later is the case if #f# is continuous), we determine the coefficient #a_0# by integrating the Fourier series expression for #f#. \[\begin{array}{rcl}\displaystyle \int_{-\pi}^{\pi} f(x)\dd x &=&\displaystyle \int_{-\pi}^{\pi} \left( \frac{a_0}{2} + \sum_{n=1}^{\infty} (a_n\cos(nx) + b_n \sin(nx)) \right)\dd x \\&&\phantom{xxx}\color{blue}{\text{Fourier series}}\\ &=&\displaystyle \frac{a_0}{2} \int_{-\pi}^{\pi} \dd x\\&& \displaystyle+\sum_{n=1}^{\infty}\left (a_n\int_{-\pi}^{\pi} \cos(nx) \dd x + b_n\int_{-\pi}^{\pi} \sin(nx) \dd x\right) \\&&\phantom{xxx}\color{blue}{\text{interchanging summation and integration}}\\ &=&\displaystyle\frac{a_0}{2}\int_{-\pi}^{\pi} \dd x \\&&\phantom{xxx}\color{blue}{\text{definite integrals involving cos and sin are zero}}\\ &=&\displaystyle a_0 \cdot \pi \\&&\phantom{xxx}\color{blue}{\text{simple definite integration}}\\ \end{array}\] We conclude that #a_0 = \frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\dd x#.
Fix a positive integer #n#. Assuming that term-by-term integration of the series is allowed (which we will show later is the case if #f# is continuous), we determine the coefficient #a_n# by integrating the Fourier series for #f#. We multiply the Fourier series identity by #\cos(nx)# and take the definite integral of the result from #-\pi# to #\pi#. We use the easily verified fact that the integrals #\int_{-\pi}^{\pi}\cos(\ell x)\dd x# and #\int_{-\pi}^{\pi}\sin(mx)\dd x# are zero whenever #\ell# is a nonzero integer and #m# is an integer. We also use the product-to-sum formulas for trigonometric functions.
In addition, we assume that the series #\sum_{k=1}^{\infty} a_k\cos(kx)# and #\sum_{k=1}^{\infty} b_k\sin(kx)# converge and that the definite integrals from #-\pi# to #\pi# of these series are equal to the infinite sums of the same definite integrals over the terms.
\[\begin{array}{rcl}\displaystyle \int_{-\pi}^{\pi} f(x)\cos(nx)\dd x &=&\displaystyle \int_{-\pi}^{\pi} \left( \frac{a_0}{2} + \sum_{k=1}^{\infty} (a_k\cos(kx) + k_n \sin(kx))\cdot{\cos(nx)} \right) \dd x \\&&\phantom{xxx}\color{blue}{\text{Fourier series}}\\ &=&\displaystyle\frac{a_0}{2}\int_{-\pi}^{\pi}{\cos(nx)} \dd x\\&&\displaystyle + \sum_{k=1}^{\infty} \left( a_k \int_{-\pi}^{\pi} \cos(kx){\cos(nx)} \dd x \right)\\&&\displaystyle + \sum_{k=1}^{\infty} \left( b_k\int_{-\pi}^{\pi} \sin(kx){\cos(nx)} \dd x \right) \\&&\phantom{xxx}\color{blue}{\text{interchanging summation and integration}}\\&=&\displaystyle \sum_{k=1}^{\infty} \left( \frac{a_k}{2} \int_{-\pi}^{\pi} \left(\cos((k-n)x)+\cos((k+n)x\right) \dd x \right)\\ &&\displaystyle + \sum_{k=1}^{\infty} \left( \frac{b_k}{2}\int_{-\pi}^{\pi} \left(\sin((n-k)x)+\sin((k+n)x)\right) \dd x \right) \\&&\phantom{xxx}\color{blue}{\text{first integral is zero; product-to-sum formulas applied}}\\&=&\displaystyle \sum_{k=1}^{\infty} \left( \frac{a_k}{2} \int_{-\pi}^{\pi} \cos((k-n)x)\dd x \right)+\sum_{k=1}^{\infty} \left( \frac{a_k}{2} \int_{-\pi}^{\pi}\cos((k+n)x) \dd x \right)\\ &&\displaystyle + \sum_{k=1}^{\infty} \left( \frac{b_k}{2}\int_{-\pi}^{\pi}\sin((n-k)x) \dd x \right)+ \sum_{k=1}^{\infty} \left( \frac{b_k}{2}\int_{-\pi}^{\pi}\sin((k+n)x) \dd x \right) \\&&\phantom{xxx}\color{blue}{\text{sum of limits is limit of sum}}\\&=&\displaystyle \frac{a_n}{2} \int_{-\pi}^{\pi}\cos(0) \dd x \\&&\phantom{xxx}\color{blue}{\text{only first integral with }k=n\text{ is nonzero}}\\&=&\displaystyle a_n \cdot \pi \\&&\phantom{xxx}\color{blue}{\text{simple definite integration}}\\ \end{array}\] We conclude that #a_n = \frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos(nx)\dd x#.
We proceed as for the cosine coefficients. Fix a positive integer #n#. We use that easily verified fact that the integrals #\int_{-\pi}^{\pi}\cos(\ell x)\dd x# and #\int_{-\pi}^{\pi}\sin(mx)\dd x# are zero whenever #\ell# is a nonzero integer and #m# is an integer. We also use the product-to-sum formulas for trigonometric functions.
In addition, we assume that the series #\sum_{k=1}^{\infty} a_k\cos(kx)# and #\sum_{k=1}^{\infty} b_k\sin(kx)# converge and that the definite integrals from #-\pi# to #\pi# of these series are equal to the infinite sums of the same definite integrals over the terms. We will show later is the case if #f# is continuous. We determine the coefficient #b_n# by integrating the Fourier series expression for #f#. We multiply the Fourier series identity by #\cos(nx)# and take the integral:
\[\begin{array}{rcl}\displaystyle \int_{-\pi}^{\pi} f(x)\sin(nx)\dd x &=&\displaystyle \int_{-\pi}^{\pi} \left( \frac{a_0}{2} + \sum_{k=1}^{\infty} (a_k\cos(kx) + k_n \sin(kx))\cdot{\sin(nx)} \right) \dd x \\&&\phantom{xxx}\color{blue}{\text{Fourier series}}\\ &=&\displaystyle\frac{a_0}{2}\int_{-\pi}^{\pi}{\sin(nx)} \dd x\\&&\displaystyle + \sum_{k=1}^{\infty} \left( a_k \int_{-\pi}^{\pi} \cos(kx){\sin(nx)} \dd x \right)\\&&\displaystyle + \sum_{k=1}^{\infty} \left( b_k\int_{-\pi}^{\pi} \sin(kx){\sin(nx)} \dd x \right) \\&&\phantom{xxx}\color{blue}{\text{interchanging summation and integration}}\\&=&\displaystyle \sum_{k=1}^{\infty} \left( \frac{a_k}{2} \int_{-\pi}^{\pi} \left(\sin((n-k)x)+\sin((n+k)x\right) \dd x \right)\\ &&\displaystyle + \sum_{k=1}^{\infty} \left( \frac{b_k}{2}\int_{-\pi}^{\pi} \left(\cos((k-n)x)-\cos((k+n)x)\right) \dd x \right) \\&&\phantom{xxx}\color{blue}{\text{first integral is zero; product-to-sum formulas applied}}\\&=&\displaystyle \sum_{k=1}^{\infty} \left(\frac{a_k}{2} \int_{-\pi}^{\pi} \sin((n-k)x)\dd x \right)+\sum_{k=1}^{\infty} \left( \frac{a_k}{2} \int_{-\pi}^{\pi}\sin((n+k)x) \dd x \right)\\ &&\displaystyle + \sum_{k=1}^{\infty} \left( \frac{b_k}{2}\int_{-\pi}^{\pi}\cos((k-n)x) \dd x \right)- \sum_{k=1}^{\infty} \left( \frac{b_k}{2}\int_{-\pi}^{\pi}\cos((k+n)x) \dd x \right)\\&&\phantom{xxx}\color{blue}{\text{sum of limits is limit of sum}}\\&=&\displaystyle \frac{b_n}{2} \int_{-\pi}^{\pi}\cos(0) \dd x \\&&\phantom{xxx}\color{blue}{\text{only third integral with }k=n\text{ is nonzero}}\\&=&\displaystyle b_n \cdot \pi \\&&\phantom{xxx}\color{blue}{\text{simple definite integration}}\\ \end{array}\] We conclude that #b_n = \frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\sin(nx)\dd x#.
In terms of the inner product space of all #2\pi#-periodic piecewise continuous functions with inner product \[\dotprod{f}{g} = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\cdot g(x)\,\dd x\]and orthonormal system #\frac{1}{\sqrt2},\cos(x),\sin(x),\cos(2x),\sin(2x),\ldots#, the Euler formulas can be rewritten as \[\begin{array}{rclcl} {a_0} &=& \displaystyle \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \dd x &=& \dotprod{f}{1}\\ a_k &=&\displaystyle \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos(k x) \dd x &=& \dotprod{f}{\cos(kx)}\\ b_k &=&\displaystyle \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \sin(k x) \dd x &=& \dotprod{f}{\sin(kx)}\end{array}\]
Calculate the Fourier series of the real periodic function #f# defined by
\[f(x) = \euler^{x} \qquad \text{for}\qquad -\pi \leq x \lt \pi\] and extended to #\mathbb{R}# by periodicity with period #2\pi#.
The Fourier series of #f# is \({{\euler^{\pi}-\euler^ {- \pi }}\over{\pi}} \cdot\left({{1}\over{2}} + \sum_{n=1}^{\infty} {{{\left(-1\right)^{n}\cdot \left(\cos \left(n x \right)-n\cdot \sin \left(n x \right)\right)}\over{n^2+1}}}\right) \)
By the
Euler formula for #a_n#, we have, for #n\ge0#,
\[\begin{array}{rcl}a_n &=& \displaystyle \frac{1}{\pi} \int_{-\pi}^{\pi} \euler^{x}\,\cos(n x) \dd x\\ &=&
\displaystyle\frac{1}{\pi} \left[{{\euler^{x}\cdot \left(n\cdot \sin \left(n\cdot x\right)+\cos \left(n\cdot x\right)\right)}\over{n^2+1}} \right]_{-\pi}^{\pi} \\
&&\phantom{xxx}\color{blue}{\text{the Fundamental theorem of Analysis}}\\ &=&\displaystyle\frac{1}{\pi} \left({{\euler^{\pi}\cdot \left(n\cdot \sin \left(\pi\cdot n\right)+\cos \left(\pi\cdot n\right)\right)}\over{n^2+1}}-{{\euler^ {- \pi }\cdot \left(\cos \left(\pi\cdot n\right)-n\cdot \sin \left(\pi\cdot n\right)\right)}\over{n^2+1}} \right) \\
&&\phantom{xxx}\color{blue}{\text{boundary values substituted}}\\
\displaystyle&=&\displaystyle {{\left(\euler^{\pi}-\euler^ {- \pi }\right)\cdot \left(-1\right)^{n}}\over{\pi\cdot \left(n^2+1\right)}} \\
&&\phantom{xxx}\color{blue}{\text{simplified}}\\ \end{array}
\]
Similarly, for #n\ge1#,
\[\begin{array}{rcl}b_n &=& \displaystyle \frac{1}{\pi} \int_{-\pi}^{\pi} \euler^{x}\,\sin(n x) \dd x\\ &=&
\displaystyle\frac{1}{\pi} \left[{{\euler^{x}\cdot \left(\sin \left(n\cdot x\right)-n\cdot \cos \left(n\cdot x\right)\right)}\over{n^2+1}} \right]_{-\pi}^{\pi} \\
&&\phantom{xxx}\color{blue}{\text{the Fundamental theorem of Analysis}}\\ &=&\displaystyle\frac{1}{\pi} \left({{\euler^{\pi}\cdot \left(\sin \left(\pi\cdot n\right)-n\cdot \cos \left(\pi\cdot n\right)\right)}\over{n^2+1}}-{{\euler^ {- \pi }\cdot \left(-\sin \left(\pi\cdot n\right)-n\cdot \cos \left(\pi\cdot n\right)\right)}\over{n^2+1}} \right) \\
&&\phantom{xxx}\color{blue}{\text{boundary values substituted}}\\
\displaystyle&=&\displaystyle {{\left(\euler^ {- \pi }-\euler^{\pi}\right)\cdot n\cdot \left(-1\right)^{n}}\over{\pi\cdot \left(n^2+1\right)}} \\
&&\phantom{xxx}\color{blue}{\text{simplified}}\\ \end{array}
\]
As a consequence, the Fourier series of #f# is
\[ \begin{array}{cl}&\displaystyle\frac{a_0}{2} + \sum_{n=1}^{\infty}\left( a_n\cos(nx)+b_n\sin(nx)\right) \\ &\displaystyle = {{\euler^{\pi}-\euler^ {- \pi }}\over{2\cdot \pi}}+ \sum_{n=1}^{\infty}\left( {{\left(\euler^{\pi}-\euler^ {- \pi }\right)\cdot \left(-1\right)^{n}}\over{\pi\cdot \left(n^2+1\right)}} \cdot\cos(nx)+{{\left(\euler^ {- \pi }-\euler^{\pi}\right)\cdot n\cdot \left(-1\right)^{n}}\over{\pi\cdot \left(n^2+1\right)}}\cdot \sin(nx)\right)\\ &= \displaystyle {{\euler^{\pi}-\euler^ {- \pi }}\over{\pi}} \cdot\left({{1}\over{2}} + \sum_{n=1}^{\infty} {{{\left(-1\right)^{n}\cdot \left(\cos \left(n x \right)-n\cdot \sin \left(n x \right)\right)}\over{n^2+1}}}\right) \end{array}\]
As a consequence of pointwise convergence of the series evaluated at #0#, we find
\[\sum_{n=2}^\infty \frac{(-1)^n}{n^2+1} = \frac{\pi}{\ee^{\pi}-\ee^{-\pi}}\]