Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions