3.6 Obtain Fourier Series approximation

3.6.1 Example 1
3.6.2 Example 2
3.6.3 Example 3

3.6.1 Example 1

3.6.1.1 Maple
3.6.1.2 Mathematica

Obtain Fourier Series approximation of f(x)=e|x| for 1<x<1

3.6.1.1 Maple
restart; 
f:=x->exp(-abs(x)); 
f_approx:=OrthogonalExpansions:-FourierSeries(f(x),x=-1..1,infinity ): 
f_approx:=subs(i=n,f_approx);
 
1e1+n=1(2((1)ne11)cos(πnx)π2n2+1)

3.6.1.2 Mathematica

Mathematica does not have a buildin function to give general series expression as the above with Maple. There is a user written package and answer here https://mathematica.stackexchange.com/questions/149468/a-more-convenient-fourier-series which provides this.

In Mathematica it is possible to obtain the terms using the command FourierSeries . For example the terms n=0,n=1,n=1 can be obtained using

expr = Exp[-Abs[x]]; 
FourierSeries[expr, x, 1, FourierParameters -> {1, Pi}]
 
(1+e)eiπxe+eπ2+(1+e)eiπxe+eπ2+e1e

see https://reference.wolfram.com/language/ref/FourierSeries.html for definitions of FourierParameters used above.

3.6.2 Example 2

3.6.2.1 Maple

Obtain Fourier Series approximation of

f(x)={2xhL0xL22h(Lx)LL2xL

For 0<x<L

3.6.2.1 Maple
restart; 
f:=x->piecewise(0<x and x<L/2,2*x*h/L, L/2<x and x<L, 2*h*(L-x)/L); 
f_approx:=OrthogonalExpansions:-FourierSeries(f(x),x=0..L,infinity ): 
f_approx:=subs(i=n,f_approx): 
simplify(%) assuming L>0
 
2(n=1h((1)n1)cos(2πnxL)π2n2)+h2

3.6.3 Example 3

3.6.3.1 Maple

Obtain Fourier Series approximation of coshx for 1<x<1.

3.6.3.1 Maple
restart; 
f:=x->cosh(x); 
f_approx:=OrthogonalExpansions:-FourierSeries(f(x),x=-1..1,infinity ): 
f_approx:=subs(i=n,f_approx); 
convert(%,trig);
 
sinh(1)+(n=12sinh(1)(1)ncos(πnx)π2n2+1)