f0[x_]:=x^2

f[x_]:=f0[Mod[x,2Pi,-Pi]]

Plot[f[x],{x,-3Pi,3Pi}]

?Mod

s[n_,x_]:=Pi^2/3-4Sum[(-1)^(k-1) Cos[k x]/k^2,{k,1,n}]

Plot[s[10,x],{x,-3Pi,3Pi}]

Manipulate[Plot[{f[x],s[n,x]},{x,-3Pi,3Pi}],{n,1,20}]

g0[x_]:=x

g[x_]:=g0[Mod[x,2Pi,-Pi]]

sg[n_,x_]:=2Sum[(-1)^(k-1)Sin[k x]/k,{k,1,n}]

Manipulate[Plot[{g[x],sg[n,x]},{x,-3Pi,3Pi},PlotRange->{-4,4},PlotPoints->100],{n,1,50,1}]