Cubic graph

From formulasearchengine
Revision as of 04:17, 8 June 2013 by en>David Eppstein (Undid revision 558848965 by 24.185.3.4 (talk) there IS a number, there ARE infinitely many, but not there ARE a number nor there IS infinitely many)
Jump to navigation Jump to search

In number theory, the integer square root (isqrt) of a positive integer n is the positive integer m which is the greatest integer less than or equal to the square root of n,

isqrt(n)=n.

For example, isqrt(27)=5 because 55=2527 and 66=36>27.

Algorithm

One way of calculating n and isqrt(n) is to use Newton's method to find a solution for the equation x2n=0, giving the recursive formula

xk+1=12(xk+nxk),k0,x0>0.

The sequence {xk} converges quadratically to n as k. It can be proven that if x0=n is chosen as the initial guess, one can stop as soon as

|xk+1xk|<1

to ensure that xk+1=n.

Domain of computation

Although n is irrational for almost all n, the sequence {xk} contains only rational terms when x0 is rational. Thus, with this method it is unnecessary to exit the field of rational numbers in order to calculate isqrt(n), a fact which has some theoretical advantages.

Stopping criterion

One can prove that c=1 is the largest possible number for which the stopping criterion

|xk+1xk|<c

ensures xk+1=n in the algorithm above.

In implementations which use number formats that cannot represent all rational numbers exactly (for example, floating point), a stopping constant less than one should be used to protect against roundoff errors.

See also

External links

Template:Number theoretic algorithms