Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement Newton\'s Method to obtain approximations to the first three positive

ID: 3603194 • Letter: I

Question

Implement Newton's Method to obtain approximations to the first three positive zeros of f(x) = x sin ( x) + cos (x). In your solution include a copy of the Newton's Method script, a copy of any relevant data tables, and state a conclusion.

The script is the following:

function [x, y, z] = Newton(fun, funpr, x1, tol, kmax)

% newton method
x(1) = x1;
y(1) = feval (fun, x(1));
ypr(1) = feval (funpr, x(1));
for k = 2 : kmax
x(k) = x(k-1) - y(k-1)/ypr(k-1);
y(k) = feval(fun, x(k));
z(k) = x(k) - x(k-1);
if abs(z(k)) < tol
disp('Newton method has converged'); break;
end
ypr(k) = feval(funpr, x(k));
iter = k;
end
if (iter >= kmax)
disp('zero not found to desired tolerance');
end
disp(' k x(k) y(k) x(k)-x(k-1)')
n = length(x);
out = [1, x(1), y(1)]; disp(out)
for k = 2 : n
out = [k, x(k), y(k), z(k)]; disp(out)
end
end

Explanation / Answer

the code has changed

function [x, y, z] = Newton(fun, funpr, x1, tol, kmax)
% newton method
x(1) = x1;
y(1) = feval (fun, x(1));
ypr(1) = feval (funpr, x(1));
for k = 2 : kmax
x(k) = x(k-1) - y(k-1)/ypr(k-1);
y(k) = feval(fun, x(k));
z(k) = x(k) - x(k-1);
if abs(z(k)) < tol
disp('Newton method has converged'); break;
end
ypr(k) = feval(funpr, x(k));
iter = k;
end
if (iter >= kmax)
disp('zero not found to desired tolerance');
end
disp(' k x(k) y(k) x(k)-x(k-1)')
n = length(x);
out = [1, x(1), y(1)]; disp(out)
for k = 2 : n
out = [k, x(k), y(k), z(k)]; disp(out)
end
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote