You are on page 1of 5

Assignment No: 13 [ Fourier Series Transformation of Exp(2x).

Submitted
By- Shashank Mishra, Date: 17.02.2014.
In[38]:= gg[x_] Piecewise[{{Exp[2 x], 1 x 0}, {Exp[2 x], 0 x 1}}]
Out[38]=

2 x
1 x 0

2 x
0 x 1
0 True
In[55]:= plt[1] Plot[gg[x], {x, 1, 1},
PlotStyle RGBColor[1.`, 0.41000000000000003`, 0.18`], AxesOrigin {0, 0}]
Out[55]=
1.0 0.5 0.5 1.0
6
4
2
2
4
6
In[49]:= a[0] 0.5 NIntegrate[gg[x], {x, 1, 1}, AccuracyGoal 2, MaxRecursion 6]
Out[49]= 2.22045 10
16
In[200]:= hh[x_] Sum[Evaluate[NIntegrate[gg[t] Sin[m Pi t], {t, 1, 1},
AccuracyGoal 2, MaxRecursion 6]] Sin[m Pi x], {m, 0, 5}];
In[201]:= plt[2] Plot[hh[x], {x, 1, 1}];
In[202]:= Show[plt[1], plt[2]]
Out[202]=
1.0 0.5 0.5 1.0
6
4
2
2
4
6
The error of approximating the given function using Fourier series expansion is too high. Rea-
son being since we are defining Exp[2x] as an odd function, integral value for the contant term is
zero since odd function integral over range -x to x is always zero.
Let us Solve the Half Range Fourier series expansion of Exp[2x] using cosine series and plot
them to examine the error.
The error of approximating the given function using Fourier series expansion is too high. Rea-
son being since we are defining Exp[2x] as an odd function, integral value for the contant term is
zero since odd function integral over range -x to x is always zero.
Let us Solve the Half Range Fourier series expansion of Exp[2x] using cosine series and plot
them to examine the error.
a[1] 2 Integrate[Exp[2 x], {x, 0, 1}]
Out[63]= 1
2
In[100]:= a
n
Sum[ 2 NIntegrate[Exp[2 x] Cos[n Pi x], {x, 0, 1}] Cos[ n Pi x], {n, 1, 5}];
In[96]:= b
n
Sum[ NIntegrate[Exp[2 x] Sin[n Pi x], {x, 0, 1}] Sin[ n Pi x], {n, 1, 5}];
In[111]:= plt[3] Plot[a
n
(a[1] / 2), {x, 0, 1}, PlotStyle {Red, Dashed}]
Out[111]=
0.2 0.4 0.6 0.8 1.0
2
3
4
5
6
In[112]:= plt[4] Plot[Exp[2 x], {x, 0, 1}, PlotRange All];
2 Assignment 13.nb
In[113]:= Show[plt[4], plt[3]]
Out[113]=
0.2 0.4 0.6 0.8 1.0
2
3
4
5
6
7
Therefore, we can say that cosine half series expansion of exp[2x] is aa much better approxima-
tion.
if we do the even function extension of exp[2x]

2 x
1 x 0

2 x
0 x 1
0 True
and use only cosine terms of
Fourier series, then the coefficients of cosine series are all approaching towards to zero.
In[114]:= kk[x_] Piecewise[{{Exp[2 x], 1 x 0}, {Exp[2 x], 0 x 1}}]
Out[114]=

2 x
1 x 0

2 x
0 x 1
0 True
In[220]:= plt[5] Plot]Piecewise]]]
2 x
, 1 x 0), ]
2 x
, 0 x 1)), 0, {x, 0, 1}
Out[220]=
0.2 0.4 0.6 0.8 1.0
2
3
4
5
6
7
Assignment 13.nb 3
In[119]:= l[0] 0.5 NIntegrate[kk[x], {x, 1, 1}, AccuracyGoal 2, MaxRecursion 6]
Out[119]= 3.19453
In[213]:= hh2[x_] Sum[2 NIntegrate[gg[t] Cos[m Pi t], {t, 0, 1}] Cos[m Pi x], {m, 0, 5}]
The integration x->{-1,1} is reduced to 2* integration {0,1} becaue Cos() is an even fucntion and I
have extended my exp(2x) as an even function as well, therefore their product is also an Even
function.
Out[213]= 6.38906 2.41941 Cos x 0.587791 Cos2 x
0.361494 Cos3 x 0.157839 Cos4 x 0.133829 Cos5 x
In[210]:= plt[7] Plot[6.38906 2.41941 Cos[ x] 0.587791 Cos[2 x] 0.361494 Cos[3 x]
0.157839 Cos[4 x] 0.133829 Cos[5 x], {x, 0, 1}, PlotStyle {Red, Dashed}]
Out[210]=
0.2 0.4 0.6 0.8 1.0
5
6
7
8
9
10
In[222]:= plt[6] Plot[3.2 2.41941 Cos[ x] 0.587791 Cos[2 x] 0.361494 Cos[3 x]
0.157839 Cos[4 x] 0.133829 Cos[5 x], {x, 0, 1}, PlotStyle {Red, Dashed}]
Out[222]=
0.2 0.4 0.6 0.8 1.0
2
3
4
5
6
4 Assignment 13.nb
In[223]:= Show[plt[6], plt[5], plt[7] , PlotRange All]
Out[223]=
0.2 0.4 0.6 0.8 1.0
2
4
6
8
10
As Evident from the graph, dashed curve is of fourier series transformation using even function exten-
sion without using constant term. The graph is parallel to original graph Exp(2x). But the second graph
is an excellent approximation of the given function
In[269]:= a[100] ReadList[
"\\\\clusterfs.ceas1.uc.edu\\students\\mishrash\\Desktop\\plotdata.txt",
{Number, Number}];
In[290]:= Maker[pts_] : Fit[pts, {1, x}, x]
In[291]:= Maker[a[100]]
Out[291]= 1296.04 0.508211 x
In[292]:= Plot[1296.04 0.508211 x, {x, 5, 5}]
Out[292]=
4 2 0 2 4
1294
1295
1296
1297
1298
Now we need to convert this into a piecewise function.
Assignment 13.nb 5

You might also like