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

Use the function file (provided) as a starting template to accomplish the follow

ID: 642755 • Letter: U

Question



Use the function file (provided) as a starting template to accomplish the following criteria:

b) insert the long format command into the function.
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 greater than delta and 'it' is less than maxit.
f) run the function to compute the square root of a prime number between 120 and 175 using a delta value of 5E-3 and maxit of 10.
g) repeat step 6 with a delta value of 5E-9 and maxit of 12.

Use the function file (provided) as a starting template to accomplish the following criteria: b) insert the long format command into the function. 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 greater than delta and 'it' is less than maxit. f) run the function to compute the square root of a prime number between 120 and 175 using a delta value of 5E-3 and maxit of 10. g) repeat step 6 with a delta value of 5E-9 and maxit of 12. The function file The list of the prime numbers referred to in question f) The command line instructions and output of step f) The command line instructions and output of step g)

Explanation / Answer

Hi

function NewtonSqrtCS3(x, delta, maxit)
if nargin<2, delta=5E-6; end
if nargin<3, maxit=5; end
r=x/2;
rold=x;
fprintf(' the estimate for square root of x is ')
%disp('the approach to sqrt(a) for a=', num2str(a)]);
%i=0;
%it=0;
while (abs((r-rold)/rold)>delta))&& (it<maxit))
%while i<6
rold=r; %Save old value of r for next convergence
%it=it+1;
r=0.5*(rold+x/rold);
disp(r)
%i=i+1;
end
fprintf('%14.6f ' ,r)
%disp('Matlab' 's valu')
fprintf('Matlab' 's value is: ')
disp(sqrt(x))

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