Matlab Question

Integrals that cannot be evaluated in closed form sometimes can be evaluated approximately by using a series representation for the integrand. For example, the following integral is used for some probability calculations:

I found a solution to this question, but I’m having trouble inputting it into matlab. Can someone explain it further for me (what suppose to be in the script file, the command window, what’s missing from the solution etc.), or if you have a different way to solve this question please do share.

The solution I found is:

(a)

syms x

E= taylor(exp(-x^2),11);

F= double(int(E,0,1)

F=

0.7467

G= taylor(exp(-x^2),13);

H= double(int(G,0,1))

H=

0.7468

error= H-F

error=

1.0684-004

(b)

erf(1)*sqrt(pi)/2

ans=

0.7468

## Expert Answer

(A)

%This is using Matlab R2012b

syms x

E= taylor(exp(-x^2),x,’order’,11);

F= double(int(E,0,1));

fprintf(‘Integral value:%fn’,F);

G= taylor(exp(-x^2),x,’order’,13);

H= double(int(G,0,1));

error = H – F;

fprintf(‘Error = %fn’,error);

(B)

%This is using Matlab R2012b

syms x

E= taylor(exp(-x^2),x,’order’,11);

F= double(int(E,0,1));

fprintf(‘Integral value:%fn’,F);

H= erf(1)*sqrt(pi)/2;

error = H – F;

fprintf(‘Error = %fn’,error);