Question: Consider the following function: f(x) = x^2 2xe^(-x) + e^(2x) a. Perform five interactions of the Newton method (initial guess = 0) by hand to

Consider the following function: f(x) = x^2 2xe^(-x) + e^(2x)

a. Perform five interactions of the Newton method (initial guess = 0) by hand to estimate the functions root.

b. Use the Matlab file provided in class (i.e. bisect.m) to solve the functions root using the Bisection method between 0 and 1 within a 0.00002 error. Show as many significant digits in your output as possible.

Bisect.m matlab code

function bisect(f,a,b,tol,n)

% Bisection method for solving the nonlinear

%equation f(x)=0.

a0=a;

b0=b;

iter=0;

u=feval(f,a);

v=feval(f,b);

c=(a+b)*0.5;

err=abs(b-a)*0.5;

disp('_____________________________________________________________________')

disp(' iter a b c f(c) |b-a|/2 ')

disp('_____________________________________________________________________')

fprintf(' ')

if (u*v<=0)

while (err>tol)&(iter<=n)

w=feval(f,c);

fprintf('%2.0f %10.4f %10.4f %12.6f %10.6f %10.6f ',iter,a,b,c,w,err)

if (w*u<0)

b=c;v=w;

end

if (w*u>0)

a=c;u=w;

end

iter=iter+1;

c=(a+b)*0.5;

err=abs(b-a)*0.5;

end

if (iter>n)

disp(' Method failed to converge')

end

else

disp(' The method cannot be applied f(a)f(b)>0')

end

% Plot f(x) in the interval [a,b].

fplot(f, [a0 b0])

xlabel('x');ylabel('f(x)');

grid

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!