f[x_]=Switch[Mod[x,2 π]≤π,True,Mod[x,2*Pi],False,0]

p1 = Plot[f[x],{x,-4*Pi,4*Pi},PlotStyle->{Black,Thick},PlotRange->{{-4*Pi,4*Pi},{-1,3.5}}]

F[x_,n_] = Pi/4 + Sum[(((-1)^m-1)/(Pi*m^2))*Cos[m*x]+(((-1)^(m+1))/m)*Sin[m*x],{m,1,n}];

Manipulate[
Plot[F[x,n],{x,-4*Pi,4*Pi}],
{{n,0},0,10,1,Appearance->"Labeled"}];

p2 = Plot[Evaluate[Table[F[x,i],{i,{0,1,2,3}}]],{x,-4*Pi,4*Pi},Axes->True,PlotRange->{{-4*Pi,4*Pi},{-1,3.5}}];

Show[p1,p2]

Plot[{f[x],F[x,10]},{x,-4*Pi,4*Pi},Axes->True,PlotRange->{{-4*Pi,4*Pi},{-1,3.5}}]

g0[x_] =({{\[Piecewise], ({{0, -3<x≤-1}, {1, -1<x≤1}, {0, 1<x≤3}})}})

g[x_]=g0[Mod[x,6,-3]]

p3=Plot[g[x],{x,-12,12},Axes->True,PlotRange->{{-12,12},{-0.1,1.3}},PlotStyle->{Thick,Black}]

G[x_,n_]=1/3+Sum[(2/(m*Pi))*Sin[m*Pi/3]*Cos[((m*Pi*x)/3)],{m,1,n}];

p4 = Plot[Evaluate[Table[G[x,i],{i,{0,1,3,5}}]],{x,-12,12},Axes->True,PlotRange->{{-12,12},{-0.1,1.3}}];

Show[p3,p4]

Plot[{g[x],1/3+Sum[(2/(m*Pi))*Sin[m*Pi/3]*Cos[((m*Pi*x)/3)],{m,1,8}]},{x,-12,12}]

Plot[g[x]-(1/3+Sum[(2/(m*Pi))*Sin[m*Pi/3]*Cos[((m*Pi*x)/3)],{m,1,8}]),{x,-12,12},PlotRange->{{-12,12},{-1,1}}]

Plot[Abs[g[x]-(1/3+Sum[(2/(m*Pi))*Sin[m*Pi/3]*Cos[((m*Pi*x)/3)],{m,1,8}])],{x,-12,12},PlotRange->{{-12,12},{-0.1,0.75}}]

Plot[Exp[-1/x^2],{x,-2,2}]