Problem 2
Find the Fourier Sine series for the function, on the interval and .
First, clear the workspace and define .
> restart: f := x -> x*(Pi - x);
Next compute the general coefficient, .
> b[k] := (2/Pi)*int(f(x)*sin(k*x),x=0..Pi);
Note that if is an integer, then the term involving will be zero. Also, .
To use this coefficient expression in the series, we need to make it a function of .
> coef := unapply(b[k],k);
It is easy to see the pattern for the coefficients.
> b[1] := coef(1);b[2] := coef(2);b[3] := coef(3);b[4] := coef(4);b[5] := coef(5);b[6] := coef(6);
The series - actually an arbitrary partial sum of the series - can be simply defined by
> SF := (x,N) -> sum(coef(k)*sin(k*x),k=1..N);
We can verify the convergence of the series by looking a the first few approximations.
> plot([f(x),SF(x,1),SF(x,3),SF(x,5)],x=0..Pi);
A more informative plot for higher order approximations is a plot of the error.
> plot((f(x)-SF(x,25)),x=0..Pi);
One immediate observation is that the Sine series converges much more quickly than the Cosine series.
The maximum error is almost 100 times smaller with only half as many terms. This is because the function and
the first derivative are continuous under the odd extension.