1. Somebody claims that square root of 10 can be calculated by the following alg
ID: 3879974 • Letter: 1
Question
1. Somebody claims that square root of 10 can be calculated by the following algorithm: a. Set initial value: x 3 b. Find by this equation: 10 X 2x. 2 c. Update the value of x, by using:. d. repeat stepsb' and ‘c, using the updated x0 until- e. If the condition in step 'd' is met, final x, is the answer. knew _4" rld 10 To find out whether this proposed method is true or not, write a code in MATLAB · based on the above algorithm to find square root of 10 Determine how many iterations are needed for this purpose.Explanation / Answer
xold = 3;
format long
epsilon = 10/(2*xold) - xold/2;
xnew = xold + epsilon
iter = 1;
while abs((xnew-xold)/xold) >= 10E-6
iter = iter + 1;
xold = xnew;
epsilon = 10/(2*xold) - xold/2;
xnew = xold + epsilon
end
%display the results with 10 decimal places
fprintf("It took %d iterations and the square root of 10 is %.10f ", iter, xnew);
output
======xnew = 3.16666666666667
xnew = 3.16228070175439
xnew = 3.16227766016984
It took 3 iterations and the square root of 10 is 3.1622776602
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.