Answered! Matlab Question Integrals that cannot be evaluated in closed form sometimes can be evaluated approximately by using a series…

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:

27. Integrals that cannot be evaluated in closed form sometimes can be evalu- ated approximately by using a series representation for the integrand. For example, the following integral is used for some probability calculations (see Chapter 6, Section 6.2) e x dx a. Obtain the Taylor series for e 2 about x 0 and integrate the first six nonzero terms in the series to find I. Use the seventh term to estimate the error. Compare your answer with that obtained with the MATLAB erf function, defined as e dt erf

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

 The script file is given below. Save the script and run it. It should give the result

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

Still stressed from student homework?
Get quality assistance from academic writers!