- Integer square root
In
number theory , the integer square root (isqrt) of apositive integer "n" is the positive integer "m" which is the greatest integer less than or equal to thesquare root of "n",:
For example, because and .
Algorithm
To calculate , and in particular, , one can use
Newton's method for the equation , which gives us the recursive formula: One can choose for example as initial guess.The
sequence converges quadratically to as . It can be proven (the proof is not trivial) that one can stop as soon as:to ensure thatDomain of computation
Although is irrational for most , the sequence contains only rational terms. Thus, with Newton's method one never needs to exit the field of rational numbers in order to calculate , a fact which has some theoretical advantages.
topping criterion
One can prove that is the largest possible number for which the stopping criterion :ensures in the algorithm above.
Since actual computer calculations involve roundoff errors, a stopping constant less than 1 should be used, e.g.:.
See also
*
Methods of computing square roots External links
* [http://www.codecodex.com/wiki/index.php?title=Calculate_an_integer_square_root Code to calculate the integer square root]
* [http://mathcentral.uregina.ca/RR/database/RR.09.95/grzesina1.html A geometric view of the square root algorithm]
Wikimedia Foundation. 2010.