Question: f = @ ( x ) x ^ 3 - 1 0 * x - 5 ; xl = 2 ; xu = 4 ;
f @x xx ;
xl ;
xu ;
fxl fxl;
fxu fxu;
if fxl fxu
errorInitial guesses do not bracket the root.;
end
Set tolerance and maximum number of iterations
tol e;
maxIter ;
Initialize variables
xr ;
error inf;
iter ;
while abserror tol && iter maxIter
xrprev xr;
xr xu fxu xl xufxl fxu;
Evaluate the function at xr
fxr fxr;
if fxr fxl
xu xr;
fxu fxr;
elseif fxr fxu
xl xr;
fxl fxr;
else
break;
end
if xr ~
error xr xrprev xr;
end
iter iter ;
end
Display results
fprintfRoot found at xr f
xr;
fprintfNumber of iterations: d
iter;
fprintfError: e
abserror;
A Modify the code used in Example to find the root only at using
NewtonRephson Method without showing any iteration. Also find the root of
equation, take initial guess,
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
