20 lines
321 B
Plaintext
20 lines
321 B
Plaintext
function [x_out] = Heron(x0, n)
|
|
xn = x0;
|
|
for i = 1:n
|
|
xn = xn - (xn*xn-2) / 2*xn;
|
|
end
|
|
|
|
x_out = xn;
|
|
end
|
|
|
|
--------------------------------------------------
|
|
function [x_out] = Heron(x0, n)
|
|
y=
|
|
xn = x0;
|
|
for i = 1:n
|
|
xn = xn - (xn*xn-2) / 2*xn;
|
|
end
|
|
|
|
x_out = xn;
|
|
end
|