Problem 2 [35]
Use the function file named NewtonSqrtCS3.m posted on D2L as a starting template to accomplish the following criteria.
(a) Change the function name to your surname
(b) Ensure that the long format statement is included in the function file.
(c) Introduce a variable called it outside the loop and initialize to 0
(d) Within the loop update it by 1 (e) Modify the statement in the while loop so that it allows you to check the termination of the loop when the conditional is > delta and it is < maxit
(f) Run your function to compute the square root of 59 using a delta value of 5E-3 and maxit of 3.
(g) Repeat step f with a delta value of 5E-9 and maxit of 7.
function NewtonSqrtCS3(x,delta,maxit)
%The simple square root function with added functionality%
%Synopsis:Call the function NewtonSqrt and pass a numerical value 'a' whiose square root we need to approximate.Pass also delta and maxit for convergence control
if nargin<2,delta=5E-6;end
if nargin<3,maxit=5;end
r=x/2;
rold=x;
%Use fprintf command as a place holder
fprintf("\n the estimate for the aquare root of x is \n')
%disp({'The approach to sqrt(a) for a=',num2str(a)]);
%i=0;
while abs((r-rold)/rold)>delta
%while i<6
rold=r;
r=0.5*(rold+x/rold);
disp(r)
%i=i+1;
end
fprintf('%14.6f\n',r)
%disp('Matlab"s value:')
fprintf('Matlab"s value is:')
disp(sqrt(x))
Problem 2 [35] Use the function file named NewtonSqrtCS3.m posted on D2L as a starting template...
Problem 4 (programming): Create a MATLAB function named mynewton.m to estimate the root for any arbitrary function f given an initial guess xo, an absolute error tolerance e and a maximum number of iterations max iter. Follow mynewton.m template posted in homework 2 folder on TritonED for guidance. You are not required to use the template. The function should return the approximated root ^n and the number of steps n taken to reach the solution. Use function mynewton.m to perform...