Matlab Programming using matlab code Your task is to impleme
Matlab Programming (using matlab code)
Your task is to implement the square root function without the builtin sqrt. The iterative update formula for computing square roots is a consequence of Newton\'s Method and the update formula is called the Divide and Average formula. You can find this formula either in the class notes or by a quick web search. Twenty iterations of the update formula will suffice.
Implement a loop/iterative function to compute square root with signature:
function y = sqrt_iterative(x)
Matlab Programming (using matlab code)
Your task is to implement the square root function without the builtin sqrt. The iterative update formula for computing square roots is a consequence of Newton\'s Method and the update formula is called the Divide and Average formula. You can find this formula either in the class notes or by a quick web search. Twenty iterations of the update formula will suffice.
Implement a loop/iterative function to compute square root with signature:
function y = sqrt_iterative(x)
Matlab Programming (using matlab code)
Your task is to implement the square root function without the builtin sqrt. The iterative update formula for computing square roots is a consequence of Newton\'s Method and the update formula is called the Divide and Average formula. You can find this formula either in the class notes or by a quick web search. Twenty iterations of the update formula will suffice.
Implement a loop/iterative function to compute square root with signature:
function y = sqrt_iterative(x)
Solution
function y = sqrt_iterative(x)
% Choose (arbitrarily) a first approach
x= 10;
fa = x/2;
% Divide your number by that first approach
sa = x/fa;
% Get the mean between the two previous numbers
y = mean([fa sa]);
% Repeat until you obtain a good enough root
while abs(x - y^2) > 0.000000001
fa = y;
sa = x/fa;
y = mean([fa sa])
end
