Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#2. Modify the provided Matlab code for the bisection method to incorporate Inpu

ID: 3199243 • Letter: #

Question

#2. Modify the provided Matlab code for the bisection method to incorporate Inputs: f, a, b, TOL, ?tmax Stopping criterion: Relative error S TOL or k S itmax Consider the following equations defined on the given intervals: I. 3x-ex = 0, [1,2] II. 2 I1. 2x cos(2.x) (+1)2-0, I-1,0] For each of the above equations, a. Use Maple to find the analytic solution p on the interval. b. Find the approximate root by using your Matlab with TOL-10,itmax 10 Reportp, p-P P1for n 2 1, in a table format. This question related to Numerical Anlysis. Please solve this question step by step and make it clear to understand. Please send clear picture. Thanks!

Explanation / Answer

The MATLAB code for the bisection method for our required solution is as follows

clear all;
clc;
% Declaration of first function in terms of variable x
f1=@(x) (3*x)-exp(x);         
% Declaration of second function in terms of variable x
f2=@(x) (2*x*cos(2*x) - (x+1)^2);

l1=[1 2];   % Limits for first function
l2=[-1 0]; % Limits for second function

itmax=10;       % Iteration value
tol=10^(-6);    % Tolerance value
%==== Calculation for f1 ====
ll=l1(1);
ul=l1(2);
i=1;
while(i<=10)
bisect=(ll+ul)/2;
if(abs(f1(bisect))<=tol)
    break;
else
if(f1(ll)*f1(bisect)<0)
ul=bisect;
else
ll=bisect;  
end
end
i=i+1;
end
sol_f1=bisect; % Final Solution variable for first function
%==== Calculation for f2 ====
ll=l2(1);
ul=l2(2);
i=1;
while(i<=10)
bisect=(ll+ul)/2;
if(abs(f2(bisect))<=tol)
    break;
else
if(f2(ll)*f2(bisect)<0)
ul=bisect;
else
ll=bisect;  
end
end
i=i+1;
end
sol_f2=bisect; % Final Solution variable for second function

Therefore after executing this we will get the results for the two functions