The calculator uses sequences derived from refinements of Newton's method (see Les Algorithmes, Bibliothèque Tangente 37, 2013, or Itération et Récurrence, Bibliothèque Tangente 76, 2021).
The function f used here is defined by f (x) = x2 ‒ a.
We solve f (x) = 0 because its solution is precisely a, the quantity we are interested in. Let's implement the algorithm.
The derivative of f is f ' (x) = 2 x, and we have f(x)f′(x)=x2−a2x=x2−a2x.
This gives Heron's sequence:
un+1=un−f(un)f′(un)=un−un2+a2un=un2+a2un=12(un+aun).
Let's now illustrate the method with a = 163. To initialize the computation, we can start with a, or, since 163 lies between 144 = 122 and 169 = 132, with 12.
After just three iterations of the algorithm, the result is remarkable, since 163=12,7671453348037…
In fact, the number of correct decimal places doubles (at least) with each loop—a phenomenon known as quadratic convergence.
Each iteration requires one addition and one division, together with a division by 2, which is easy to program in binary: just three operations in all.
Schönhage's trick ---------------------
The main drawback of Heron's sequence (see above) is that it involves a division: division is a "troublesome" and "slow" operation, even for an electronic circuit. But the division "a / *un" can be replaced by an iteration: once again, we use Newton's method to compute the reciprocal 1/b of a real number b > 0. This time we use the function g defined by g(x)=1x−b, which gives the sequence v defined by vn*+1 = *vn(2 ‒ bvn*).
Indeed: g(x)=1x−b, and g′(x)=−1x2, hence g(x)g′(x)=1x−b−1x2=−x2(1x−b)=−x+bx2,
that is, vn+1=vn−g(un)g′(un)=vn+vn−bvn2=vn(2−bvn).
We can do even better! The German mathematician Arnold Schönhage (born in 1934) had the idea of coupling the two Newton iterations, a combination that proved more efficient than using the two methods separately. To find an approximation to the square root of a > 0, we start with the sequence u, defined by
un+1=12(un+aun)=un+a−un22un.
To compute 12un, we use Newton's method to compute reciprocals.
In this setting, we use two sequences, u and v:
{un+1=un+(a−un2)vn,\[0,7mm]vn+1=vn(2−2unvn)=vn+(1−2unvn)vn, with v0=12u0.