fourier series transformation using mathematica

5
Assignment No: 13 [ Fourier Series Transformation of Exp(2x). Submitted By- Shashank Mishra, Date: 17.02.2014. In[38]:= gg@x_D = Piecewise@88- Exp@- 2xD, - 1 £ x £ 0<, 8Exp@2xD,0 £ x £ 1<<D Out[38]= -2x - 1 £ x £ 0 ª 2x 0 £ x £ 1 0 True In[55]:= plt@1D = Plot@gg@xD, 8x, - 1, 1<, PlotStyle RGBColor@1.`, 0.41000000000000003`, 0.18`D, AxesOrigin 80, 0<D Out[55]= -1.0 -0.5 0.5 1.0 -6 -4 -2 2 4 6 In[49]:= a@0D = 0.5 * NIntegrate@gg@xD, 8x, - 1, 1<, AccuracyGoal 2, MaxRecursion 6D Out[49]= 2.22045 · 10 -16 In[200]:= hh@x_D = Sum@Evaluate@NIntegrate@gg@tD Sin@mPitD, 8t, - 1, 1<, AccuracyGoal 2, MaxRecursion 6DD Sin@mPixD, 8m, 0, 5<D; In[201]:= plt@2D = Plot@hh@xD, 8x, - 1, 1<D; In[202]:= Show@plt@1D, plt@2DD 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.

Upload: shashank-mishra

Post on 20-Jan-2016

24 views

Category:

Documents


1 download

DESCRIPTION

Mathematica analysis of EXP [2x]

TRANSCRIPT

Page 1: Fourier Series Transformation using Mathematica

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

By- Shashank Mishra, Date: 17.02.2014.

In[38]:= gg@x_D = Piecewise@88-Exp@-2 xD, -1 £ x £ 0<, 8Exp@2 xD, 0 £ x £ 1<<D

Out[38]=

-ã-2 x -1 £ x £ 0

ã2 x 0 £ x £ 1

0 True

In[55]:= plt@1D = Plot@gg@xD, 8x, -1, 1<,

PlotStyle ® RGBColor@1.`, 0.41000000000000003`, 0.18`D, AxesOrigin ® 80, 0<D

Out[55]=

-1.0 -0.5 0.5 1.0

-6

-4

-2

2

4

6

In[49]:= a@0D = 0.5 * NIntegrate@gg@xD, 8x, -1, 1<, AccuracyGoal ® 2, MaxRecursion ® 6D

Out[49]= 2.22045 ´ 10-16

In[200]:= hh@x_D = Sum@Evaluate@NIntegrate@gg@tD Sin@m Pi tD, 8t, -1, 1<,

AccuracyGoal ® 2, MaxRecursion ® 6DD Sin@m Pi xD, 8m, 0, 5<D;

In[201]:= plt@2D = Plot@hh@xD, 8x, -1, 1<D;

In[202]:= Show@plt@1D, plt@2DD

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.

Page 2: Fourier Series Transformation using Mathematica

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@1D = 2 * Integrate@Exp@2 xD, 8x, 0, 1<D

Out[63]= -1 + ã2

In[100]:= an = Sum@ 2 * NIntegrate@Exp@2 xD Cos@n Pi xD, 8x, 0, 1<D Cos@ n Pi xD, 8n, 1, 5<D;

In[96]:= bn = Sum@ NIntegrate@Exp@2 xD Sin@n Pi xD, 8x, 0, 1<D Sin@ n Pi xD, 8n, 1, 5<D;

In[111]:= plt@3D = Plot@an + Ha@1D � 2L, 8x, 0, 1<, PlotStyle ® 8Red, Dashed<D

Out[111]=

0.2 0.4 0.6 0.8 1.0

2

3

4

5

6

In[112]:= plt@4D = Plot@Exp@2 xD, 8x, 0, 1<, PlotRange ® AllD;

2 Assignment 13.nb

Page 3: Fourier Series Transformation using Mathematica

In[113]:= Show@plt@4D, plt@3DD

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_D = Piecewise@88Exp@-2 xD, -1 £ x £ 0<, 8Exp@2 xD, 0 £ x £ 1<<D

Out[114]=

ã-2 x -1 £ x £ 0

ã2 x 0 £ x £ 1

0 True

In[220]:= plt@5D = PlotAPiecewiseA99ã-2 x

, -1 £ x £ 0=, 9ã2 x

, 0 £ x £ 1==, 0E, 8x, 0, 1<E

Out[220]=

0.2 0.4 0.6 0.8 1.0

2

3

4

5

6

7

Assignment 13.nb 3

Page 4: Fourier Series Transformation using Mathematica

In[119]:= l@0D = 0.5 * NIntegrate@kk@xD, 8x, -1, 1<, AccuracyGoal ® 2, MaxRecursion ® 6DOut[119]= 3.19453

In[213]:= hh2@x_D = Sum@2 * NIntegrate@gg@tD Cos@m Pi tD, 8t, 0, 1<D Cos@m Pi xD, 8m, 0, 5<D

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@Π xD + 0.587791 Cos@2 Π xD -

0.361494 Cos@3 Π xD + 0.157839 Cos@4 Π xD - 0.133829 Cos@5 Π xD

In[210]:= plt@7D = [email protected] - 2.41941 Cos@Π xD + 0.587791 Cos@2 Π xD - 0.361494 Cos@3 Π xD +

0.157839 Cos@4 Π xD - 0.133829 Cos@5 Π xD, 8x, 0, 1<, PlotStyle ® 8Red, Dashed<D

Out[210]=

0.2 0.4 0.6 0.8 1.0

5

6

7

8

9

10

In[222]:= plt@6D = [email protected] - 2.41941 Cos@Π xD + 0.587791 Cos@2 Π xD - 0.361494 Cos@3 Π xD +

0.157839 Cos@4 Π xD - 0.133829 Cos@5 Π xD, 8x, 0, 1<, PlotStyle ® 8Red, Dashed<D

Out[222]=

0.2 0.4 0.6 0.8 1.0

2

3

4

5

6

4 Assignment 13.nb

Page 5: Fourier Series Transformation using Mathematica

In[223]:= Show@plt@6D, plt@5D, plt@7D , PlotRange ® AllD

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@100D = ReadList@"\\\\clusterfs.ceas1.uc.edu\\students\\mishrash\\Desktop\\plotdata.txt",

8Number, Number<D;

In[290]:= Maker@pts_D := Fit@pts, 81, x<, xD

In[291]:= Maker@a@100DDOut[291]= 1296.04 - 0.508211 x

In[292]:= [email protected] - 0.508211 x, 8x, -5, 5<D

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