NotebookDirectory[]

The output in this notebook is deleted. To get all the output back, evaluate the entire notebook: Alt+v o (or the menu item Evaluation, then Evaluate Notebook

A collection of Fourier series

Preliminaries

Below is the definition of a periodic extension of a function defined on (-L,L]. This definition takes a function as a variable. The function has to be inputted as a so called pure function (that is instead of the variable we put # and the formula ends with &).

Example 1:  Sign[x]  on  -π < x ≤π

Clear[f1,x];f1[x_]:=Sign[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f1[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f1[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f1[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

This formula simplifies; for even n to 0 and for odd n to  (4/(π n)). Thus the Fourier series of the given function is

(4/π)(∑_(k=1)^∞)(1/(2k-1))Sin[(2k-1)x]

This series converges pointwise to the Fourier 2π-periodic extension of Sign[x], as illustrated in the following graph and manipulation

Plot[{fft[f1[#]&,x,Pi]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]]

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f1[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];pic2=Plot[{fft[f1[#]&,x,Pi]},{x,-10,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-1}],Point[{#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{# Pi,-1}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];

pic3=Plot[Evaluate[{(4/π)(∑_(k=1)^nn)(1/(2k-1))Sin[(2k-1)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-1.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]]

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f1[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];pic2=Plot[{fft[f1[#]&,x,Pi]},{x,-10,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-1}],Point[{#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{# Pi,-1}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];

pic3=Plot[Evaluate[{(4/π)(∑_(k=1)^nn)(1/(2k-1))Sin[(2k-1)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-1.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f1[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];pic2=Plot[{fft[f1[#]&,x,Pi]},{x,-10,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-1}],Point[{#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{# Pi,-1}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];

pic3=Plot[Evaluate[{(4/π)(∑_(k=1)^nn)(1/(2k-1))Sin[(2k-1)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-1.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

x = π/2

Notice that the convergence theorem implies that for a specific x = (π/2) the following numerical series

(4/π)(∑_(k=1)^∞)(1/(2k-1))Sin[(2k-1)(π/2)]

which equals

(4/π)(∑_(k=1)^∞)((((-1))^(k-1))/(2k-1))

converges to 1.

Mathematica knows this

(4/π)(∑_(k=1)^∞)((((-1))^(k-1))/(2k-1))

In other words, from the convergence theorem for Fourier series we deduce that

(∑_(k=1)^∞)((((-1))^(k-1))/(2k-1))=(π/4)

which is the famous Leibniz formula for π.

x = π/4

Table[{k,Sin[(2k-1)*(Pi/4)]},{k,1,20}]

Table[{k,(((-1))^(Ceiling[k/2]-1))},{k,1,20}]

FindSequenceFunction[{{1,1},{2,1},{3,-1},{4,-1},{5,1},{6,1},{7,-1},{8,-1},{9,1},{10,1},{11,-1},{12,-1},{13,1},{14,1},{15,-1},{16,-1},{17,1},{18,1},{19,-1},{20,-1}}]

The convergence theorem implies that for a specific x = (π/4) the following numerical series

(4/π)(∑_(k=1)^∞)(1/(2k-1))Sin[(2k-1)(π/4)]

which equals

((2(Sqrt[2]))/π)(∑_(k=1)^∞)((((-1))^(Ceiling[k/2]-1))/(2k-1))

converges to 1.

Does Mathematica knows this

((2(Sqrt[2]))/π)(∑_(k=1)^∞)((((-1))^(Ceiling[k/2]-1))/(2k-1))

Check numerically

N[((2(Sqrt[2]))/π)(∑_(k=1)^10000)((((-1))^(Ceiling[k/2]-1))/(2k-1))]

x = π/3

But we can get more numerical series sums from the above Fourier series. Take x = π/3.

(4/π)(∑_(k=1)^∞)(1/(2k-1))Sin[(2k-1)*(Pi/3)]

FullSimplify[(4/π)(∑_(k=1)^∞)(1/(2k-1))Sin[(2k-1)*(Pi/3)]]

Table[{k,Sin[(2k-1)*(Pi/3)]},{k,1,20}]

Table[3 Floor[j/2]+((1+(((-1))^(j-1)))/2),{j,1,10}]

Table[2(3 Floor[j/2]+((1+(((-1))^(j-1)))/2))-1,{j,1,10}]

Table[{j,3 Floor[j/2]+((1+(((-1))^(j-1)))/2),(((-1))^(j-1))},{j,1,10}]

Table[{j,2(3 Floor[j/2]+((1+(((-1))^(j-1)))/2))-1},{j,1,10}]

Table[{j,3 (j-((1+(((-1))^(j-1)))/2))+(((-1))^(j-1))},{j,1,10}]

Table[{j,((6 j-3-(((-1))^(j-1)))/2)},{j,1,10}]

((4(Sqrt[3]))/π)(∑_(j=1)^∞)((((-1))^(j-1))/( 6 j-3-(((-1))^(j-1))))

N[((4(Sqrt[3]))/π)(∑_(j=1)^1200)((((-1))^(j-1))/( 6 j-3-(((-1))^(j-1))))]

Important note: for every positive x<π we have convergence to 1.

Test the above claim for specific x:

N[(4/π)(∑_(k=1)^10000)(1/(2k-1))Sin[(2k-1)*(Pi/200)]]

Integrate this series

Differentiate this Fourier series term by term

(4/π)(∑_(k=1)^∞)(1/(2k-1))Sin[(2k-1)x]

The definite integral of is

Integrate[Sin[(2k-1)t],{t,0,x}]

(4/π)(∑_(k=1)^∞)(1/(((2k-1))^2))(1-Cos[x-2 k x])

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{(4/π)(∑_(k=1)^nn)(1/(((2k-1))^2))(1-Cos[x-2 k x])}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]]

This series is exactly the Fourier series that we will encounter in Example 4 below.

(4/π)(∑_(k=1)^∞)(1/(((2k-1))^2))(1-Cos[x-2 k x])

One only needs to observe that

(4/π)(∑_(k=1)^∞)(1/(((2k-1))^2))

So

(4/π)(∑_(k=1)^∞)(1/(((2k-1))^2))(1-Cos[x-2 k x]) = (π/2)-(4/π)(∑_(k=1)^∞)(1/(((2k-1))^2))Cos[(2 k-1) x]

Example 2:  UnitStep[x]  on  -π < x ≤π

Clear[f2,x];f2[x_]:=UnitStep[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f2[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f2[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f2[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

This formula simplifies; for even n to 0 and for odd n to  (2/(π n)). Thus the Fourier series of the given function is

(1/2)+(2/π)(∑_(k=1)^∞)(1/(2k-1))Sin[(2k-1)x]

This series converges pointwise to the Fourier 2π-periodic extension of UnitStep[x], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f2[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];pic2=Plot[{fft[f2[#]&,x,Pi]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#Pi,1}],Point[{# Pi,1/2}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{#Pi,0}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];

pic3=Plot[Evaluate[{(1/2)+(2/π)(∑_(k=1)^nn)(1/(2k-1))Sin[(2k-1)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f2[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];pic2=Plot[{fft[f2[#]&,x,Pi]},{x,-10,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{#Pi,1}],Point[{# Pi,1/2}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{#Pi,0}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];

pic3=Plot[Evaluate[{(1/2)+(2/π)(∑_(k=1)^nn)(1/(2k-1))Sin[(2k-1)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1/2]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

With the exception of the points of discontinuity, there is a simple connection between the functions f1 and f2:  f2[x]=(1/2)(1+f1[x]). Therefore the Fourier series studied in this section does not yield any new information in pointwise convergence.

Example 3a:   x  on  -1 < x ≤1

Odd

Clear[f3,x];f3a[x_]:=x;

on the interval  (-1,1]

Integrate[x Cos[n Pi x],x]

Integrate[x Sin[n Pi x],x]

The coefficient (Subscript[a, 0])

FullSimplify[(1/2)Integrate[f3a[x],{x,-1,1}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/1)Integrate[f3a[x] Cos[n Pi x],{x,-1,1}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/1)Integrate[f3a[x] Sin[n Pi x],{x,-1,1}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

2(∑_(n=1)^∞)((((-1))^(n+1))/(n Pi))Sin[n Pi x]

This series converges pointwise to the Fourier periodic extension of the function x, restricted to [-1,1), as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic2b,pic3,nn},nn=10;pic1=Plot[{f3a[x]},{x,-1,1},PlotStyle->{{Thickness[0.012],RGBColor[0,0,0.5]}}];

pic2=Plot[{fft[f3a[#]&,x,1]},{x,-15,10},PlotStyle->{{Thickness[0.008],RGBColor[0,0,0.5]}},Exclusions->Range[-10 ,14 ,1]];

pic2a=Graphics[{
{PointSize[0.015],RGBColor[0,0,0.5],{Point[{# ,-1}],Point[{# ,0}],Point[{#,1}]}&/@Range[-11,13,2]},{PointSize[0.01],White,{Point[{# ,-1}],Point[{#,1}]}&/@Range[-11,13,2]},{RGBColor[0.8{1,1,1}],Opacity[0.3],Polygon[{{-1,-2},{1,-2},{1,2},{-1,2},{-1,-2}}]}
}];
pic2b=Graphics[{
{RGBColor[0.8{1,1,1}],Opacity[0.01],Polygon[{{-1,-2},{1,-2},{1,2},{-1,2},{-1,-2}}]}
}];

pic3=Plot[Evaluate[{(2/Pi)(∑_(n=1)^nn)((((-1))^(n+1))/n)Sin[(n Pi)x]}],{x,-12,14},PlotStyle->{{Thickness[0.004],RGBColor[0.75,0,0]}},PlotPoints->200];Show[pic2,pic2a,pic3,PlotRange->{{-3.76,3.76},{-1 -.26,1+.26}},PlotRangePadding->None,AspectRatio->Automatic,Ticks->{Range[-10 ,10,(1/1)],Range[-3,3,(1/2)]},GridLines->{Range[-10 ,10,(1/4)],Range[-3,3,(1/4)]},ImageSize->600,PlotLabel->TableForm[{nn,"nonzero terms"},TableDirections->Row,TableSpacing->0.25]]]

Module[{pic1,pic2,pic2a,pic2b,pic3,nn},nn=10;pic1=Plot[{f3a[x]},{x,-1,1},PlotStyle->{{Thickness[0.01],RGBColor[0,0,0.5]}}];

pic2=Plot[{fft[(Sign[#]-#)&,x,1]},{x,-15,10},PlotStyle->{{Thickness[0.008],RGBColor[0,0,0.5]}},Exclusions->Range[-10 ,14 ,1]];

pic2a=Graphics[{
{PointSize[0.016],RGBColor[0,0,0.5],{Point[{# ,-1}],Point[{# ,0}],Point[{#,1}]}&/@Range[-10,13,2]},{PointSize[0.01],White,{Point[{# ,-1}],Point[{#,1}]}&/@Range[-10,13,2]},{RGBColor[0.8{1,1,1}],Opacity[0.3],Polygon[{{-1,-2},{1,-2},{1,2},{-1,2},{-1,-2}}]}
}];
pic3=Plot[Evaluate[{(2/Pi)(∑_(n=1)^nn)(1/n)Sin[(n Pi)x]}],{x,-12,14},PlotStyle->{{Thickness[0.004],RGBColor[0.75,0,0]}},PlotPoints->200];Show[pic2,pic2a,pic3,PlotRange->{{-3.76,3.76},{-1 -.26,1+.26}},PlotRangePadding->None,AspectRatio->Automatic,Ticks->{Range[-10 ,10,(1/1)],Range[-3,3,(1/2)]},GridLines->{Range[-10 ,10,(1/4)],Range[-3,3,(1/4)]},ImageSize->600,PlotLabel->TableForm[{nn,"nonzero terms"},TableDirections->Row,TableSpacing->0.25]]]

Numerical series at special values of x

x = 1/2

Notice that the convergence theorem implies that for a specific x = (1/2) the following numerical series

(2/Pi)(∑_(n=1)^∞)((((-1))^(n+1))/(n ))Sin[n Pi (1/2)]

which equals

2(∑_(k=1)^∞)((((-1))^(k-1))/(2k-1))

converges to π/2.

The Leibniz series.

x = π/3

Table[{n,Sin[n*(Pi/3)]},{n,1,20}]

Figuring out the pattern here is more complicated

Table[(((-1))^(Floor[k/2]))Floor[(3/2)k+1],{k,0,20}]

Table[2 ((((-1))^(n+1))/n)Sin[n(π/3)],{n,1,23}]

Table[(Sqrt[3])((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1)),{k,0,15}]

The convergence theorem implies that for a specific x = (1/3) the following numerical series

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n(π/3)]

which equals

(Sqrt[3])(∑_(k=0)^∞)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))

converges to π/3.

Does Mathematica knows this

((3(Sqrt[3]))/π)(∑_(k=0)^∞)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))

Check numerically

N[((3(Sqrt[3]))/π)(∑_(k=0)^10000)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))]

So, we established that the series with terms

Table[((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1)),{k,0,30}]

and so on

converges to  (π/(3(Sqrt[3])))

Adding the consecutive terms of the above series we get the series, for which Mathematica knows the sum

(∑_(k=0)^∞)(1/((3 k+1)(3 k+2)))

Differentiate this series

Differentiate this Fourier series term by term

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

The derivative is

2(∑_(n=1)^∞)(((-1))^(n+1))Cos[n x]

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{2(∑_(n=1)^nn)(((-1))^(n+1))Cos[(n)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]]

This series does not converge. In particular it does not converge to the derivative of the Fourier periodic extension of the function x, which equals to 1 except at jumps.

Integrate this series

Differentiate this Fourier series term by term

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

The definite integral of is

Integrate[Sin[(n)t],{t,0,x}]

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x])

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{2(∑_(n=1)^nn)((((-1))^(n+1))/(n^2))(1-Cos[n x])}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-.5,2Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-3Pi,3Pi,(Pi/2)]},ImageSize->is]]

This series similar to the Fourier series that we will encounter in Example ?? below.

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x])

One only needs to observe that

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))

So

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x]) =((π^2)/6)-2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))Cos[n x]

Even

Clear[f3,x];f3ae[x_]:=Abs[x];

on the interval  [-1,1]

Integrate[x Cos[n Pi x],x]

Integrate[x Sin[n Pi x],x]

The coefficient (Subscript[a, 0])

FullSimplify[(1/2)Integrate[Abs[x],{x,-1,1}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/1)Integrate[Abs[x] Cos[n Pi x],{x,-1,1}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/1)Integrate[Abs[x] Sin[n Pi x],{x,-1,1}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

(1/2)-(4/(π^2))(∑_(n=1)^∞)(1/((((2n-1))^2) ))Cos[(2n-1) Pi x]

This series converges pointwise to the Fourier periodic extension of the function x, restricted to [-1,1), as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic2b,pic3,nn},nn=2;
pic2=Plot[{fft[Abs[#]&,x,1]},{x,-15,10},PlotStyle->{{Thickness[0.01],RGBColor[0,0,0.5]}},Exclusions->Range[-10 ,14 ,1]];

pic2a=Graphics[{
{PointSize[0.017],RGBColor[0,0,0.5],{Point[{# ,1}]}&/@Range[-11,13,2]},{RGBColor[0.8{1,1,1}],Opacity[0.3],Polygon[{{-1,-2},{1,-2},{1,2},{-1,2},{-1,-2}}]}
}];

pic3=Plot[Evaluate[{(1/2)-(4/(Pi^2))(∑_(n=1)^nn)(1/((((2n-1))^2) ))Cos[(2n-1) Pi x]}],{x,-12,14},PlotStyle->{{Thickness[0.004],RGBColor[0.75,0,0]}},PlotPoints->200];Show[pic2,pic2a,pic3,PlotRange->{{-3.76,3.76},{-0 -.56,1+.26}},PlotRangePadding->None,AspectRatio->Automatic,Ticks->{Range[-10 ,10,(1/2)],Range[-3,3,(1/2)]},GridLines->{Range[-10 ,10,(1/4)],Range[-3,3,(1/4)]},ImageSize->600,PlotLabel->TableForm[{nn,"nonzero terms"},TableDirections->Row,TableSpacing->0.25]]]

Manipulate[Module[{pic1,pic2,pic2a,pic2b,pic3}, 
pic2=Plot[{fft[Abs[#]&,x,1]},{x,-15,10},PlotStyle->{{Thickness[0.01],RGBColor[0,0,0.5]}},Exclusions->Range[-10 ,14 ,1]];

pic2a=Graphics[{
{PointSize[0.017],RGBColor[0,0,0.5],{Point[{# ,1}]}&/@Range[-11,13,2]},{RGBColor[0.8{1,1,1}],Opacity[0.3],Polygon[{{-1,-2},{1,-2},{1,2},{-1,2},{-1,-2}}]}
}];

pic3=Plot[Evaluate[{(1/2)-(4/(Pi^2))(∑_(n=1)^nn)(1/((((2n-1))^2) ))Cos[(2n-1) Pi x]}],{x,-12,14},PlotStyle->{{Thickness[0.004],RGBColor[0.75,0,0]}},PlotPoints->200];Show[pic2,pic2a,pic3,PlotRange->{{-3.76,3.76},{-0 -.56,1+.26}},PlotRangePadding->None,AspectRatio->Automatic,Ticks->{Range[-10 ,10,(1/2)],Range[-3,3,(1/2)]},GridLines->{Range[-10 ,10,(1/4)],Range[-3,3,(1/4)]},ImageSize->800,PlotLabel->TableForm[{nn+1,"nonzero terms"},TableDirections->Row,TableSpacing->0.25]]],{{nn,10,"n"},{1,2,3,4,5,10,20,30,100}},ControlType->Setter]

Module[{pic1,pic2,pic2a,pic2b,pic3,nn},nn=10;
pic2=Plot[{fft[(1-Abs[#])&,x,1]},{x,-15,10},PlotStyle->{{Thickness[0.01],RGBColor[0,0,0.5]}},Exclusions->Range[-10 ,14 ,1]];

pic2a=Graphics[{
{PointSize[0.017],RGBColor[0,0,0.5],{Point[{# ,0}]}&/@Range[-11,13,2]},{RGBColor[0.8{1,1,1}],Opacity[0.3],Polygon[{{-1,-2},{1,-2},{1,2},{-1,2},{-1,-2}}]}
}];

pic3=Plot[Evaluate[{(1/2)+(4/(Pi^2))(∑_(n=1)^nn)(1/((((2n-1))^2) ))Cos[(2n-1) Pi x]}],{x,-12,14},PlotStyle->{{Thickness[0.004],RGBColor[0.75,0,0]}},PlotPoints->200];Show[pic2,pic2a,pic3,PlotRange->{{-3.76,3.76},{-0 -.56,1+.26}},PlotRangePadding->None,AspectRatio->Automatic,Ticks->{Range[-10 ,10,(1/2)],Range[-3,3,(1/2)]},GridLines->{Range[-10 ,10,(1/4)],Range[-3,3,(1/4)]},ImageSize->600]]

x = 1/2

Notice that the convergence theorem implies that for a specific x = (1/2) the following numerical series

(2/Pi)(∑_(n=1)^∞)((((-1))^(n+1))/(n ))Sin[n Pi (1/2)]

which equals

2(∑_(k=1)^∞)((((-1))^(k-1))/(2k-1))

converges to π/2.

The Leibniz series.

x = 1/3

Table[{n,Sin[n*(Pi/3)]},{n,1,20}]

Figuring out the pattern here is more complicated

Table[(((-1))^(Floor[k/2]))Floor[(3/2)k+1],{k,0,20}]

Table[2 ((((-1))^(n+1))/n)Sin[n(π/3)],{n,1,23}]

Table[(Sqrt[3])((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1)),{k,0,15}]

The convergence theorem implies that for a specific x = (1/3) the following numerical series

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n(π/3)]

which equals

(Sqrt[3])(∑_(k=0)^∞)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))

converges to π/3.

Does Mathematica knows this

((3(Sqrt[3]))/π)(∑_(k=0)^∞)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))

Check numerically

N[((3(Sqrt[3]))/π)(∑_(k=0)^10000)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))]

So, we established that the series with terms

Table[((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1)),{k,0,30}]

and so on

converges to  (π/(3(Sqrt[3])))

Adding the consecutive terms of the above series we get the series, for which Mathematica knows the sum

(∑_(k=0)^∞)(1/((3 k+1)(3 k+2)))

Differentiate this series

Differentiate this Fourier series term by term

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

The derivative is

2(∑_(n=1)^∞)(((-1))^(n+1))Cos[n x]

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{2(∑_(n=1)^nn)(((-1))^(n+1))Cos[(n)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]]

This series does not converge. In particular it does not converge to the derivative of the Fourier periodic extension of the function x, which equals to 1 except at jumps.

Integrate this series

Differentiate this Fourier series term by term

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

The definite integral of is

Integrate[Sin[(n)t],{t,0,x}]

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x])

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{2(∑_(n=1)^nn)((((-1))^(n+1))/(n^2))(1-Cos[n x])}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-.5,2Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-3Pi,3Pi,(Pi/2)]},ImageSize->is]]

This series similar to the Fourier series that we will encounter in Example ?? below.

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x])

One only needs to observe that

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))

So

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x]) =((π^2)/6)-2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))Cos[n x]

Neither

Clear[f3,x];f3an[x_]:=x UnitStep[x];

on the interval  [-1,1)

The coefficient (Subscript[a, 0])

FullSimplify[(1/2)Integrate[x,{x,0,1}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/1)Integrate[x Cos[n Pi x],{x,0,1}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/1)Integrate[x Sin[n Pi x],{x,0,1}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

(1/4)-(2/(π^2))(∑_(n=1)^∞)(1/((((2n-1))^2) ))Cos[(2n-1) Pi x]+(1/π)(∑_(n=1)^∞)((((-1))^(n+1))/(n ))Sin[n Pi x]

This series converges pointwise to the Fourier periodic extension of the function x, restricted to [-1,1), as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic2b,pic3,nn},nn=10;
pic2=Plot[{fft[# UnitStep[#]&,x,1]},{x,-15,10},PlotStyle->{{Thickness[0.008],RGBColor[0,0,0.5]}},Exclusions->Range[-10 ,14 ,1]];

pic2a=Graphics[{
{PointSize[0.017],RGBColor[0,0,0.5],{Point[{# ,1}],Point[{# ,1/2}],Point[{# ,0}]}&/@Range[-11,13,2]},
{PointSize[0.01],White,{Point[{# ,0}],Point[{#,1}]}&/@Range[-11,13,2]},{RGBColor[0.8{1,1,1}],Opacity[0.3],Polygon[{{-1,-2},{1,-2},{1,2},{-1,2},{-1,-2}}]}
}];

pic3=Plot[Evaluate[{(1/4)-(2/(Pi^2))(∑_(n=1)^(Ceiling[nn/2]))(1/((((2n-1))^2) ))Cos[(2n-1) Pi x]+(1/π)(∑_(n=1)^nn)((((-1))^(n+1))/(n ))Sin[n Pi x]}],{x,-12,14},PlotStyle->{{Thickness[0.004],RGBColor[0.75,0,0]}},PlotPoints->200];Show[pic2,pic2a,pic3,PlotRange->{{-3.76,3.76},{-0 -.56,1+.26}},PlotRangePadding->None,AspectRatio->Automatic,Ticks->{Range[-10 ,10,(1/2)],Range[-3,3,(1/2)]},GridLines->{Range[-10 ,10,(1/4)],Range[-3,3,(1/4)]},ImageSize->800,PlotLabel->TableForm[{nn+1+Ceiling[nn/2],"nonzero terms"},TableDirections->Row,TableSpacing->0.25]]]

Manipulate[Module[{pic1,pic2,pic2a,pic2b,pic3},
pic2=Plot[{fft[# UnitStep[#]&,x,1]},{x,-15,10},PlotStyle->{{Thickness[0.008],RGBColor[0,0,0.5]}},Exclusions->Range[-10 ,14 ,1]];

pic2a=Graphics[{
{PointSize[0.017],RGBColor[0,0,0.5],{Point[{# ,1}],Point[{# ,1/2}],Point[{# ,0}]}&/@Range[-11,13,2]},
{PointSize[0.01],White,{Point[{# ,0}],Point[{#,1}]}&/@Range[-11,13,2]},{RGBColor[0.8{1,1,1}],Opacity[0.3],Polygon[{{-1,-2},{1,-2},{1,2},{-1,2},{-1,-2}}]}
}];

pic3=Plot[Evaluate[{(1/4)-(2/(Pi^2))(∑_(n=1)^(Ceiling[nn/2]))(1/((((2n-1))^2) ))Cos[(2n-1) Pi x]+(1/π)(∑_(n=1)^nn)((((-1))^(n+1))/(n ))Sin[n Pi x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],RGBColor[0.75,0,0]}},PlotPoints->300];Show[pic2,pic2a,pic3,PlotRange->{{-3.76,3.76},{-0 -.56,1+.26}},PlotRangePadding->None,AspectRatio->Automatic,Ticks->{Range[-10 ,10,(1/2)],Range[-3,3,(1/2)]},GridLines->{Range[-10 ,10,(1/4)],Range[-3,3,(1/4)]},ImageSize->800,PlotLabel->TableForm[{nn+1+Ceiling[nn/2],"nonzero terms"},TableDirections->Row,TableSpacing->0.25]]],{{nn,10,"n"},{1,2,3,4,5,10,20,30,100}},ControlType->Setter]

x = 1/2

Notice that the convergence theorem implies that for a specific x = (1/2) the following numerical series

(2/Pi)(∑_(n=1)^∞)((((-1))^(n+1))/(n ))Sin[n Pi (1/2)]

which equals

2(∑_(k=1)^∞)((((-1))^(k-1))/(2k-1))

converges to π/2.

The Leibniz series.

x = π/3

Table[{n,Sin[n*(Pi/3)]},{n,1,20}]

Figuring out the pattern here is more complicated

Table[(((-1))^(Floor[k/2]))Floor[(3/2)k+1],{k,0,20}]

Table[2 ((((-1))^(n+1))/n)Sin[n(π/3)],{n,1,23}]

Table[(Sqrt[3])((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1)),{k,0,15}]

The convergence theorem implies that for a specific x = (1/3) the following numerical series

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n(π/3)]

which equals

(Sqrt[3])(∑_(k=0)^∞)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))

converges to π/3.

Does Mathematica knows this

((3(Sqrt[3]))/π)(∑_(k=0)^∞)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))

Check numerically

N[((3(Sqrt[3]))/π)(∑_(k=0)^10000)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))]

So, we established that the series with terms

Table[((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1)),{k,0,30}]

and so on

converges to  (π/(3(Sqrt[3])))

Adding the consecutive terms of the above series we get the series, for which Mathematica knows the sum

(∑_(k=0)^∞)(1/((3 k+1)(3 k+2)))

Differentiate this series

Differentiate this Fourier series term by term

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

The derivative is

2(∑_(n=1)^∞)(((-1))^(n+1))Cos[n x]

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{2(∑_(n=1)^nn)(((-1))^(n+1))Cos[(n)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]]

This series does not converge. In particular it does not converge to the derivative of the Fourier periodic extension of the function x, which equals to 1 except at jumps.

Integrate this series

Differentiate this Fourier series term by term

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

The definite integral of is

Integrate[Sin[(n)t],{t,0,x}]

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x])

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{2(∑_(n=1)^nn)((((-1))^(n+1))/(n^2))(1-Cos[n x])}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-.5,2Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-3Pi,3Pi,(Pi/2)]},ImageSize->is]]

This series similar to the Fourier series that we will encounter in Example ?? below.

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x])

One only needs to observe that

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))

So

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x]) =((π^2)/6)-2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))Cos[n x]

Example 3:   x  on  -π < x ≤π

Clear[f3,x];f3[x_]:=x;

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f3[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f3[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f3[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

This series converges pointwise to the Fourier 2π-periodic extension of the function x, restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f3[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f3[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-Pi}],Point[{# Pi,0}],Point[{#Pi,Pi}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,-Pi}],Point[{#Pi,Pi}]}&/@Range[-11,13,2]}
}];

pic3=Plot[Evaluate[{2(∑_(n=1)^nn)((((-1))^(n+1))/n)Sin[(n)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f3[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f3[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-Pi}],Point[{# Pi,0}],Point[{#Pi,Pi}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,-Pi}],Point[{#Pi,Pi}]}&/@Range[-11,13,2]}
}];

pic3=Plot[Evaluate[{2(∑_(n=1)^nn)((((-1))^(n+1))/n)Sin[(n)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

x = π/2

Notice that the convergence theorem implies that for a specific x = (π/2) the following numerical series

2(∑_(n=1)^∞)(1/n)Sin[n(π/2)]

which equals

2(∑_(k=1)^∞)((((-1))^(k-1))/(2k-1))

converges to π/2.

This is again the Leibniz series.

x = π/3

Table[{n,Sin[n*(Pi/3)]},{n,1,20}]

Figuring out the pattern here is more complicated

Table[(((-1))^(Floor[k/2]))Floor[(3/2)k+1],{k,0,20}]

Table[2 ((((-1))^(n+1))/n)Sin[n(π/3)],{n,1,23}]

Table[(Sqrt[3])((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1)),{k,0,15}]

The convergence theorem implies that for a specific x = (π/3) the following numerical series

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n(π/3)]

which equals

(Sqrt[3])(∑_(k=0)^∞)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))

converges to π/3.

Does Mathematica knows this

((3(Sqrt[3]))/π)(∑_(k=0)^∞)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))

Check numerically

N[((3(Sqrt[3]))/π)(∑_(k=0)^10000)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))]

So, we established that the series with terms

Table[((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1)),{k,0,30}]

and so on

converges to  (π/(3(Sqrt[3])))

Adding the consecutive terms of the above series we get the series, for which Mathematica knows the sum

(∑_(k=0)^∞)(1/((3 k+1)(3 k+2)))

Differentiate this series

Differentiate this Fourier series term by term

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

The derivative is

2(∑_(n=1)^∞)(((-1))^(n+1))Cos[n x]

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{2(∑_(n=1)^nn)(((-1))^(n+1))Cos[(n)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]]

This series does not converge. In particular it does not converge to the derivative of the Fourier periodic extension of the function x, which equals to 1 except at jumps.

Integrate this series

Differentiate this Fourier series term by term

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

The definite integral of is

Integrate[Sin[(n)t],{t,0,x}]

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x])

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{2(∑_(n=1)^nn)((((-1))^(n+1))/(n^2))(1-Cos[n x])}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-.5,2Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-3Pi,3Pi,(Pi/2)]},ImageSize->is]]

This series similar to the Fourier series that we will encounter in Example ?? below.

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x])

One only needs to observe that

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))

So

2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))(1-Cos[n x]) =((π^2)/6)-2(∑_(n=1)^∞)((((-1))^(n+1))/(n^2))Cos[n x]

Example 3a:  π Sign[x] - x  on -π < x ≤ π

Clear[f3a,x]; f3a[x_]:=π Sign[x] -x;

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f3a[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f3a[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f3a[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

2(∑_(n=1)^∞)(1/n)Sin[n x]

This series converges pointwise to the Fourier 2π-periodic extension of the function x, restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f3a[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f3a[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-Pi}],Point[{# Pi,0}],Point[{#Pi,Pi}]}&/@Range[-10,13,2]},{PointSize[0.014],White,{Point[{# Pi,-Pi}],Point[{#Pi,Pi}]}&/@Range[-10,13,2]}
}];

pic3=Plot[Evaluate[{2(∑_(n=1)^nn)(1/n)Sin[(n)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f3a[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f3a[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-Pi}],Point[{# Pi,0}],Point[{#Pi,Pi}]}&/@Range[-10,13,2]},{PointSize[0.014],White,{Point[{# Pi,-Pi}],Point[{#Pi,Pi}]}&/@Range[-10,13,2]}
}];

pic3=Plot[Evaluate[{2(∑_(n=1)^nn)(1/n)Sin[(n)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

x = π/2

Notice that the convergence theorem implies that for a specific x = (π/2) the following numerical series

2(∑_(n=1)^∞)(1/n)Sin[n(π/2)]

which equals

2(∑_(k=1)^∞)((((-1))^(k-1))/(2k-1))

converges to π/2.

This is again the Leibniz series.

x = π/3

Table[{n,Sin[n*(Pi/3)]},{n,1,20}]

Figuring out the pattern here is more complicated

Table[(((-1))^(Floor[k/2]))Floor[(3/2)k+1],{k,0,20}]

Table[2 ((((-1))^(n+1))/n)Sin[n(π/3)],{n,1,23}]

Table[(Sqrt[3])((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1)),{k,0,15}]

The convergence theorem implies that for a specific x = (π/3) the following numerical series

2(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n(π/3)]

which equals

(Sqrt[3])(∑_(k=0)^∞)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))

converges to π/3.

Does Mathematica knows this

((3(Sqrt[3]))/π)(∑_(k=0)^∞)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))

Check numerically

N[((3(Sqrt[3]))/π)(∑_(k=0)^10000)((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1))]

So, we established that the series with terms

Table[((((-1))^(Floor[k/2]+Floor[(3/2)k]))/(Floor[(3/2)k]+1)),{k,0,30}]

and so on

converges to  (π/(3(Sqrt[3])))

Adding the consecutive terms of the above series we get the series, for which Mathematica knows the sum

(∑_(k=0)^∞)(1/((3 k+1)(3 k+2)))

Example 4:  Abs[x] = x Sign[x]  on  -π < x ≤π

Clear[f4,x]; f4[x_]:=Abs[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f4[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f4[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

This formula simplifies; for even n to 0 and for odd n to  ((-4)/(π (n^2))).

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f4[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

(π/2)-(4/π)(∑_(k=1)^∞)(1/(((2 k-1))^2))Cos[(2k-1) x]

This series converges uniformly to the Fourier 2π-periodic extension of the function Abs[x], restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f4[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f4[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic3=Plot[Evaluate[{(π/2)-(4/Pi)(∑_(k=1)^nn)(1/(((2 k-1))^2))Cos[(2 k-1)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0 -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f4[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f4[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic3=Plot[Evaluate[{(π/2)-(4/Pi)(∑_(k=1)^nn)(1/(((2 k-1))^2))Cos[(2 k-1)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0 -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

x = 0

Notice that the convergence theorem implies that for a specific x = 0 the following numerical series

(π/2)-(4/π)(∑_(k=1)^∞)(1/(((2 k-1))^2))Cos[(2k-1) 0]

which equals

(π/2)-(4/π)(∑_(k=1)^∞)(1/(((2 k-1))^2))

converges to 0.

Thus

(∑_(k=1)^∞)(1/(((2 k-1))^2))=((π^2)/8)

x = π/4

Table[Cos[(2k-1)*(π/4)],{k,1,20}]

Table[(((-1))^(Floor[k/2])),{k,1,20}]

Notice that the convergence theorem implies that for a specific x = (π/4) the following numerical series

(π/2)-(4/π)(∑_(k=1)^∞)(1/(((2 k-1))^2))Cos[(2k-1)*(π/4)]

which equals

(π/2)-((2(Sqrt[2]))/π)(∑_(k=1)^∞)((((-1))^(Floor[k/2]))/(((2 k-1))^2))

converges to π/4.

Thus

(∑_(k=1)^∞)((((-1))^(Floor[k/2]))/(((2 k-1))^2))=((π^2)/(8(Sqrt[2])))

(∑_(k=1)^∞)((((-1))^(Floor[k/2]))/(((2 k-1))^2))

N[((π^2)/(8(Sqrt[2])))]

N[(∑_(k=1)^10000)((((-1))^(Floor[k/2]))/(((2 k-1))^2))]

Grouping four terms in the above series gives

Together[(1/(((2(4 k +1)-1))^2))-(1/(((2(4 k +2)-1))^2))-(1/(((2(4 k +3)-1))^2))+(1/(((2(4 k +4)-1))^2))]

FullSimplify[(∑_(k=0)^∞)(16 (599+5504 k+17792 (k^2)+24576 (k^3)+12288 (k^4)))/((((1+8 k))^2) (((3+8 k))^2) (((5+8 k))^2) (((7+8 k))^2))]

Mathematica knows these things.

Differentiate this series

Differentiate this Fourier series term by term

(π/2)-(4/π)(∑_(k=1)^∞)(1/(((2 k-1))^2))Cos[(2k-1) x]

The derivative is

(4/π)(∑_(k=1)^∞)(1/((2 k-1)))Sin[(2k-1) x]

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{(4/π)(∑_(k=1)^nn)(1/((2 k-1)))Sin[(2k-1) x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-1-.5,1+.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4,4,1]},ImageSize->is]]

This series we encountered in Example 1. It converges and it converges to the Fourier periodic extension of the derivative of the function Abs[x].

Example 5, ReLU function:   x UnitStep[x]  on  -π < x ≤π

Clear[f5,x]; f5[x_]:=x UnitStep[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f5[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f5[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

This formula simplifies; for even n to 0 and for odd n to  ((-2)/(π (n^2))).

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f5[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

(π/4)-(2/π)(∑_(k=1)^∞)(1/(((2 k-1))^2))Cos[(2k-1) x]+(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

This series converges pointwise to the Fourier 2π-periodic extension of the function x UnitStep[x], restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f5[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f5[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,0}],Point[{# Pi,Pi/2}],Point[{#Pi,Pi}]}&/@Range[-11,13,2]},
{PointSize[0.014],White,{Point[{# Pi,0}],Point[{#Pi,Pi}]}&/@Range[-11,13,2]}
}];

pic3=Plot[Evaluate[{(π/4)-(2/Pi)(∑_(k=1)^(Floor[nn/2]))(1/(((2 k-1))^2))Cos[(2 k-1)x]+(∑_(n=1)^nn)((((-1))^(n+1))/n)Sin[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0 -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f5[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f5[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,0}],Point[{# Pi,Pi/2}],Point[{#Pi,Pi}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,0}],Point[{#Pi,Pi}]}&/@Range[-11,13,2]}
}];

pic3=Plot[Evaluate[{(π/4)-(2/Pi)(∑_(k=1)^(Floor[nn/2]))(1/(((2 k-1))^2))Cos[(2 k-1)x]+(∑_(n=1)^nn)((((-1))^(n+1))/n)Sin[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0 -.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

Nothing new can be obtained here.

Differentiate this series

Differentiate this Fourier series term by term

(π/4)-(2/π)(∑_(k=1)^∞)(1/(((2 k-1))^2))Cos[(2k-1) x]+(∑_(n=1)^∞)((((-1))^(n+1))/n)Sin[n x]

The derivative is

(2/π)(∑_(k=1)^∞)(1/((2 k-1)))Sin[(2k-1) x]+(∑_(n=1)^∞)(((-1))^(n+1))Cos[n x]

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{(2/π)(∑_(k=1)^nn)(1/((2 k-1)))Sin[(2k-1) x]+(∑_(n=1)^nn)(((-1))^(n+1))Cos[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-3-.5,3+.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4,4,1]},ImageSize->is]]

This series does not converge.

Example 6:   (x^2)  on  -π < x ≤π

Clear[f6,x]; f6[x_]:=(x^2);

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f6[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f6[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f6[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

((π^2)/3)+4(∑_(n=1)^∞)((((-1))^n)/(n^2))Cos[n x]

This series converges uniformly to the Fourier 2π-periodic extension of the function (x^2), restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f6[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f6[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic3=Plot[Evaluate[{((π^2)/3)+4(∑_(n=1)^nn)((((-1))^n)/(n^2))Cos[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0 -.5,(Pi^2)+.5}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f6[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f6[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic3=Plot[Evaluate[{((π^2)/3)+4(∑_(n=1)^nn)((((-1))^n)/(n^2))Cos[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0 -.5,(Pi^2)+.5}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,(Pi/2)]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

x = π

Notice that the convergence theorem implies that for a specific x = π the following numerical series

((π^2)/3)+4(∑_(n=1)^∞)((((-1))^n)/(n^2))Cos[n π]

which equals

((π^2)/3)+4(∑_(n=1)^∞)(1/(n^2))

converges to (π^2).

Thus

(∑_(n=1)^∞)(1/(n^2))=((π^2)/6)

This is the famous formula for which direct proofs are not simple.

Differentiate this series

Differentiate this Fourier series term by term

((π^2)/3)+4(∑_(n=1)^∞)((((-1))^n)/(n^2))Cos[n x]

The derivative is

-4(∑_(n=1)^∞)((((-1))^n)/n)Sin[n x]

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{-4(∑_(n=1)^nn)((((-1))^n)/n)Sin[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-2 Pi-.5,2Pi+.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4,4,1]},ImageSize->is]]

This series we encountered in Example 3. It converges and it converges to the Fourier periodic extension of the derivative of the function (x^2).

Example 7:   x Abs[x] = (x^2)Sign[x]  on  -π < x ≤π

Clear[f7,x]; f7[x_]:=x Abs[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f7[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f7[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f7[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Expand[((-4-2 (((-1))^n) (-2+(n^2) (π^2)))/((n^3) π))]

Thus the Fourier series of the given function is

(∑_(n=1)^∞)(-(4/((n^3) π))+((4 (((-1))^n))/((n^3) π))-((2 (((-1))^n) π)/n))Sin[n x]

This series converges pointwise to the Fourier 2π-periodic extension of the function x Abs[x], restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic1=Plot[{f7[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f7[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];
pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,(Pi^2)}],Point[{# Pi,0}],Point[{#Pi,-(Pi^2)}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,(Pi^2)}],Point[{#Pi,-(Pi^2)}]}&/@Range[-11,13,2]}
}];
pic3=Plot[Evaluate[{(∑_(n=1)^nn)(-(4/((n^3) π))+((4 (((-1))^n))/((n^3) π))-((2 (((-1))^n) π)/n))Sin[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-(Pi^2) -.7,(Pi^2)+.7}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4Pi,4Pi,(Pi/2)]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f7[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f7[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];
pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,(Pi^2)}],Point[{# Pi,0}],Point[{#Pi,-(Pi^2)}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,(Pi^2)}],Point[{#Pi,-(Pi^2)}]}&/@Range[-11,13,2]}
}];
pic3=Plot[Evaluate[{(∑_(n=1)^nn)(-(4/((n^3) π))+((4 (((-1))^n))/((n^3) π))-((2 (((-1))^n) π)/n))Sin[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-(Pi^2) -.7,(Pi^2)+.7}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4Pi,4Pi,(Pi/2)]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

Example 8:   (x^2) UnitStep[x]  on  -π < x ≤π

Clear[f8,x]; f8[x_]:=(x^2) UnitStep[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[x^2,{x,0,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[x^2 Cos[n x],{x,0,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[x^2 Sin[n x],{x,0,Pi}],And[n∈Integers,n>0]]

Expand[((-2+(((-1))^n) (2-(n^2) (π^2)))/((n^3) π))]

Thus the Fourier series of the given function is

((π^2)/6)+(∑_(n=1)^∞)(((2 (((-1))^n))/(n^2))Cos[n x]+(-(2/((n^3) π))+((2 (((-1))^n))/((n^3) π))-(((((-1))^n) π)/n))Sin[n x])

This series converges pointwise to the Fourier 2π-periodic extension of the function (x^2) UnitStep[x], restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic1=Plot[{f8[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[Evaluate[{fft[f8[#]&,x,Pi]}],{x,-20,20},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11 Pi,14 Pi,2Pi],PlotRange->{{-2.5Pi,2.5Pi},{0-.7,(Pi^2)+.7}}];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,(Pi^2)}],Point[{# Pi,0}],Point[{#Pi,(Pi^2)/2}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,(Pi^2)}],Point[{#Pi,0}]}&/@Range[-11,13,2]}
}];
pic3=Plot[Evaluate[{((π^2)/6)+(∑_(n=1)^nn)(((2 (((-1))^n))/(n^2))Cos[n x]+(-(2/((n^3) π))+((2 (((-1))^n))/((n^3) π))-(((((-1))^n) π)/n))Sin[n x])}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0-.7,(Pi^2)+.7}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4Pi,4Pi,(Pi/2)]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f8[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[Evaluate[{fft[f8[#]&,x,Pi]}],{x,-20,20},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11 Pi,14 Pi,2Pi],PlotRange->{{-2.5Pi,2.5Pi},{0-.7,(Pi^2)+.7}}];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,(Pi^2)}],Point[{# Pi,0}],Point[{#Pi,(Pi^2)/2}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,(Pi^2)}],Point[{#Pi,0}]}&/@Range[-11,13,2]}
}];
pic3=Plot[Evaluate[{((π^2)/6)+(∑_(n=1)^nn)(((2 (((-1))^n))/(n^2))Cos[n x]+(-(2/((n^3) π))+((2 (((-1))^n))/((n^3) π))-(((((-1))^n) π)/n))Sin[n x])}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0-.7,(Pi^2)+.7}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4Pi,4Pi,(Pi/2)]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

Example 9:    x (π -Abs[x])  on  -π < x ≤π

Clear[f9,x]; f9[x_]:=x (Pi-Abs[x]);

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f9[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f9[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f9[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

This formula simplifies to  (8/((n^3)π)) for n odd and 0 for n even.

Thus the Fourier series of the given function is

(8/π)(∑_(k=1)^∞)(1/(((2 k -1))^3))Sin[(2k-1) x]

This series converges uniformly to the Fourier 2π-periodic extension of the function x (π-Abs[x]), restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f9[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f9[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

(* pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,(Pi^2)}],Point[{# Pi,0}],Point[{#Pi,-(Pi^2)}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,(Pi^2)}],Point[{#Pi,-(Pi^2)}]}&/@Range[-11,13,2]}
}]; *) 
pic3=Plot[Evaluate[{(8/π)(∑_(k=1)^(Floor[nn/2]))(1/(((2 k -1))^3))Sin[(2k-1) x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2, pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.3,Pi+.3}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4Pi,4Pi,(Pi/2)]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f9[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}}];

pic2=Plot[{fft[f9[#]&,x,Pi]},{x,-15,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

(* pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,(Pi^2)}],Point[{# Pi,0}],Point[{#Pi,-(Pi^2)}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,(Pi^2)}],Point[{#Pi,-(Pi^2)}]}&/@Range[-11,13,2]}
}]; *) 
pic3=Plot[Evaluate[{(8/π)(∑_(k=1)^(Ceiling[nn/2]))(1/(((2 k -1))^3))Sin[(2k-1) x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2, pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi -.3,Pi+.3}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4Pi,4Pi,(Pi/2)]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

x = π/2

Notice that the convergence theorem implies that for a specific x = π/2 the following numerical series

(8/π)(∑_(k=1)^∞)(1/(((2 k -1))^3))Sin[(2k-1) *(π/2)]

which equals

(8/π)(∑_(k=1)^∞)((((-1))^(k+1))/(((2 k -1))^3))

converges to ((π^2)/4).

Thus

(∑_(k=1)^∞)((((-1))^(k+1))/(((2 k -1))^3))=((π^3)/32)

Mathematica knows this formula

(∑_(k=1)^∞)((((-1))^(k+1))/(((2 k -1))^3))

Differentiate this series

Differentiate this Fourier series term by term

(8/π)(∑_(k=1)^∞)(1/(((2 k -1))^3))Sin[(2k-1) x]

The derivative is

(8/π)(∑_(k=1)^∞)(1/(((2 k -1))^2))Cos[(2k-1) x]

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{(8/π)(∑_(k=1)^nn)(1/(((2 k -1))^2))Cos[(2k-1) x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Pi-.5,Pi+.5}},AspectRatio->Automatic,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-Pi,Pi,Pi/2]},ImageSize->is]]

A similar series we encountered in Example 4. It converges and it converges to the Fourier periodic extension of the derivative of the function x (π -Abs[x]).

Example 10:   Cos[x]Sign[x]  on  -π < x ≤π

Clear[f10,x]; f10[x_]:=Cos[x] Sign[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0]) is 0

FullSimplify[(1/(2Pi))Integrate[f10[x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[a, n]) are 0

FullSimplify[(1/Pi)Integrate[f10[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f10[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

This formula simplifies; for even n to  ((4 n)/(π ((n^2)-1))) and for odd n to 0. Thus the Fourier series of the given function is

(4/π)(∑_(k=1)^∞)((2k)/(4(k^2)-1))Sin[(2k)x]

This series converges pointwise to the Fourier 2π-periodic extension of Cos[x], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f10[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];

pic2=Plot[{fft[f10[#]&,x,Pi]},{x,-20,20},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-1}],Point[{#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{# Pi,-1}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];

pic3=Plot[Evaluate[{(4/π)(∑_(k=1)^(Ceiling[nn/2]))((2k)/(4(k^2)-1))Sin[(2k)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-1.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f10[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];

pic2=Plot[{fft[f10[#]&,x,Pi]},{x,-20,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-1}],Point[{#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{# Pi,-1}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];

pic3=Plot[Evaluate[{(4/π)(∑_(k=1)^(Ceiling[nn/2]))((2k)/(4(k^2)-1))Sin[(2k)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-1.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Example 10a:   Cos[x]UnitStep[x]  on  -π < x ≤π

Clear[f10a,x]; f10a[x_]:=Cos[x] UnitStep[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0]) is 0

FullSimplify[(1/(2Pi))Integrate[f10a[x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[a, n]) are 0

FullSimplify[(1/Pi)Integrate[f10a[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

(1/Pi)Integrate[f10a[x] Cos[n x],{x,-Pi,Pi}]

Must be careful about (Subscript[a, 1])

FullSimplify[(1/Pi)Integrate[f10a[x] Cos[1 x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f10a[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

This formula simplifies; for even n to  ((2 n)/(π ((n^2)-1))) and for odd n to 0. Thus the Fourier series of the given function is

(1/2)Cos[x]+(2/π)(∑_(k=1)^∞)((2k)/(4(k^2)-1))Sin[(2k)x]

This series converges pointwise to the Fourier 2π-periodic extension of  Cos[x] UnitStep[x], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=10;pic1=Plot[{f10a[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];

pic2=Plot[{fft[f10a[#]&,x,Pi]},{x,-20,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{(2#-1) Pi,-1}],Point[{(2#-1)Pi,-1/2}],Point[{2#Pi,1}],Point[{2#Pi,1/2}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{(2#-1)Pi,-1}],Point[{2#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]}
}];

pic3=Plot[Evaluate[{(1/2)Cos[x]+(2/π)(∑_(k=1)^(Ceiling[nn/2]))((2k)/(4(k^2)-1))Sin[(2k)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-1.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f10a[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];

pic2=Plot[{fft[f10a[#]&,x,Pi]},{x,-20,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{(2#-1) Pi,-1}],Point[{(2#-1)Pi,-1/2}],Point[{2#Pi,1}],Point[{2#Pi,1/2}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{(2#-1)Pi,-1}],Point[{2#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]}
}];

pic3=Plot[Evaluate[{(1/2)Cos[x]+(2/π)(∑_(k=1)^(Ceiling[nn/2]))((2k)/(4(k^2)-1))Sin[(2k)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-1.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Example 11:  Sin[x]Sign[x]  on  -π < x ≤π

Clear[f11,x];  f11[x_]:=Sign[x]Sin[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f11[x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f11[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

This formula simplifies; for even n to  (4/(π ((n^2)-1))) and for odd n to 0.

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f11[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

(2/π)-(4/π)(∑_(k=1)^∞)(1/(4(k^2)-1))Cos[(2k)x]

This series converges uniformly to the Fourier 2π-periodic even extension of Sin[x], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=5;pic1=Plot[{f11[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];

pic2=Plot[{fft[f11[#]&,x,Pi]},{x,-20,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

(* pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-1}],Point[{#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{# Pi,-1}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];*)

pic3=Plot[Evaluate[{(2/π)-(4/π)(∑_(k=1)^(Ceiling[nn/2]))(1/(4(k^2)-1))Cos[(2k)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-0.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f11[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];

pic2=Plot[{fft[f11[#]&,x,Pi]},{x,-12,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

(* pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-1}],Point[{#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{# Pi,-1}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];*)

pic3=Plot[Evaluate[{(2/π)-(4/π)(∑_(k=1)^(Ceiling[nn/2]))(1/(4(k^2)-1))Cos[(2k)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-0.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Differentiate this series

Differentiate this Fourier series term by term

(2/π)-(4/π)(∑_(k=1)^∞)(1/(4(k^2)-1))Cos[(2k)x]

The derivative is

(4/π)(∑_(k=1)^∞)((2 k)/(4(k^2)-1))Sin[(2k)x]

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{(4/π)(∑_(k=1)^nn)((2 k)/(4(k^2)-1))Sin[(2k)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-1-.5,1+.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4,4,1]},ImageSize->is]]

A similar series we encountered in Example 10. It converges and it converges to the Fourier periodic extension of the derivative of the function f11[x].

Example 11a:  Sin[x]UnitStep[x]  on  -π < x ≤π

Clear[f11a,x];  f11a[x_]:=UnitStep[x]Sin[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[f11a[x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[f11a[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

One has to be careful with (Subscript[a, 1])

FullSimplify[(1/Pi)Integrate[f11a[x] Cos[1 x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The general formula simplifies: for even n to  (2/(π (1-(n^2)))) and for odd n to 0.

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[f11a[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

One has to be careful with (Subscript[b, 1])

FullSimplify[(1/Pi)Integrate[f11a[x] Sin[1 x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

(1/2)Sin[x]+(1/π)-(2/π)(∑_(k=1)^∞)(1/(4(k^2)-1))Cos[(2k)x]

This series converges uniformly to the Fourier 2π-periodic even extension of Sin[x] UnitStep[x], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=5;pic1=Plot[{f11a[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];

pic2=Plot[{fft[f11a[#]&,x,Pi]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

(* pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-1}],Point[{#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{# Pi,-1}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];*)

pic3=Plot[Evaluate[{(1/2)Sin[x]+(1/π)-(2/π)(∑_(k=1)^(Ceiling[nn/2]))(1/(4(k^2)-1))Cos[(2k)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-0.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f11a[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},Exclusions->{0}];

pic2=Plot[{fft[f11a[#]&,x,Pi]},{x,-5,10},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-10 Pi,14 Pi,Pi]];

(* pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,-1}],Point[{#Pi,1}],Point[{# Pi,0}]}&/@Range[-10,13,1]},{PointSize[0.014],White,{Point[{# Pi,-1}],Point[{#Pi,1}]}&/@Range[-10,13,1]}
}];*)

pic3=Plot[Evaluate[{(1/2)Sin[x]+(1/π)-(2/π)(∑_(k=1)^(Ceiling[nn/2]))(1/(4(k^2)-1))Cos[(2k)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-0.5,1.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-2,2,1]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

x = π/2

Notice that the convergence theorem implies that for a specific x = π/2 the following numerical series

which equals

(1/2)Sin[(π/2)]+(1/π)-(2/π)(∑_(k=1)^∞)(1/(4(k^2)-1))Cos[(2k)(π/2)]

converges to 1.

Thus

(1/2)+(1/π) - (2/π)(∑_(k=1)^∞)((((-1))^k)/(4(k^2)-1))=1

That is

(∑_(k=1)^∞)((((-1))^k)/(4(k^2)-1))=(π/4)((2/π)-1)=((2-π)/4)

Mathematica knows this formula

(∑_(k=1)^∞)((((-1))^k)/(4(k^2)-1))

Differentiate this series

Differentiate this Fourier series term by term

(1/2)Sin[x]+(1/π)-(2/π)(∑_(k=1)^∞)(1/(4(k^2)-1))Cos[(2k)x]

The derivative is

(1/2)Cos[x]+(2/π)(∑_(k=1)^∞)((2 k)/(4(k^2)-1))Sin[(2k)x]

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic3=Plot[Evaluate[{(1/2)Cos[x]+(2/π)(∑_(k=1)^nn)((2 k)/(4(k^2)-1))Sin[(2k)x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic3,PlotRange->{{-2.5Pi,2.5Pi},{-1-.5,1+.5}},Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-4,4,1]},ImageSize->is]]

This series we encountered in Example 10a.  It converges and it converges to the Fourier periodic extension of the derivative of the function f11a[x].

Example 12: Exp[x]  on  -π < x ≤π

Clear[f12,x];  f12[x_]:=Exp[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[Exp[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[Exp[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[Exp[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

((Sinh[π])/π)+((2 Sinh[π])/π)(∑_(n=1)^∞)((((-1))^n)/(1+(n^2)))(Cos[n x]- n Sin[n x])

This series converges pointwise to the Fourier 2π-periodic extension of the function Exp[x], restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic1=Plot[{f12[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->All];

pic2=Plot[Evaluate[{fft[f12[#]&,x,Pi]}],{x,-20,20},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11 Pi,14 Pi,2Pi],PlotRange->All];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,Cosh[Pi]}],Point[{# Pi,Exp[-Pi]}],Point[{#Pi,Exp[Pi]}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,Exp[-Pi]}],Point[{#Pi,Exp[Pi]}]}&/@Range[-11,13,2]}
}];
pic3=Plot[Evaluate[{((Sinh[π])/π)+((2 Sinh[π])/π)(∑_(n=1)^nn)((((-1))^n)/(1+(n^2)))(Cos[n x]- n Sin[n x])}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0-2,Exp[Pi]+2}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[0,40,5]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f12[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->All];

pic2=Plot[Evaluate[{fft[f12[#]&,x,Pi]}],{x,-20,20},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11 Pi,14 Pi,2Pi],PlotRange->All];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,Cosh[Pi]}],Point[{# Pi,Exp[-Pi]}],Point[{#Pi,Exp[Pi]}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,Exp[-Pi]}],Point[{#Pi,Exp[Pi]}]}&/@Range[-11,13,2]}
}];
pic3=Plot[Evaluate[{((Sinh[π])/π)+((2 Sinh[π])/π)(∑_(n=1)^nn)((((-1))^n)/(1+(n^2)))(Cos[n x]- n Sin[n x])}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0-2,Exp[Pi]+2}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[0,40,5]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

x = π

Notice that the convergence theorem implies that for a specific x = π the following numerical series

((Sinh[π])/π)+((2 Sinh[π])/π)(∑_(n=1)^∞)((((-1))^n)/(1+(n^2)))(Cos[n π]- n Sin[n π])

which equals

((Sinh[π])/π)+((2 Sinh[π])/π)(∑_(n=1)^∞)(1/(1+(n^2)))

converges to  Cosh[π].

Thus

(∑_(n=1)^∞)(1/(1+(n^2)))=(π/(2Sinh[π]))(Cosh[π]-((Sinh[π])/π))=(1/2)(π Coth[π] -1)

Mathematica knows this formula

(∑_(n=1)^∞)(1/(1+(n^2)))

x = 0

Notice that the convergence theorem implies that for the specific x = 0  the following numerical series

((Sinh[π])/π)+((2 Sinh[π])/π)(∑_(n=1)^∞)((((-1))^n)/(1+(n^2)))(Cos[n 0]- n Sin[n 0])

which equals

((Sinh[π])/π)+((2 Sinh[π])/π)(∑_(n=1)^∞)((((-1))^n)/(1+(n^2)))

converges to  1.

Thus

(∑_(n=1)^∞)((((-1))^n)/(1+(n^2)))=(π/(2Sinh[π]))(1-((Sinh[π])/π))=(1/2)((π/(Sinh[π])) -1)

Mathematica knows this formula

(∑_(n=1)^∞)((((-1))^n)/(1+(n^2)))

Example 13:  Cosh[x]  on  -π < x ≤π

Clear[f13,x]; f13[x_]:=Cosh[x];

on the interval  (-π,π]

Since Cosh[x]  is the even part of  Exp[x],  we know the constant coefficient and the coefficients with Cos functions will be identical to the corresponding coefficients calculated for Exp[x].

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[Cosh[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[Cosh[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])

FullSimplify[(1/Pi)Integrate[Cosh[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

((Sinh[π])/π)+((2 Sinh[π])/π)(∑_(n=1)^∞)((((-1))^n)/(1+(n^2)))Cos[n x]

This series converges uniformly to the Fourier 2π-periodic extension of the function Cosh[x], restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic1=Plot[{f13[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->All];

pic2=Plot[Evaluate[{fft[f13[#]&,x,Pi]}],{x,-20,20},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11 Pi,14 Pi,2Pi],PlotRange->All];
(*
pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,Cosh[Pi]}],Point[{# Pi,Exp[-Pi]}],Point[{#Pi,Exp[Pi]}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,Exp[-Pi]}],Point[{#Pi,Exp[Pi]}]}&/@Range[-11,13,2]}
}];
*)
pic3=Plot[Evaluate[{((Sinh[π])/π)+((2 Sinh[π])/π)(∑_(n=1)^nn)((((-1))^n)/(1+(n^2)))Cos[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0-2,Cosh[Pi]+2}},AspectRatio->1/GoldenRatio,AxesOrigin-> 0,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[0,40,5]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f13[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->All];

pic2=Plot[Evaluate[{fft[f13[#]&,x,Pi]}],{x,-20,20},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11 Pi,14 Pi,2Pi],PlotRange->All];
(*
pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,Cosh[Pi]}],Point[{# Pi,Exp[-Pi]}],Point[{#Pi,Exp[Pi]}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,Exp[-Pi]}],Point[{#Pi,Exp[Pi]}]}&/@Range[-11,13,2]}
}];
*)
pic3=Plot[Evaluate[{((Sinh[π])/π)+((2 Sinh[π])/π)(∑_(n=1)^nn)((((-1))^n)/(1+(n^2)))Cos[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic3,PlotRange->{{-2.5Pi,2.5Pi},{0-2,Cosh[Pi]+2}},AspectRatio->1/GoldenRatio,AxesOrigin-> 0,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[0,40,5]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

Example 14:  Sinh[x]  on  -π < x ≤π

Clear[f14,x]; f14[x_]:=Sinh[x];

on the interval  (-π,π]

The coefficient (Subscript[a, 0])

FullSimplify[(1/(2 Pi))Integrate[Sinh[x],{x,-Pi,Pi}]]

The coefficients (Subscript[a, n])

FullSimplify[(1/Pi)Integrate[Sinh[x] Cos[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

The coefficients (Subscript[b, n])  (identical to the corresponding coefficient for Exp[x])

FullSimplify[(1/Pi)Integrate[Sinh[x] Sin[n x],{x,-Pi,Pi}],And[n∈Integers,n>0]]

Thus the Fourier series of the given function is

((2 Sinh[π])/π)(∑_(n=1)^∞)(((((-1))^(n+1))n)/(1+(n^2))) Sin[n x])

This series converges pointwise to the Fourier 2π-periodic extension of the function Sinh[x], restricted to (-π,π], as illustrated in the following graph and manipulation

Module[{pic1,pic2,pic2a,pic3,nn},nn=20;pic1=Plot[{f14[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->All];

pic2=Plot[Evaluate[{fft[f14[#]&,x,Pi]}],{x,-20,20},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11 Pi,14 Pi,2Pi],PlotRange->All];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,0}],Point[{# Pi,Sinh[-Pi]}],Point[{#Pi,Sinh[Pi]}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,Sinh[-Pi]}],Point[{#Pi,Sinh[Pi]}]}&/@Range[-11,13,2]}
}];
pic3=Plot[Evaluate[{((2 Sinh[π])/π)(∑_(n=1)^nn)(((((-1))^(n+1))n)/(1+(n^2))) Sin[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Sinh[Pi]-2,Sinh[Pi]+2}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-40,40,5]},ImageSize->is]]

Or, the same picture with Manipulate

Manipulate[Module[{pic1,pic2,pic2a,pic3},pic1=Plot[{f14[x]},{x,-Pi,Pi},PlotStyle->{{Thickness[0.01],Blue}},PlotRange->All];

pic2=Plot[Evaluate[{fft[f14[#]&,x,Pi]}],{x,-20,20},PlotStyle->{{Thickness[0.005],Green}},Exclusions->Range[-11 Pi,14 Pi,2Pi],PlotRange->All];

pic2a=Graphics[{
{PointSize[0.02],Green,{Point[{# Pi,0}],Point[{# Pi,Sinh[-Pi]}],Point[{#Pi,Sinh[Pi]}]}&/@Range[-11,13,2]},{PointSize[0.014],White,{Point[{# Pi,Sinh[-Pi]}],Point[{#Pi,Sinh[Pi]}]}&/@Range[-11,13,2]}
}];
pic3=Plot[Evaluate[{((2 Sinh[π])/π)(∑_(n=1)^nn)(((((-1))^(n+1))n)/(1+(n^2))) Sin[n x]}],{x,-12,14},PlotStyle->{{Thickness[0.003],Black}},PlotPoints->200];Show[pic1,pic2,pic2a,pic3,PlotRange->{{-2.5Pi,2.5Pi},{-Sinh[Pi]-2,Sinh[Pi]+2}},AspectRatio->1/GoldenRatio,Ticks->{Range[-10 Pi,10Pi,(Pi/2)],Range[-40,40,5]},ImageSize->is]],{{nn,10,"n"},Join[Range[10],Range[15,30,5]]},ControlType->Setter]

Numerical series at special values of x

x = π/2

Notice that the convergence theorem implies that for a specific x = π the following numerical series

((2 Sinh[π])/π)(∑_(n=1)^∞)(((((-1))^(n+1))n)/(1+(n^2)))Sin[n (π/2)]

which equals

((Sinh[π])/π)(∑_(k=1)^∞)(((((-1))^(k+1))(2k-1))/(2 (k^2)-2k+1))

converges to  Sinh[π/2].

Thus

(∑_(k=1)^∞)(((((-1))^(k+1))(2k-1))/(2 (k^2)-2k+1))=((π Sinh[π/2])/(Sinh[π]))=((π Sinh[π/2])/(2Sinh[π/2]Cosh[π/2]))=((π )/(2Cosh[π/2]))

Mathematica knows this formula

(∑_(k=1)^∞)(((((-1))^(k+1))(2k-1))/(2 (k^2)-2k+1))