function y = approx_sqrt(x)y = x;while abs(y^2 - x) > 1e-7*x y = (x/y + y)/2
This is part of the code in my lecture class. I wonder what is the purpose of setting y = x at the begining?
Can anyone explain to me? Thank you so much.
loopMATLABwhile loop
function y = approx_sqrt(x)y = x;while abs(y^2 - x) > 1e-7*x y = (x/y + y)/2
Best Answer