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

Write a function myNewtonBasin1D.m with the following definition: function [x, f

ID: 3727337 • Letter: W

Question

Write a function myNewtonBasin1D.m with the following definition: function [x, flag, z] - NewtonMethod1D(f, df, x0, tol, maxIter) where · f, df are the function we are looking for the roots of and its derivative respectively ·xo is an initial approximation tol is a desired level of tolerance for approximating a root and maxIter is the maximum number of iterations of Newton's methocd You can choose any suitable stopping criteria for your Newton steps. Your results might differ slightly dependiug on the stopping criterion used but should not be fundamentally different. The function should return x, an approximation to a root, if the Newton method iterations converge; or an empty variable, if the Newton method doesn't converge and . flag that is either 1 if the method converges or 0 if it does not converge or there are other issues

Explanation / Answer

Hi,

As per the problem statement , Please find the solution below:

As part of this I implemeted method , testing matlab files.Please find below:

newtonMethod1D.m:

callNewtonImpl.m:

% Newton method implementation to solve the non-linear equation as follows  

% Given Equation fx = x^3-6*x^2+11*x-6=0
% Diff equation for fx is df = 3*x^2 -12*x +11 =0

% Given tol = 10^(-12)
% maxIter = 10
% range : 0:0.1:4


fx = x^3-6*x^2+11*x-6;
df = 3*x^2 -12*x +11;

tol = 10^(-12) ;
maxIter = 10;
range =0:0.1:4;

x0=0;
[x, flag,z] = newtonMethod1D(fx,df,x0,tol,maxIter);

Thanks

function [x,flag,z] = newtonMethod1D (f,df,x0,tol,maxIter)
  
x =x0;
xOld = x0;
flag=0;
z=[];
for i=1:maxIter
z(i) = xOld;
x = x-(f./df);
  
err = abs(x-xOld);
xOld =x
flag=1;
  
if(err < tol)
break;
end
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