Question: f = @ ( x ) x ^ 3 - 1 0 * x - 5 ; xl = 2 ; xu = 4 ;

f = @(x) x^3-10*x -5;
xl =2;
xu =4;
fxl = f(xl);
fxu = f(xu);
if fxl * fxu >0
error('Initial guesses do not bracket the root.');
end
% Set tolerance and maximum number of iterations
tol =1e-8;
maxIter =1000;
% Initialize variables
xr =0;
error = inf;
iter =0;
while abs(error)> tol && iter maxIter
xr_prev = xr;
xr = xu - fxu *(xl - xu)/(fxl - fxu);
% Evaluate the function at xr
fxr = f(xr);
if fxr * fxl 0
xu = xr;
fxu = fxr;
elseif fxr * fxu 0
xl = xr;
fxl = fxr;
else
break;
end
if xr ~=0
error =(xr - xr_prev)/ xr;
end
iter = iter +1;
end
% Display results
fprintf('Root found at xr =%.8f
', xr);
fprintf('Number of iterations: %d
', iter);
fprintf('Error: %.8e
', abs(error));
A5-3. Modify the code used in Example 4 to find the root only at f(x)0.01 using
Newton-Rephson Method without showing any iteration. Also find the root of
equation, f(x)=x5-3x-10, take initial guess, x0=2
 f = @(x) x^3-10*x -5; xl =2; xu =4; fxl =

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!