Fourier Series of a Function

f[x_]=(1- HeavisideTheta[x]) (Abs[x+Pi/2]-Pi/2) + HeavisideTheta[x] (Pi/2-Abs[x-Pi/2]);

startplot=Plot[f[x],{x,-Pi,Pi}]

beta[k_] = 4 (-1)^k/( Pi (2 k+1)^2 );

approx[n_,x_]=Sum[beta[k] Sin[(2 k+1) x],{k,0,n}];

Show[startplot,Plot[approx[0,x],{x,-Pi,Pi}]]

Show[startplot,Plot[approx[0,x],{x,-Pi,Pi}],Plot[approx[1,x],{x,-Pi,Pi}]]

Show[startplot,Plot[approx[2,x],{x,-Pi,Pi},PlotStyle->Black],Plot[approx[1,x],{x,-Pi,Pi},PlotStyle->Red]]