вычисление корня квадратного методом ньютона
Method 2: Newton's iteration An efficient method for computing the square root is found by using Newton's iteration for the equation r^2-x=0. The initial value of r can be obtained by bit counting and shifting, as in the bisection method. The iteration formula is
r'=r/2+x/(2*r).
The convergence is quadratic, so we double the number of correct digits at each step. Therefore, if the initial guess is accurate to one bit, the number of steps n needed to obtain P decimal digits is
n=Ln(P*Ln(10)/Ln(2))/Ln(2)=O(Ln(P)).
|