> sq:=proc(x) if (x>=(-2*evalf(Pi)) and x<(-1*evalf(Pi))) then 1 elif (x>=-1*evalf(Pi) and x<0) then -1 elif (x>=0 and x<evalf(Pi)) then 1 elif (x>=evalf(Pi) and x<2*evalf(Pi)) then -1 end if end proc;
> fsq:=(x,n)->4/(Pi)*sum('sin((2*k-1)*x)/(2*k-1)',k=1..n);
> fs2:=x->fsq(x,2);
> fs5:=x->fsq(x,5);
> fs10:=x->fsq(x,10);
> plot([sq,fs2,fs5,fs10],-6..6);
> plot([sq,fs2,fs5,fs10],-0.3..0.3);
> fs50:=x->fsq(x,50);
> plot([sq,fs50],-0.1..0.1);
> tr:=x-> if (x>=(-4) and x<(-2)) then (x+4) elif (x>=-2 and x<0) then -x elif (x>=0 and x<2) then x elif (x>=2 and x<4) then -(x-4) fi;
> ftr:=(x,n)->1-8/(Pi^2)*sum('cos((2*k-1)*Pi*x/2)/(2*k-1)^2',k=1..n);
> ft2:=x->ftr(x,2);
> ft5:=x->ftr(x,5);
> ft10:=x->ftr(x,10);
> plot([tr,ft2,ft5,ft10],-.1..0.1);
>
>