Answered step by step
Verified Expert Solution
Question
1 Approved Answer
function x = NRCubeRoot(R, x0, nmax, delta, eps) % Applies Newton's Method to find cube root of R. % % Input: % R = number
function x = NRCubeRoot(R, x0, nmax, delta, eps)
% Applies Newton's Method to find cube root of R.
%
% Input:
% R = number whose cube root we want.
% x0 = initial iterate.
% nmax = maximum number of iterates to use.
% delta = tolerance for small derivatives (break if df(x) is too small).
% eps = stopping tolerance. Stop when relative magnitude of f is small
% enough.
% Output:
% x = approximate cube root of f.
%% Initialization.
% Initalize x. Stores sequence of iterates.
x = zeros(nmax + 1,1);
x(1) = x0;
%% Run Newton's Method.
for n = 2 : nmax + 1
% Check if df is small.
df = ?; % CHANGE THIS. % df is derivative evaluated at last iterate x(n-1).
if (% INSERT STOPPING CONDITION)
x = x(n-1); % extract root from sequence of approximate solutions.
break % leave the loop.
end
% Compute step length to check for convegence.
d = ?; % CHANGE THIS.
% Stop if absolute step length is sufficiently small.
if (% INSERT STOPPING CONDITION.)
x = x(n-1); % extract root from sequence of approximate solutions.
break % leave the loop.
end
% Update x using the formula from Part(a).
x(n) = ?; % INSERT UPDATE FORMULA.
end
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