Application Center - Maplesoft

# Fourier Series package

You can switch back to the summary page by clicking here.

FourierSeries package

Faculty of Science, Masaryk University, Czech Republic

This package concept differs from other Fourier series packages. It provides new data structure for the representation of trigonometric series and few procedures to manipulate trigonometric series and to compute Fourier series. Some procedures and data structure are (for better understanding) similar (but not exactly the same) to OrthogonalSeries package so in many cases you can use the OrthogonalSeries package help files.

 > restart:

 > with(FourierSeries);

 (1)

Create()

Usage of the procedure Create is similar to OrthogonalSeries[Create] but there are few differences.

 > s:=Create({[1,2,3], n}, SinTrigP(n,x));

 (1.1)

 > type(s, FOURIERSERIES);

 (1.2)

There are four types of orthogonal systems: SinTrigP, CosTrigP, CosSinTrigP and ExpTrigP2. ExpTrigP2 means that the series is defined as a sum which goes from the zero to the plus infinity (and not from the minus infinity to the plus infinity).

 > Create({[1,2,3], n}, CosTrigP(n,x));

 (1.3)

Creating series with different period.

 > Create({[1,2,3], n}, CosTrigP(n,x), Pi);

 (1.4)

When creating the series with both sine and cosine terms, the coefficients are specified by a list of pairs. Also it is necessary to use the option "general" to set the general coefficient of the series.

 > s:=Create({[1,[1,-1],[1/2,-1/2]], 'general'=[n,-n]}, CosSinTrigP(n,x));

 (1.5)

Some other possibilities to specify the coefficients (see OrthogonalSeries[Create]):

 > Create({[1,[1,-1],[1/2,-1/2]]}, CosSinTrigP(n,x));

 (1.6)

 > Create({[0=1,1=[1,-1],3=[1/2,-1/2]], 'general'=n, n=5..10}, CosSinTrigP(n,x));

 (1.7)

 > Create({[0=1,1=[1,-1],3=[1/2,-1/2]], 'general'=n, n=5..10}, ExpTrigP2(n,x));

 (1.8)

The data structure of the type FOURIERSERIES:

 > lprint(s);

 FourierSeries:-FOURIERSERIES(S)

 > print(op(1,s));

 (1.9)

ConvertToSum()

Converting series structure to the regular sum

 > ConvertToSum(s);

 (2.1)

 > lprint(%);

 1+cos(x)-sin(x)+(1/2)*cos(2*x)-(1/2)*sin(2*x)+Sum(n*cos(n*x)-n*sin(n*x), n = 3 .. infinity)

Derivate()

Derivate the series

 > s2:=Derivate(s, 'x');

 (3.1)

 > s3:=Create({[t], t*n}, CosTrigP(n,x));

 (3.2)

 > Derivate(s3, 'x');

 (3.3)

 > Derivate(s3, 't');

 (3.4)

Evaluate()

Evaluation

 > Evaluate(s, x=Pi/4);

 (4.1)

 > Evaluate(s, x=Pi/4, trunc=5);

 (4.2)

 > Evaluate(s, x=A, trunc=5);

 (4.3)

ChangeBasis()

Conversion between orthogonal systems.

 > s2;

 (5.1)

 > ChangeBasis(s2, `ExpTrigP2`(n,x));

 (5.2)

 > ChangeBasis(%, `SinTrigP`(n,x));

 (5.3)

Adding two series and multiplying the series by a scalar.

 > s;

 (6.1)

 > s2;

 (6.2)

 (6.3)

 (6.4)

 > s3:=ScalarMultiply(s2, (1-alpha));

 (6.5)

Coefficient(), Degree(), Truncate(), Copy()

Getting the coefficients and the degree of the partial sum, copying the series.

 > s;

 (7.1)

 > Coefficients(s,5);

 (7.2)

 > Degree(s3);

 (7.3)

 > Truncate(s3,7);

 (7.4)

 > Degree(%);

 (7.5)

Copying the series

 > s4:=Copy(s3);

 (7.6)

SimplifyCoefficients()

Simplify the coefficients

 > s1:=Create({-1/(n-1)}, SinTrigP(n,x));

 (8.1)

 > s2:=Create({n/(n-1)}, SinTrigP(n,x));

 (8.2)

 (8.3)

 > SimplifyCoefficients(%, simplify);

 (8.4)

GetFourierSeries()

Computing the Fourier series of the given function.

 > GetFourierSeries(cos(x)^4,x=-Pi..Pi);

 (9.1)

 > GetFourierSeries(x+signum(x),x=-Pi..Pi);

 (9.2)

Getting the partial sum.

 > t:=Truncate(%, 4);

 (9.3)

 > ConvertToSum(t);

 (9.4)

Change the orthogonal system.

 > ChangeBasis(t, `ExpTrigP2`(n,x));

 (9.5)

 > GetFourierSeries(x^2,x=-Pi..Pi, exp);

 (9.6)

Getting the Fourier series of the odd/even periodic extension.

 > GetFourierSeries(x^2,x=0..Pi, even);

 (9.7)

 > GetFourierSeries(x^2,x=0..Pi, even, exp);

 (9.8)

 > GetFourierSeries(x^3,x=-Pi..Pi);

 (9.9)

 > GetFourierSeries(x^3,x=-Pi..0, odd);

 (9.10)

 >

Solving the differential equation using the Fourier series.

 > Diff(y(x),x\$2)+2*y(x)=Sum(sin(n*x)/n^4,n=1..infinity);

 (10.1)

 > S1:=Create({[0],'general'=[0,1/n^4]}, CosSinTrigP(n,x));

 (10.2)

Create the general series

 > S2:=Create({[a0], 'general'=[aN,bN]}, CosSinTrigP(n,x));

 (10.3)

Derivate the series two times

 > tmp1:=Derivate(Derivate(S2, 'x'), 'x');

 (10.4)

Add the multiple of the series

 (10.5)

Our equation now has the form

 > tmp2=S1;

 (10.6)

Subtract the series

 (10.7)

 > type(S, FOURIERSERIES);

 (10.8)

Series S should have all coefficients equal to zero. Hence a0 = 0.

Get the general coefficient.

 > Coefficients(S);

 (10.9)

 > {%[1]=0, %[2]=0};

 (10.10)

 > solve(%, {aN, bN});

 (10.11)

Create the solution.

 > Y:=Create({subs(%, bN)}, SinTrigP(n,x));

 (10.12)

Check the solution

 > Add(Derivate(Derivate(Y, 'x'), 'x'), Y, 1, 2);

 (10.13)

 > SimplifyCoefficients(%, simplify);

 (10.14)

Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.