Application Center - Maplesoft

App Preview:

Fourier Series package

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

Learn about Maple
Download Application


 

Image 

FourierSeries package 

Karel Srot,
xsrot@math.muni.cz,
www.math.muni.cz/~xsrot/fourierseries 

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

[Add, ChangeBasis, Coefficients, ConvertToSum, Copy, Create, Degree, Derivate, Evaluate, FOURIERSERIES, GetFourierSeries, SERIESORTHOGONALSYSTEM, ScalarMultiply, SimplifyCoefficients, Truncate]
[Add, ChangeBasis, Coefficients, ConvertToSum, Copy, Create, Degree, Derivate, Evaluate, FOURIERSERIES, GetFourierSeries, SERIESORTHOGONALSYSTEM, ScalarMultiply, SimplifyCoefficients, Truncate]
(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));
 

FOURIERSERIES(S) (1.1)
 

> type(s, FOURIERSERIES);
 

true (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));
 

FourierSeries:-FOURIERSERIES(S) (1.3)
 

Creating series with different period. 

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

FourierSeries:-FOURIERSERIES(S) (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));
 

FourierSeries:-FOURIERSERIES(S) (1.5)
 

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

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

FourierSeries:-FOURIERSERIES(S) (1.6)
 

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

FourierSeries:-FOURIERSERIES(S) (1.7)
 

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

FourierSeries:-FOURIERSERIES(S) (1.8)
 

The data structure of the type FOURIERSERIES: 

> lprint(s);
 

FourierSeries:-FOURIERSERIES(S)
 

> print(op(1,s));
 

S
S
(1.9)
 

ConvertToSum() 

Converting series structure to the regular sum 

> ConvertToSum(s);
 

`+`(1, cos(x), `-`(sin(x)), `*`(`/`(1, 2), `*`(cos(`+`(`*`(2, `*`(x)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(2, `*`(x))))))), Sum(`+`(`*`(n, `*`(cos(`*`(n, `*`(x))))), `-`(`*`(n, `*`(sin(`*`(n, `*`(x... (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');
 

FourierSeries:-FOURIERSERIES(S) (3.1)
 

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

FourierSeries:-FOURIERSERIES(S) (3.2)
 

> Derivate(s3, 'x');
 

FourierSeries:-FOURIERSERIES(S) (3.3)
 

> Derivate(s3, 't');
 

FourierSeries:-FOURIERSERIES(S) (3.4)
 

Evaluate() 

Evaluation 

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

`+`(`/`(1, 2), sum(`+`(`*`(n, `*`(cos(`+`(`*`(`/`(1, 4), `*`(n, `*`(Pi))))))), `-`(`*`(n, `*`(sin(`+`(`*`(`/`(1, 4), `*`(n, `*`(Pi))))))))), n = 3 .. infinity)) (4.1)
 

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

`+`(`-`(`/`(7, 2)), `-`(`*`(3, `*`(`^`(2, `/`(1, 2)))))) (4.2)
 

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

`+`(1, cos(A), `-`(sin(A)), `*`(`/`(1, 2), `*`(cos(`+`(`*`(2, `*`(A)))))), `-`(`*`(`/`(1, 2), `*`(sin(`+`(`*`(2, `*`(A))))))), `*`(3, `*`(cos(`+`(`*`(3, `*`(A)))))), `-`(`*`(3, `*`(sin(`+`(`*`(3, `*`(... (4.3)
 

ChangeBasis() 

Conversion between orthogonal systems. 

> s2;
 

FourierSeries:-FOURIERSERIES(S) (5.1)
 

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

FourierSeries:-FOURIERSERIES(S) (5.2)
 

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

 

`Cannot convert to SinTrigP, converting to CosSinTrigP`
FourierSeries:-FOURIERSERIES(S) (5.3)
 

Add(), ScalarMultiply() 

Adding two series and multiplying the series by a scalar. 

> s;
 

FourierSeries:-FOURIERSERIES(S) (6.1)
 

> s2;
 

FourierSeries:-FOURIERSERIES(S) (6.2)
 

> Add(s,s2);
 

FourierSeries:-FOURIERSERIES(S) (6.3)
 

> Add(s,s2, 1, 3);
 

FourierSeries:-FOURIERSERIES(S) (6.4)
 

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

FourierSeries:-FOURIERSERIES(S2) (6.5)
 

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

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

> s;
 

FourierSeries:-FOURIERSERIES(S) (7.1)
 

> Coefficients(s,5);
 

[5, -5] (7.2)
 

> Degree(s3);
 

infinity (7.3)
 

> Truncate(s3,7);
 

FourierSeries:-FOURIERSERIES(S2) (7.4)
 

> Degree(%);
 

7 (7.5)
 

Copying the series 

> s4:=Copy(s3);
 

FourierSeries:-FOURIERSERIES(S2) (7.6)
 

SimplifyCoefficients() 

Simplify the coefficients 

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

FourierSeries:-FOURIERSERIES(S) (8.1)
 

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

FourierSeries:-FOURIERSERIES(S) (8.2)
 

> Add(s1,s2);
 

FourierSeries:-FOURIERSERIES(S) (8.3)
 

> SimplifyCoefficients(%, simplify);
 

FourierSeries:-FOURIERSERIES(S2) (8.4)
 

GetFourierSeries() 

Computing the Fourier series of the given function. 

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

FourierSeries:-FOURIERSERIES(S) (9.1)
 

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

FourierSeries:-FOURIERSERIES(S) (9.2)
 

Getting the partial sum. 

> t:=Truncate(%, 4);
 

FourierSeries:-FOURIERSERIES(S2) (9.3)
 

> ConvertToSum(t);
 

Sum(`+`(`-`(`/`(`*`(2, `*`(`+`(`^`(-1, n), `*`(`^`(-1, n), `*`(Pi)), `-`(1)), `*`(sin(`*`(n, `*`(x)))))), `*`(Pi, `*`(n))))), n = 1 .. 4) (9.4)
 

Change the orthogonal system. 

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

FourierSeries:-FOURIERSERIES(S) (9.5)
 

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

FourierSeries:-FOURIERSERIES(S) (9.6)
 

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

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

FourierSeries:-FOURIERSERIES(S) (9.7)
 

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

FourierSeries:-FOURIERSERIES(S) (9.8)
 

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

FourierSeries:-FOURIERSERIES(S) (9.9)
 

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

FourierSeries:-FOURIERSERIES(S) (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);
 

`+`(Diff(y(x), x, x), `*`(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));
 

FourierSeries:-FOURIERSERIES(S) (10.2)
 

Create the general series 

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

FourierSeries:-FOURIERSERIES(S) (10.3)
 

Derivate the series two times 

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

FourierSeries:-FOURIERSERIES(S) (10.4)
 

Add the multiple of the series 

> tmp2:=Add(tmp1,S2, 1, 2);
 

FourierSeries:-FOURIERSERIES(S) (10.5)
 

Our equation now has the form 

> tmp2=S1;
 

FourierSeries:-FOURIERSERIES(S) = FourierSeries:-FOURIERSERIES(S) (10.6)
 

Subtract the series 

> S:=Add(lhs(%), rhs(%), 1, -1);
 

FourierSeries:-FOURIERSERIES(S) (10.7)
 

> type(S, FOURIERSERIES);
 

true (10.8)
 

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

Get the general coefficient. 

> Coefficients(S);
 

[`+`(`*`(2, `*`(aN)), `-`(`*`(`^`(n, 2), `*`(aN)))), `+`(`-`(`/`(1, `*`(`^`(n, 4)))), `*`(2, `*`(bN)), `-`(`*`(`^`(n, 2), `*`(bN))))] (10.9)
 

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

{`+`(`*`(2, `*`(aN)), `-`(`*`(`^`(n, 2), `*`(aN)))) = 0, `+`(`-`(`/`(1, `*`(`^`(n, 4)))), `*`(2, `*`(bN)), `-`(`*`(`^`(n, 2), `*`(bN)))) = 0} (10.10)
 

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

{aN = 0, bN = `+`(`-`(`/`(1, `*`(`^`(n, 4), `*`(`+`(`-`(2), `*`(`^`(n, 2))))))))} (10.11)
 

Create the solution. 

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

FourierSeries:-FOURIERSERIES(S) (10.12)
 

Check the solution 

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

FourierSeries:-FOURIERSERIES(S) (10.13)
 

> SimplifyCoefficients(%, simplify);
 

FourierSeries:-FOURIERSERIES(S2) (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.
 

Image