iconEuler Examples

Fourier Series in Maxima

by R. Grothmann

In this notebook, we compute and plot a Fourier series of the function
f(x)=x. Using the convergence theorem, we can derive the famous Euler
sum.
>&sum(1/n^2,n,1,inf) | simpsum
                                   2
                                 pi
                                 ---
                                  6

Compute the Fourier coefficients of x.
>&declare(n,integer);
>&integrate(x*sin(n*x),x)/%pi; A &= at(%,x=2*pi)-at(%,x=0)
                                   2
                                 - -
                                   n

>&integrate(x*cos(n*x),x)/%pi; A &= at(%,x=2*pi)-at(%,x=0)
                                  0

>&integrate(x,x)/(2*%pi); A &= at(%,x=2*pi)-at(%,x=0)
                                  pi

So we get the series as pi - 2 sum_n cos(n)/n. Let us evaluate
this sum in Euler for x=1.
>n=1:100000; x=1; -2*sum(sin(n*x)/n)+pi
0.999981349343
And plot the series up to n=30.
>function map f(x,n) := -2*sum(sin((1:n)*x)/(1:n))+pi
>plot2d("f",0,2pi;30); insimg;

Fourier Series in Maxima

>

Examples Homepage