A Different Looking Sine Function

Consider
f(x) = sin(x) for 0<=x<=Pi
0 for Pi<=x<=2Pi

Remember, we actually need the periodic extension of f(x).

This function use useful in the theory of diodes.


  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];


  Clear[a0,a,b,Sn]
  a0=(1/(2Pi))(Integrate[0,{x,-Pi,0}]+
  Integrate[Sin[x],{x,0,Pi}]);


  a=(1/Pi)Table[Integrate[0 u[x][[i]],{x,-Pi,0}]+
  Integrate[Sin[x] u[x][[i]],{x,0,Pi}],{i,1,10}];


  b=(1/Pi)Table[Integrate[0 v[x][[i]],{x,-Pi,0}]+
  Integrate[Sin[x] v[x][[i]],{x,0,Pi}],{i,1,10}];


  a0
  a

Can you see the pattern?

Can you see the pattern? ...


  b

It doesn't take rocket scientist to figure out this pattern:
b1=1/2 and bk=0 for k>1

Let's calculate a few partial sums.


  Sn=Table[a0+Sum[a[[k]]Cos[k x],{k,1,n}]
  +Sum[b[[k]]Sin[k x],{k,1,n}],{n,1,10}];

Let's see how we did.


  Clear[sn1,sn3,sn5,sn10]


  sn1=Plot[Sn[[1]],{x,-2 Pi,2 Pi},DisplayFunction->Identity];
  Show[funcgraph,sn1,PlotLabel->
  FontForm["a0+a1Cos[x]+b1Sin[x]",{"Helvetica-Bold",12}]];


  sn3=Plot[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}]];


  sn5=Plot[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}]];


  sn10=Plot[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