Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To calculate √a with Newton-Raphson, start with a nonzero estimate x0 and repeatedly apply:

xn+1 = (xn + a / xn) / 2

For example, starting with x0 = 3 gives √10 ≈ 3.1622776602 after only a few iterations. The method produces an approximation, not an exact decimal result, so you should stop using a defined tolerance rather than when the displayed digits merely appear unchanged.

What Newton-Raphson is solving

The square root of a positive number a is the nonnegative number r that satisfies:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

r2 = a

Instead of calculating the square root directly, rewrite the problem as finding a zero of:

f(x) = x2 - a

For a > 0, this equation has two roots, +√a and -√a. To calculate the ordinary, nonnegative square root, use a positive starting estimate.

The Newton-Raphson formula

For a differentiable function, Newton-Raphson updates an estimate with:

xn+1 = xn - f(xn) / f'(xn)

Geometrically, the method draws a tangent to the function at the current estimate. Where that tangent crosses the x-axis becomes the next estimate. This general rule requires a starting value and a derivative that is not zero at the current estimate. See the NIST Digital Library of Mathematical Functions’ description of Newton’s rule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Deriving the square-root iteration

For square roots:

f(x) = x2 - a
f'(x) = 2x

Substitute these into Newton-Raphson:

xn+1 = xn - (xn2 - a) / (2xn)

Simplifying:

xn+1 = (2xn2 - xn2 + a) / (2xn)

Therefore:

xn+1 = (xn + a / xn) / 2

Each update averages the current estimate with a / xn. For square roots, this same recurrence is also known as the Babylonian method.

Worked example: calculating √10

Choose x0 = 3, since 3 is close to √10.

Iteration Calculation Approximation
x0 Starting estimate 3
x1 (3 + 10 / 3) / 2 3.1666666667
x2 (3.1666666667 + 10 / 3.1666666667) / 2 3.1622807018
x3 (3.1622807018 + 10 / 3.1622807018) / 2 3.1622776602
x4 Next update 3.1622776602

The exact value is √10; the decimal shown is an approximation. Checking the result gives:

(3.1622776602)2 ≈ 10

Choosing the initial estimate

The starting value affects how quickly the method reaches the desired precision. It does not normally change the final positive root when a > 0 and the starting value is positive.

  • For a simple general rule, use x0 = a when a > 1.
  • Use x0 = 1 when 0 < a < 1.
  • For a hand calculation, choose a nearby familiar square. For √10, 3 is better than 10.
  • For very large or very small values, estimate the magnitude from powers of 10 or use the number’s binary exponent in a production implementation.

For a > 0, a positive starting value remains positive. A negative starting value generally converges to -√a, so require x0 > 0 when the principal square root is required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When to stop iterating

A practical successive-estimate test is:

|xn+1 - xn| ≤ ε max(1, |xn+1|)

This combines absolute and relative tolerance. It avoids demanding an unnecessarily tiny absolute difference when the answer is large.

You can also check the residual, which measures how closely the result satisfies the original equation:

|xn+12 - a| ≤ ε max(1, |a|)

A robust implementation can use both tests, along with a maximum iteration count. A small residual is useful, but it is not a universal guarantee of small root error in every floating-point scale. Likewise, a tiny step can occur because floating-point arithmetic has stagnated.

For hand calculations, a tolerance such as 10-3 or 10-6 may be sufficient. Ordinary numerical work may use 10-10 to 10-12, but the appropriate value depends on the input scale and number representation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python implementation

def newton_sqrt(a, tolerance=1e-12, max_iterations=100):
    if a < 0:
        raise ValueError("no real square root")
    if a == 0:
        return 0.0

    # Positive starting estimate for the principal root.
    x = a if a >= 1 else 1.0

    for iteration in range(1, max_iterations + 1):
        next_x = 0.5 * (x + a / x)

        if abs(next_x - x) <= tolerance * max(1.0, abs(next_x)):
            return next_x, iteration

        x = next_x

    raise RuntimeError("maximum iterations exceeded")

This educational version handles negative inputs, zero, tolerance, and nontermination through a maximum iteration limit. It returns the approximation and the number of iterations used.

For example:

root, iterations = newton_sqrt(10)
print(root)       # approximately 3.162277660168379
print(iterations)

For production software, a language’s built-in square-root routine is usually preferable. Standard-library implementations may include specialized handling for rounding, overflow, underflow, exceptional values, and hardware instructions.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why the method converges quickly

Let r = √a and define the error as en = xn - r. Since a = r2:

xn+1 - r = (xn + r2 / xn) / 2 - r

Rearranging gives:

en+1 = en2 / (2xn)

Near the root, the next error is approximately proportional to the square of the current error. This is called quadratic convergence: once the estimate is close, accuracy improves very rapidly. It does not mean that the visible number of correct decimal digits exactly doubles every time, because rounding and finite-precision arithmetic eventually limit the result. The MIT discussion of square roots via Newton’s method provides a detailed treatment of this behavior.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Edge cases and numerical limitations

  • a = 0: Return 0 before starting the iteration. Starting with zero would make a / x undefined.
  • a < 0: There is no real square root. A complex Newton iteration is a separate problem.
  • x0 = 0: Invalid for a nonzero input because the recurrence divides by zero.
  • Negative seed: It generally approaches the negative root, not the principal positive root.
  • Extreme magnitudes: The intermediate expression a / x or a verification square such as x * x can overflow or underflow even when the desired square root is representable. Scaled arithmetic or exponent-based initialization may be needed.
  • Poor estimates: A very poor starting value can create large intermediate values or unnecessary iterations, even though ordinary positive inputs are especially well behaved.
  • Floating-point stagnation: Eventually, next_x may equal x because the difference is smaller than the available precision. The iteration limit prevents an endless loop.
  • Display-based stopping: Do not stop because formatted decimal output looks unchanged. Compare numeric values using a tolerance.

Newton-Raphson compared with other methods

Method Strength Trade-off
Built-in square root Usually the most appropriate choice for application code; tested and optimized. Does not demonstrate the underlying algorithm.
Newton-Raphson Very fast near the root and requires only the current estimate. Needs a derivative in the general case and a sensible stopping policy.
Bisection Guaranteed convergence when a continuous function is bracketed. Usually slower and requires a valid interval.
Secant Approximates the derivative and needs no explicit derivative formula. Uses two starting values and is generally less predictable here.
Babylonian method Simple square-root recurrence. For square roots, it is algebraically the same Newton-Raphson iteration.

Summary

To calculate the principal square root of a > 0:

  1. Choose a positive, nonzero estimate x0.
  2. Update it with xn+1 = (xn + a / xn) / 2.
  3. Stop when the step size, residual, or both meet your tolerance.
  4. Handle a = 0 and negative inputs before iterating.
  5. Use a standard-library square-root function instead when reliability and production performance matter more than implementing the method yourself.

Newton-Raphson is not universally convergent for every equation and starting value, but its specialized square-root recurrence has particularly favorable behavior with positive inputs and positive estimates.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.