(* sawtooth: x[+-Pi]=+-Pi; period 2 Pi *)
x[t_]=Mod[t+Pi,2 Pi]-Pi  

(* below version agrees with x[t] only for x in (-Pi,+Pi), but thats all that counts *)
FourierTrigSeries[t,t,5]
                              2 Sin[3 t]   Sin[4 t]   2 Sin[5 t]
Out[2]= 2 Sin[t] - Sin[2 t] + ---------- - -------- + ----------
                                  3           2           5

saw=Plot[%,{t,-4 Pi, 4 Pi}]
(* the series is periodic, even though function t is not *)

(* even triangle wave: x[+-Pi]=+-Pi, x[0]=-Pi *)
x[t_]=Abs[Mod[t-Pi,2 Pi]-Pi] -Pi/2
FourierTrigSeries[-Pi/2+Abs[t],t,5]    

        -4 Cos[t]   4 Cos[3 t]   4 Cos[5 t]
Out[5]= --------- - ---------- - ----------
           Pi          9 Pi        25 Pi

triangle=Plot[%,{t,-4 Pi, 4 Pi}]    

(* square wave even *)
x[t_]=Piecewise[{{-1, t < -Pi/2},{1, -Pi/2 < t < Pi/2},{-1, t > Pi/2}}]
FourierTrigSeries[x[t],t,9] 

         4 Cos[t]   4 Cos[3 t]   4 Cos[5 t]   4 Cos[7 t]   4 Cos[9 t]
 Out[8]= -------- - ---------- + ---------- - ---------- + ----------
            Pi         3 Pi         5 Pi         7 Pi         9 Pi

squareEven=Plot[%,{t,-4 Pi, 4 Pi}]  
        
(* square wave odd *)
x[t_]=Piecewise[{{-1, t < 0},{1, 0 < t }}]
FourierTrigSeries[x[t],t,9] 

         4 Sin[t]   4 Sin[3 t]   4 Sin[5 t]   4 Sin[7 t]   4 Sin[9 t]
Out[11]= -------- + ---------- + ---------- + ---------- + ----------
            Pi         3 Pi         5 Pi         7 Pi         9 Pi

squareOdd=Plot[%,{t,-4 Pi, 4 Pi}]  

(* even half-wave rectified *)
x[t_]=Piecewise[{{Cos[t], -Pi/2 < t < Pi/2}}]
FourierTrigSeries[x[t],t,5] 

         1    Cos[t]   2 Cos[2 t]   2 Cos[4 t]
Out[14]= -- + ------ + ---------- - ----------
         Pi     2         3 Pi        15 Pi
         
halfwave=Plot[%,{t,-4 Pi, 4 Pi}]    

(* even full-wave rectified; note period *)
x[t_]=Abs[Cos[t/2]]
FourierTrigSeries[x[t],t,4] 

         2    4 Cos[t]   4 Cos[2 t]   4 Cos[3 t]   4 Cos[4 t]
Out[17]= -- + -------- - ---------- + ---------- - ----------
         Pi     3 Pi       15 Pi        35 Pi        63 Pi

fullwave=Plot[%,{t,-4 Pi, 4 Pi}]    

(* pulse *)
dt=1
x[t_]=Piecewise[{{1, -dt/2 < t < dt/2}}]
FourierTrigSeries[x[t],t,3]    
                             1                                     3
                2 Cos[t] Sin[-]                     2 Cos[3 t] Sin[-]
          1                  2    Cos[2 t] Sin[1]                  2
Out[21]= ---- + --------------- + --------------- + ----------------- + 
         2 Pi         Pi                Pi                3 Pi

pulse3=Plot[%,{t,-4 Pi, 4 Pi},PlotRange->All]    
FourierTrigSeries[x[t],t,9]    
pulse9=Plot[%,{t,-4 Pi, 4 Pi},PlotRange->All]    
GraphicsGrid[{{saw,triangle},{squareEven,squareOdd},{halfwave,fullwave},{pulse3,pulse9}}]
Export["fourier.pdf",%]
