22 May 2026
Heron's Method
An ancient square-root algorithm rediscovered as a special case of Newton-Raphson, with a derivation, convergence analysis, and implementations in Python, TypeScript, and C++.
The Idea
Heron of Alexandria described a method for computing in the first century [1].
The iteration is self-correcting: overshoot and undershoot cancel each other, pulling every successive estimate toward from above.

Why It Works — The Newton-Raphson Connection
Finding is equivalent to finding the positive root of . Newton-Raphson [2] linearises at the current guess and solves for the zero of the tangent line:
Substituting and gives exactly Heron's formula:
Convergence
Newton-Raphson converges quadratically when the initial guess is close enough to the root. Letting be the error at step , a Taylor expansion of around gives the error recurrence:
The number of correct decimal digits doubles with each iteration. The plot below shows this collapse — note how the curve drops off a cliff rather than declining steadily.
Worked Example —
Start with . Applying the recurrence with :
After only three steps the result agrees with to eight significant figures. The 3D plot below shows why the iteration works geometrically — the surface and the truth surface intersect exactly along the fixed-point curve .
Implementation
The loop terminates when consecutive iterates differ by less than a chosen tolerance. A safe initial guess is (large ) or (small ).
def heron_sqrt(s: float, tolerance: float = 1e-10) -> float:
if s < 0:
raise ValueError("Cannot take sqrt of a negative number")
if s == 0:
return 0.0
x = s if s >= 1 else 1.0
while True:
x_next = (x + s / x) / 2
if abs(x_next - x) < tolerance:
return x_next
x = x_nextReferences
- [1]Hero of Alexandria. Metrica. c. 60 CE.
- [2]Newton, Isaac. Method of Fluxions. 1671.