Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started