# Preface

Thia section is aout Fourier series exoansions of square like functions.

Introduction to Linear Algebra with Mathematica

# Fourier series for square wave functions

This section is a collection of Fourier series expansions for different step functions. Square wave function constitute a very important class of functions used in electrical engineering and computer science; in particular, in music synthesizors. A square wave function, also called a pulse wave, is a periodic waveform consisting of instantaneous transitions between two levels. We consider two cases of square waves that include the digital signal (0,1) and oscillation between (-1,1). Other common levels for the square wave includes -½ and ½.

We start with the Heaviside function on finite interval [-2,2], which we extend in periodic manner with period 4:

Integrate[Cos[n*Pi*x/a], {x,0,a}]/a
There is no need to show Mathematica commands for Fourier coefficient evaluations---it was done in the previous sections. However, for completeness, we evaluate Fourier coefficients.
\begin{eqnarray*} H(t) = \begin{cases} 1 , & \ \mbox{ if } 0 < t < \ell , \\ 1/2 , & \ \mbox{ if } t=0 , \\ 0 , & \ \mbox{ if } -\ell < t < 0 ; \end{cases} &=& \frac{1}{2} + \frac{2}{\pi} \,\sum_{k\ge 0} \frac{1}{2k+1} \,\sin \frac{(2k+1)\pi t}{\ell} . \end{eqnarray*}
Then we plot 25-term Fourier approximation; observe overshoot and undershoot indicated explicitly on the graph.
H[t_] = 1/2 + 2/Pi*Sum[1/(2*k+1)*Sin[(2*k+1)*Pi*t/2], {k,0,25}];
Plot[H[t], {t,-7,7}, PlotStyle -> {Thick, Green}, Ticks->{{-6,-4,-2,0,2,4,6},{1.089,-0.09}}, TicksStyle ->{Thick,Black}]
tickSpecification = Table[{i, Rotate[i, Pi/2]}, {i, {1.179}}]

We can also expand the Heaviside function into Fourier sine and Fourier cosine series on the interval [0,2ℓ]. To achieve this, we expand the Heaviside function evenly and oddly from the given interval:

Integrate[Sin[n*Pi*x/a/2], {x,0,a}]/a
(4 Sin[(n $Pi])/4]^2)/(n \[Pi]) Integrate[Cos[n*Pi*x/a/2], {x,0,a}]/a (2 Sin[(n \[Pi])/2])/(n \[Pi]) \begin{eqnarray*} Hs(t) = \begin{cases} 1 , & \ \mbox{ if } 0 < t < \ell , \\ 0 , & \ \mbox{ if } \ell < t < 2\ell , \\ -1 , & \ \mbox{ if } -\ell < t < 0 ; \end{cases} &=& \frac{4}{\pi}\, \sum_{n\ge 1} \frac{1}{n}\,\sin^2 \left( \frac{n\pi}{4} \right) \sin \frac{n\pi x}{2\ell} , \\ Hc(t) = \begin{cases} 1 , & \ \mbox{ if } -\ell < t < \ell , \\ 1/2 , & \ \mbox{ if } t=\ell , \\ 0 , & \ \mbox{ if } \ell < t < 2\ell ; \end{cases} &=& \frac{1}{2} + \frac{2}{\pi} \,\sum_{n\ge 1} \frac{1}{n}\,\sin \left( \frac{n\pi}{2} \right) \cos \frac{n\pi x}{2\ell} . \end{eqnarray*} We plot Fourier sine series in blue and Fourier cosine series in red. The Gibbs overshoots and undershoots are shown explicitly in the graphs. Hs[t_] = 4/Pi*Sum[1/n*(Sin[n*Pi/4])^2*Sin[n*Pi*t/4], {n,1,50}]; Plot[Hs[t], {t,-7,7}, PlotStyle -> {Thick, Blue}, Ticks->{{-6,-4,-2,0,2,4,6},{1.179,-1.179, 0.09,-0.09}}, TicksStyle ->{Thick,Black}] Hc[t_] = 1/2 + 2/Pi*Sum[1/n*Sin[n*Pi/2]*Cos[n*Pi*t/4], {n,1,25}] Plot[Hc[t], {t,-7,7}, PlotStyle -> {Thick, Red}, Ticks->{{-6,-4,-2,0,2,4,6},{1.09,-0.09}}, TicksStyle ->{Thick,Black}] How we define the shifted 2ℓ periodic Heaviside function: Integrate[Sin[n*Pi*x/a], {x,a,2*a}]/a (Cos[n \[Pi]] - Cos[2 n \[Pi]])/(n \[Pi]) Integrate[1, {x,a,2*a}]/a 1 Integrate[Cos[n*Pi*x/a], {x,a,2*a}]/a (-Sin[n \[Pi]] + Sin[2 n \[Pi]])/(n \[Pi]) \begin{eqnarray*} H(t-\ell ) = \begin{cases} 0 , & \ \mbox{ if } 0 < t < \ell , \\ 1/2 , & \ \mbox{ if } t=\ell , \\ 1 , & \ \mbox{ if } \ell < t < 2\ell ; \end{cases} &=& \frac{1}{2} - \frac{2}{\pi} \,\sum_{k\ge 0} \frac{1}{2k+1} \,\sin \frac{(2k+1)\pi t}{\ell} . \end{eqnarray*} h[t_] = 1/2 - 2/Pi*Sum[1/(2*k+1)*Sin[(2*k+1)*Pi*t/2], {k,0,25}]; Plot[h[t], {t,-7,7}, PlotStyle -> {Thick, Green}, Ticks->{{-6,-4,-2,0,2,4,6},{1.09,-0.09}}, TicksStyle ->{Thick,Black}] Similarly, we define its Fourier sine and Fourier cosine series on the interval [-ℓ,ℓ], using appropriate extensions: Integrate[Sin[n*Pi*x/a/2], {x,a,2*a}]/a (2 (Cos[(n \[Pi])/2] - Cos[n \[Pi]]))/(n \[Pi]) Integrate[Cos[n*Pi*x/a/2], {x,a,2*a}]/a (2 (-Sin[(n \[Pi])/2] + Sin[n \[Pi]]))/(n \[Pi]) \begin{eqnarray*} hs(t) = \begin{cases} 0 , & \ \mbox{ if } 0 < t < \ell , \\ 1/2 , & \ \mbox{ if } t=\ell , \\ 1 , & \ \mbox{ if } \ell < t < 2\ell ; \end{cases} &=& \frac{2}{\pi}\, \sum_{n\ge 1} \frac{1}{n}\left[ \cos \frac{n\pi}{2} - (-1)^n \right] \sin \frac{n\pi x}{2\ell} , \\ hc(t) = \begin{cases} 0 , & \ \mbox{ if } 0 < t < \ell , \\ 1/2 , & \ \mbox{ if } t=\ell , \\ 1 , & \ \mbox{ if } \ell < t < 2\ell ; \end{cases} &=& \frac{1}{2} - \frac{2}{\pi} \,\sum_{n\ge 1} \frac{1}{n}\,\sin \left( \frac{n\pi}{2} \right) \cos \frac{n\pi x}{2\ell} . \end{eqnarray*} hs[t_] = 2/Pi*Sum[1/n*(Cos[n*Pi/2] -(-1)^n)*Sin[n*Pi*t/4], {n,1,50}]; Plot[hs[t], {t,-7,7}, PlotStyle -> {Thick, Blue}, Ticks->{{-6,-4,-2,0,2,4,6},{1.179,-1.179}}, TicksStyle ->{Thick,Black}] hc[t_] = 1/2 - 2/Pi*Sum[1/n*Sin[n*Pi/2]*Cos[n*Pi*t/4], {n,1,25}] Plot[hc[t], {t,-7,7}, PlotStyle -> {Thick, Red}, Ticks->{{-6,-4,-2,0,2,4,6},{1.09,-0.09}}, TicksStyle ->{Thick,Black}] Example 1: We consider another related to the Heaviside function that is known as the signum function \[ \mbox{sign}(x) = \begin{cases} \phantom{-}1 , & \ \mbox{ if } 0 < x < +\infty , \\ \phantom{-}0 , & \ \mbox{ when } x=0 , \\ -1 , & \ \mbox{ if } -\infty < x < 0 ; \end{cases}$
 Plot of the signum function on interval [-2, 2] using Mathematica standard Sign command. Plot[Sign[x], {x, -2.5, 2.5}, PlotStyle -> {Thickness[0.01], Purple}]

In order to expand the signum function into the Fourier series, we need to choose a value ℓ and expand this function in odd way periodically from the interval (−&wll;, ℓ).
 We expect that the Fourier series will give a periodic expansion shown in the figure. g[x_] = Piecewise[{{1, 0 < x < 1}, {-1, 1 < x < 2}, {-1, -1 < x < 0}, {1, -2 < x < -1}, {1, 2 < x < 3}, {-1, 3 < x < 4}, {1, 4 < x < 5}}]; sign = Plot[g[x], {x, -2, 5}, PlotStyle -> {Thickness[0.01], Red}, AspectRatio -> 1/3]; point = Graphics[{Red, {Disk[{-1, 0}, 0.05], Disk[{0, 0}, 0.05], Disk[{1, 0}, 0.05], Disk[{2, 0}, 0.05], Disk[{3, 0}, 0.05], Disk[{4, 0}, 0.05]}}]; Show[point, sign]

However, if you want remove the point valuse on the horizontal axis, you can include plot option Exclusions → None.

 We plot oddsign function without dots: g[x_] = Piecewise[{{1, 0 < x < 1}, {-1, 1 < x < 2}, {-1, -1 < x < 0}, {1, -2 < x < -1}, {1, 2 < x < 3}, {-1, 3 < x < 4}, {1, 4 < x < 5}}]; Plot[g[x], {x, -2, 5}, PlotStyle -> {Thickness[0.01],Purple}, AspectRatio -> 1/3, Exclusions -> None]

As a result, we obtain the periodic version of the signum function that we denote as oddsign; its sine Fourier series is

$\mbox{oddsign}(x) = \begin{cases} \phantom{-}1 , & \ \mbox{ if } 0 < x < \ell , \\ \phantom{-}0 , & \ \mbox{ if } x=0 , \\ -1 , & \ \mbox{ if } \ell < x < 2\ell ; \end{cases} \quad = \quad 2 \left[ H(x/\ell ) - H(x/\ell -1) \right] -1 = 2\,H(x) -1 = \frac{4}{\pi} \,\sum_{k\ge 0} \frac{1}{2k+1} \,\sin \frac{(2k+1)\pi x}{\ell} . \tag{1.1}$
Since this function is odd, there is no difference between its Fourier series and Fourier sine series; that is why we plot it in blue. Next, we calculate its Fourier coefficients:
sign[x_,L_]=HeavisideTheta[x/L] - HeavisideTheta[-1 + x/L];
ak = Assuming[L > 0, Integrate[sign[x, L]*Cos[k*Pi*x/L]/L, {x, 0, 2*L}]]
bk = Assuming[L > 0, Integrate[sign[x, L]*Sin[k*Pi*x/L]/L, {x, 0, 2*L}]]
Sin[k $Pi]]/(k \[Pi]) (1 - Cos[k \[Pi]])/(k \[Pi]) So all Fourier cosine coefficients are zeroes, and Fourier sine coefficients do not depend on ℓ, so we have \[ b_k = \frac{2}{\ell} \int_0^{\ell} \mbox{sign}(x) \,\sin \left( \frac{k\pi x}{\ell} \right) {\text d}x = - \frac{4}{k\pi} \,(-1)^k \sin^2 \frac{k\pi}{\ell} = \frac{4}{k\pi} \times \begin{cases} 1 , & \ \mbox{if k is odd}, \\ 0, & \ \mbox{if k is even}. \end{cases}. \tag{1.2}$
You can use instead the build-in Mathematica commands:
FourierSinCoefficient[Sign[x], x, n, FourierParameters -> {1,(π)/L}]
FourierCosCoefficient[Sign[x], x, n, FourierParameters -> {1,(π)/L}]

For ℓ = π, we get

FourierSinCoefficient[Sign[x], x, n, FourierParameters -> {1, 1}]
-((2 (-1 + (-1)^n))/(n $Pi])) We can also expand the signum function into complex Fourier series: \[ \mbox{oddsign}(x) = {\bf j}\sum_{n=-\infty}^{\infty} \frac{(-1)^n -1}{n\pi}\, e^{n{\bf j}\pi x/\ell} \tag{1.3}$
because
Simplify[1/2/L *Integrate[Sign[x]*Exp[-n*I*Pi*x/L], {x, -L, L}]]
(I (-1 + Cos[n $Pi]]) Sign[L])/(n \[Pi]) \[ \alpha_n = \frac{1}{2\ell} \int_{-\ell}^{\ell} \mbox{sign}(x)\,e^{-n{\bf j} \pi x/\ell} {\text d}x = {\bf j}\,\frac{\cos n\pi -1}{n\pi} , \qquad n=1,2,\ldots .$
Therefore, the corresponding sine Fourier sine becomess
$\mbox{sign}(x) = \sum_{n\ge 1} \frac{2}{n\pi} \left[ (-1)^{n+1} + 1 \right] \sin (n\pi x) = \frac{4}{\pi} \sum_{k\ge 0} \frac{1}{2k+1} \,\sin \left( \frac{(2k+1) \pi x}{\ell} \right) . \tag{1.4}$
Of course, this series is exactly the same as (1.3). Our next step is to truncate the series (1.3) or (1.4) and show how the finite Fourier series converges to the signum function. First, we use animation:

We plot partial sums with n = 10, 100, and 1000 terms.

S10[x_] = (4/Pi)*Sum[Sin[(2*k - 1)*x]/(2*k - 1), {k, 1, 10}];
S100[x_] = (4/Pi)*Sum[Sin[(2*k - 1)*x]/(2*k - 1), {k, 1, 100}];
S1000[x_] = (4/Pi)*Sum[Sin[(2*k - 1)*x]/(2*k - 1), {k, 1, 1000}];
Plot[S10[x], {x, -4, 5}, PlotStyle -> Thickness[0.007], Ticks -> {{-4, -2, 0, 2, 4}, {1.179, -1.179}}, TicksStyle -> {Thick, Black}];
Plot[S100[x], {x, -4, 5}, PlotStyle -> Thickness[0.007], TicksStyle -> {Thick, Black}, Ticks -> {{-4, -2, 0, 2, 4}, {1.179, -1.179}}, TicksStyle -> {Thick, Black}];
Plot[S1000[x], {x, -4, 5}, PlotStyle -> Thickness[0.007], TicksStyle -> {Thick, Black}, Ticks -> {{-4, -2, 0, 2, 4}, {1.179, -1.179}}, TicksStyle -> {Thick, Black}]
 Partial Fourier sum with 10 tems. Partial Fourier sum with 100 tems. Partial Fourier sum with 1000 tems.

Its Fourier series exhibits the Gibbs phenomenon at points of discontinuity x = (2n+1)ℓ, n∈ℤ, in amount of 2w ≈ 0.1789797, where w = 0.5707963267948966 is the Wilbraham number (see section). Recall that the value of the overshoot or undershoot of the partial Fourier sum is equal to h w, where h is the jump of discontinuoity (which 2 in our case).

It is known that restoring a function from its Fourier coefficients is an ill-posed problem. The Gibbs phenomenon clearly indicates that it is impossible to recover the function in a neighbohood of the point of discontinuity. A wealth of information hidden in the Fourier series can be recovered upon utilization of a summability method. For practical applications, its regularization, can be obtained with Cesàro's summation:

$f_m (x) = \frac{4}{\pi} \sum_{n= 0}^m \left( 1 - \frac{n}{m+1} \right) \frac{1}{2n+1} \,\sin \left( \frac{(2n+1) \pi x}{\ell} \right) = \frac{4}{\pi} \sum_{k= 1}^m \left( 1 - \frac{k}{m} \right) \frac{1}{2k-1} \,\sin \left( \frac{(2k-1) \pi x}{\ell} \right) . \tag{1.5}$
Note that Cesàro's regularization requires only three additional arithmetic operations on each step compared with the standard summation: one multiplication by the difference (1−k/n), one division (k/n), and one subtraction. This usually does not increase the time of computation.

Finally, we demonstrate animation for Cesàro's approximation

s[x_, m_] = 4*Sum[(1 - k/(m + 1))*Sin[(2*k + 1)*Pi*x]/(2*k + 1), {k, 0, m}]/Pi;
animation = Table[Plot[s[x, m], {x, -0.1, 1.1}, PlotRange -> {-0.2, 1.2}, PlotStyle -> Thickness[0.008], PlotLabel -> "Sine Fourier approximation"], {m, 0, 100, 2}];
Export["sine.gif", animation, "AnimationRepetitions" -> 200]
To observe convergence of Cesàro's sums, we plot three of them with m = 10, 100, and 1000 terms.
C10[x_] = (4/Pi)* Sum[(1 - k/10)*Sin[(2*k - 1)*x]/(2*k - 1), {k, 1, 10}];
C100[x_] = (4/Pi)* Sum[(1 - k/100)*Sin[(2*k - 1)*x]/(2*k - 1), {k, 1, 100}];
C1000[x_] = (4/Pi)* Sum[(1 - k/1000)*Sin[(2*k - 1)*x]/(2*k - 1), {k, 1, 1000}];
Plot[C10[x], {x, -4, 5}, PlotStyle -> Thickness[0.007], Ticks -> {{-4, -2, 0, 2, 4}, {1.0, -1.0}}, TicksStyle -> {Thick, Black}]
Plot[C100[x], {x, -4, 5}, PlotStyle -> {Purple, Thickness[0.007]}, TicksStyle -> {Thick, Purple}, Ticks -> {{-4, -2, 0, 2, 4}, {1.0, -1.0}}, TicksStyle -> {Thick, Black}]
Plot[C1000[x], {x, -4, 5}, PlotStyle -> {Purple, Thickness[0.007]}, TicksStyle -> {Thick, Purple}, Ticks -> {{-4, -2, 0, 2, 4}, {1.0, -1.0}}, TicksStyle -> {Thick, Black}]
 Partial Cesàro's sum with 10 tems. Partial Cesàro's sum with 100 tems. Partial Cesàro's sum with 1000 tems.

⁎ ✱ ✲ ✳ ✺ ✻ ✼ ✽ ❋ ========================================

Now we demonstrate how Fourier approximation depends on the number of terms (graphs present 3 terms, 7 terms, 10 terms, and 20 terms, but you can choose any numbers instead).
sign[t_] = (4/Pi) Sum[(1/n) Sin[2 Pi n t], {n, 1, Infinity], 2}]; fserf[t_,nmax_] := (4/Pi) Sum[(1/n) Sin[2 Pi n t], {n, 1, 2*nmax-1, 2}]; GraphicsGrid[ Partition[ Plot[{sign[t], fserf[t, #]}, {t, 0, 3}, PlotStyle -> {Thick , Blue}, PlotLabel -> ToString[#] <> " Terms"] &/@ {3, 7, 10, 20}, 2], ImageSize -> Large] Even use Manipulate to interactively see how the series works: f[t_] = (4/Pi) Sum[(1/n) Sin[2 Pi n t], {n, 1, \[Infinity], 2}]; fserf[t_, nmax_] := (4/Pi) Sum[(1/n) Sin[2 Pi n t], {n, 1, 2*nmax-1, 2}]; Manipulate[ Plot[{f[t], fserf[t, nmax]}, {t, 0, scale},PlotLabel-> ToString[nmax] <> " Terms", PlotRange -> {-1.5, 1.5}], {{nmax, 1, "Nº of Terms"}, 1, 50, 1, Appearance -> "Labeled"}, {{scale, 1, "x-axis length"}, 1, 5, 1, Appearance -> "Labeled"} ] Mathematica even knows how to find the infinite sum: f[t_] = (4/Pi) Sum[(1/n) Sin[2 Pi n t], {n, 1, ∞, 2}] (2 I (ArcTanh[E^(-2 I π t)] - ArcTanh[E^(2 I π t)]))/π then the plot is simple: Plot[f[t], {t, -1, 3}, PlotStyle -> Thick] You can write this partial sum as a Mathematica function of two variables: f[M_, x_] := 4/Pi *Sum[Sin[(2*k+1)*x]/(2*k+1) , {k,0,M}] Plot a few partial sums Plot[Table[f[M, x] ,{M, 1,4}], {x, -5,5}] ■ Example 2: Let us find Fourier coefficients for the delta-function of Dirac on an interval of length 2ℓ containing the origin: \begin{align*} a_0 &= \frac{1}{\ell} \,\int \delta (x)\,{\text d}x = \frac{1}{\ell} , \\ a_n &= \frac{1}{\ell} \int \delta (x)\,\cos \frac{n\pi x}{\ell} \,{\text d}x = \frac{1}{\ell} \,\cos 0 = \frac{1}{\ell} , \\ b_n &= \frac{1}{\ell} \int \delta (x)\,\sin \frac{n\pi x}{\ell} \,{\text d}x = \frac{1}{\ell} \,\sin 0 =0 . \end{align*} Therefore, we get a formal Fourier series for the delta-function \[ \delta (x) = \frac{1}{2\ell} + \frac{1}{\ell} \,\sum_{n\ge 1} \cos \frac{n\pi x}{\ell} .
Since the delta-function is a distribution but not a regular function, the series above cannot truly converge (its terms don’t approach zero). But we can determine its partial sums and graph the latter. We naturally denote such partial sums by
$\delta_N (x) = \frac{1}{2\ell} + \frac{1}{\ell}\,\sum_{n= 1}^N \cos \frac{n\pi x}{\ell} = \frac{1}{2\ell} \left[ 1 + 2\,\cos \frac{\pi x}{\ell} + 2 \,\cos \frac{2\pi x}{\ell} + \cdots + 2\,\cos \frac{N\pi x}{\ell} \right] .$
Using Euler's formula
$2\,\cos \theta = e^{{\bf j}\theta} + e^{-{\bf j}\theta} ,$
we can rewrite the finite sum as
$\delta_N (x) = \frac{1}{2\ell} \left[ 1 + e^{{\bf j}\theta} + e^{-{\bf j}\theta} + e^{2{\bf j}\theta} + e^{-2{\bf j}\theta} + \cdots + e^{N{\bf j}\theta} + e^{-N{\bf j}\theta} \right] , \qquad \theta = \pi x/\ell .$
This is a geometric progression that starts from $$e^{-N{\bf j}\theta}$$ and ends at $$e^{N{\bf j}\theta} .$$ We have powers of the same exponential factor $$e^{{\bf j}\theta} .$$ The sum of a geometric series is known:
$\delta_N (x) = \frac{1}{2\ell} \, \frac{e^{{\bf j} (N+ 1/2) \pi x /\ell} - e^{-{\bf j} (N+ 1/2) \pi x /\ell}}{e^{{\bf j}\pi x /\ell} - e^{-{\bf j}\pi x /\ell}} = \frac{1}{2\ell} \, \frac{\sin (N+1/2) x/\ell}{\sin (x/2/\ell)}$
This partial sum approaches the Dirac delta-function in weak sense, so for any smooth probe function f, we expect
$\int \delta_N (x)\,f(x)\,{\text d} x = \frac{a_0}{2} + a_1 + \cdots + a_N \,\to\, f(0), \qquad\mbox{as } N\to\infty .$
So we obtain a remarkable result that for any smooth function, when we expand it into Fourier series
$f(x) \sim \frac{a_0}{2} + \sum_{n\ge 1} \left[ a_n \cos \frac{n\pi x}{\ell} + b_n \sin \frac{n\pi x}{\ell} \right] ,$
the sum of its cosine coefficients approaches $$f(0) = \frac{a_0}{2} + a_1 + a_2 + \cdots .$$

Using Mathematica, we plot some partial sums
deltan[x_,M_] = (1/4)*Sin[(M+1/2)*x/2] /Sin[x/4];
Plot[{deltan[x,5], deltan[x,10]} , {x,-3,3}, PlotStyle->Thick, PlotLabels -> {"with n=5 terms", "with n=10 terms"}]

Now we introduce a sequence of square pulses that approaches the Dirac delta-function:
$\delta_h (x) = \frac{1}{h} \times \begin{cases} 1, & \ \mbox{ when } -\frac{h}{2} < x < \frac{h}{2} , \\ 0, & \ \mbox{otherwise} . \end{cases}$
The graph of each δh(x) is a tall thin rectangle: height 1/h, base h, and area=1. When h approaches zero, δh(x) is squeezed into a very thin interval. The tall rectangle approaches (weakly) the delta function δ(x). The Fourier coefficients of δh(x) are
Integrate[Cos[n*Pi*x/a], {x,-h/2,h/2}]/a
Integrate[Sin[n*Pi*x/a], {x,-h/2,h/2}]/a
(2 Sin[(h n Pi])/(2 a)])/(n \[Pi]) 0 \begin{align*} a_0 &= \frac{1}{\ell} \int \delta_h (x)\,{\text d}x = \frac{1}{\ell} \,\frac{1}{h} \times h = \frac{1}{\ell} , \\ a_n &= \frac{1}{\ell} \,\int \delta_h (x)\,\cos \frac{n\pi x}{\ell} \,{\text d}x = \frac{1}{h\ell} \,\int_{-h/2}^{h/2} \,\cos \frac{n\pi x}{\ell} \,{\text d}x = \frac{2}{n\pi h} \,\sin \frac{nh\pi}{2\ell} , \\ b_n &= \frac{1}{\ell} \,\int \delta (x)\,\sin \frac{n\pi x}{\ell} \,{\text d}x = \frac{1}{h\ell} \,\int_{-h/2}^{h/2} \,\sin \frac{n\pi x}{\ell} \,{\text d}x = 0 . \end{align*} Hence, the Fourier cosine coefficient is expressed through the normalized sinc function: \[ a_n = \frac{2}{n\pi h} \,\sin \frac{nh\pi}{2\ell} = \frac{h}{\ell} \,\frac{\frac{\pi nh}{2\ell}}{\pi nh/(2\ell )} = \frac{h}{\ell} \, \mbox{sinc} \frac{n\pi h}{2\ell} ,
where
$\mbox{sinc} (x) = \frac{\sin \pi x}{\pi x} = \frac{1}{\Gamma (1+x)\,\Gamma (1-x)} = \prod_{n\ge 1} \left( 1 - \frac{x^2}{n^2} \right) .$