Remark: the focus of ths excercise is to see that the partial sums
of harmonics approximates the original function.  Nevertheless, the
usual focus of Fourier analysis is finding the amplitudes of
the various harmonics (i.e., the amount of each frequency present in the
original signal: the list of a[[m]] coeficients).  One will often
see plots of |a[[m]]|^2 vs. frequency, called spectral energy 
distributions or just spectra.




Square Wave:

result= 1/Sqrt[2 Pi] Integrate[1 Exp[-I m x],{x,-c,c}]
a0 = Limit[result , m->0]
a=Table[result,{m,25}] 
e[m_,x_] = 1/Sqrt[2 Pi] Exp[I m x]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,4}]] /. c->Pi/2
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,8}]] /. c->Pi/2
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,16}]] /. c->Pi/2
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]
Show[%,%%%,%%%%%]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,25}]] /. c->Pi/2
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]


Cos Pulse:

result= 1/Sqrt[2 Pi] Integrate[Cos[Pi x/(2 c)] Exp[-I m x],{x,-c,c}]
a0 = result /. m->0
a=Table[result,{m,25}] 
e[m_,x_] = 1/Sqrt[2 Pi] Exp[I m x]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,4}]] /. c->1.
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,8}]] /. c->1.
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,16}]] /. c->1.
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]
Show[%,%%%,%%%%%]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,25}]] /. c->1.
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]

because of a 0/0 indeterminate case for  the a[[1]] coefficient , c=Pi/2 is a bit tricky:

a[[1]]= Limit[a[[1]] , c->Pi/2]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,4}]] /. c->Pi/2
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,8}]] /. c->Pi/2
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,16}]] /. c->Pi/2
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]
Show[%,%%%,%%%%%]
ComplexExpand[a0/Sqrt[2 Pi] + Sum[2 Re[a[[m]] e[m,x]],{m,1,25}]] /. c->Pi/2
Plot[%,{x,-2 Pi,2 Pi},PlotPoints->1000]




