A Different Looking Sine Function
In[61]:=
Clear[part1,part2,part3,part4,part5,part6];
part1=Plot[0,{x,-3Pi,-2Pi},DisplayFunction->Identity];
part2=Plot[Sin[x],{x,-2Pi,-Pi},DisplayFunction->Identity];
part3=Plot[0,{x,-Pi,0},DisplayFunction->Identity];
part4=Plot[Sin[x],{x,0,Pi},DisplayFunction->Identity];
part5=Plot[0,{x,Pi,2Pi},DisplayFunction->Identity];
part6=Plot[Sin[x],{x,2Pi,3Pi},DisplayFunction->Identity];
funcgraph=Show[part1,part2,part3,part4,part5,part6,
DisplayFunction->$DisplayFunction,
Ticks->{{-3Pi,-2Pi,-Pi,Pi,2Pi,3Pi},Automatic},AspectRatio->1/3];

In[62]:=
Clear[a0,a,b,Sn]
a0=(1/(2Pi))(Integrate[0,{x,-Pi,0}]+
Integrate[Sin[x],{x,0,Pi}])
Out[62]=
1 -- Pi
In[63]:=
a[n_]:=(1/Pi)(Integrate[0 u[x,Pi,n],{x,-Pi,0}]+
Integrate[Sin[x] u[x,Pi,n],{x,0,Pi}])
Table[a[k],{k,1,10}]
Out[63]=
-2 -2 -2 -2 -2
{0, ----, 0, -----, 0, -----, 0, -----, 0, -----}
3 Pi 15 Pi 35 Pi 63 Pi 99 Pi
In[64]:=
b[n_]:=(1/Pi)(Integrate[0 v[x,Pi,n],{x,-Pi,0}]+
Integrate[Sin[x] v[x,Pi,n],{x,0,Pi}])
Table[b[k],{k,1,10}]
Out[64]=
1
{-, 0, 0, 0, 0, 0, 0, 0, 0, 0}
2
Can you see the pattern?
Let's calculate a few partial sums.
In[65]:=
Sn=Table[Sum[a[k]u[x,Pi,k]+b[k]v[x,Pi,k],{k,1,n}],{n,1,10}];
Let's see how we did.
In[66]:=
Clear[sn1,sn3,sn5,sn10]
In[67]:=
sn1=Plot[a0+Sn[[1]],{x,-2 Pi,2 Pi},DisplayFunction->Identity];
Show[funcgraph,sn1,PlotLabel->
FontForm["a0+a1Cos[x]+b1Sin[x]",{"Helvetica-Bold",12}]];

In[68]:=
sn3=Plot[a0+Sn[[3]],{x,-2 Pi,2 Pi},DisplayFunction->Identity];
Show[funcgraph,sn3,PlotLabel->
FontForm["a0+Sum(k=1 to 3) akCos[kx]+bkSin[kx]",
{"Helvetica-Bold",12}]];

In[69]:=
sn5=Plot[a0+Sn[[5]],{x,-2 Pi,2 Pi},DisplayFunction->Identity];
Show[funcgraph,sn5,PlotLabel->
FontForm["a0+Sum(k=1 to 5) akCos[kx]+bkSin[kx]",{"Helvetica-Bold",12}]];

In[70]:=
sn10=Plot[a0+Sn[[10]],{x,-2 Pi,2 Pi},DisplayFunction->Identity];
Show[funcgraph,sn10,PlotLabel->
FontForm["a0+Sum(k=1 to 10) akCos[kx]+bkSin[kx]",{"Helvetica-Bold",12}]];

Up to Fourier Series Examples