DigitHelm

Newton's Method Calculator

Find roots of equations using Newton's iterative method with step-by-step convergence.

PRESET FUNCTIONS

What Is the Newton's Method Calculator?

Newton's method (also called the Newton-Raphson method) is an iterative root-finding algorithm that converges on a solution to f(x) = 0 with quadratic speed, the number of correct decimal places roughly doubles each iteration. Starting from an initial guess x₀, each step draws a tangent line to the curve at xₙ and uses its x-intercept as the next approximation xₙ₊₁.

  • Convergence table: every iteration shows xₙ, f(xₙ), f′(xₙ), xₙ₊₁, and the absolute error, making it easy to see the quadratic speedup in action.
  • Adjustable tolerance: set the stopping criterion from 1e-4 (quick) to 1e-15 (near machine precision).
  • Up to 100 iterations: for slowly converging or nearly-converging cases.
  • 7 preset functions: load a classic example in one click to explore the method immediately.
  • Graceful failures: derivative-near-zero and divergence cases give helpful explanations, not silent NaN values.

Formula

xₙ₊₁ = xₙ − f(xₙ) / f′(xₙ)
Newton-Raphson iteration, each step improves the root approximation quadratically
SymbolMeaningNotes
xₙCurrent approximation at iteration nStarts at user-supplied x₀
f(xₙ)Function value at xₙApproaches 0 as method converges
f'(xₙ)Derivative at xₙComputed by central difference: [f(x+h)−f(x−h)] / 2h
xₙ₊₁Next (improved) approximationTangent line intersection with x-axis
|xₙ₊₁−xₙ|Absolute error (stopping criterion)Convergence when error < tolerance
OrderQuadratic convergenceDoubles correct decimal digits each iteration

How to Use

  1. 1Enter a function using x as the variable. Examples: x^3-x-2, sin(x)-0.5, exp(x)-3. Or click a preset button.
  2. 2Enter an initial guess x₀, a value reasonably close to the root you want to find.
  3. 3Adjust tolerance (default 1e-10) and maximum iterations as needed.
  4. 4Click "Find Root" or press Enter to run the iteration.
  5. 5The convergence table shows each step. A green "Converged" banner confirms the root.
  6. 6If the method fails, try a different x₀. Functions can have multiple roots, the one found depends on x₀.
  7. 7Click Clear to reset and try a new function.

Example Calculation

Example, Find the real root of x³ − x − 2 = 0

f(x) = x³ − x − 2, x₀ = 1.5, tolerance = 1e-10 Iter xₙ f(xₙ) f'(xₙ) |error| 1 1.5000000000 0.8750000 5.7500000 1.52e-1 2 1.3478261 0.1006878 4.4458 2.28e-2 3 1.3252004 0.0011691 4.2652 2.74e-4 4 1.3247182 1.66e-7 4.2609 3.89e-8 5 1.3247180 4.4e-15 4.2609 , Converged: root ≈ 1.324717957244 in 5 iterations

Convergence rate verification

Error sequence: 0.152 → 0.0228 → 2.74e-4 → 3.89e-8 → ... Ratio of errors: 0.15 → 0.012 → 1.4e-4 → ... → Each error ≈ (previous error)² × constant → Quadratic convergence ✓

When Newton's method fails

  • f'(x₀) ≈ 0: if the derivative is near zero at the starting point, the tangent is nearly horizontal and the next iterate shoots far away.
  • Multiple roots: if f has a local extremum between x₀ and the root, the iteration may converge to a different root or cycle.
  • Discontinuities: functions with jumps or undefined points near the root can cause erratic behavior.
  • Solution: try different starting guesses, or first bracket the root with the bisection method.

Understanding Newton's Method

The Geometric Interpretation

Geometrically, each Newton-Raphson step draws a tangent line to the curve y = f(x) at the point (xₙ, f(xₙ)). The tangent has slope f′(xₙ) and passes through (xₙ, f(xₙ)). Its equation is y − f(xₙ) = f′(xₙ)(x − xₙ). Setting y = 0 and solving for x gives the next iterate: xₙ₊₁ = xₙ − f(xₙ)/f′(xₙ). This is repeated until the iterates stop changing within the tolerance.

The method is derived from the first-order Taylor expansion of f around xₙ: f(xₙ₊₁) ≈ f(xₙ) + f′(xₙ)(xₙ₊₁ − xₙ). Setting the left side to zero and solving for xₙ₊₁ gives the update rule. Higher-order terms are dropped, which is why the method is not exact, but for well-behaved functions near a simple root, the convergence is spectacularly fast.

Quadratic Convergence Explained

Newton's method has quadratic (second-order) convergence near a simple root, meaning the error eₙ₊₁ ≈ C × eₙ², where C is a constant depending on f″ and f′ at the root. This implies the number of correct decimal digits roughly doubles each step. Starting with 1 correct digit: after 1 iteration you have 2, then 4, then 8, then 16. For most practical functions, machine precision (15–16 decimal digits) is reached in 5–8 iterations from a reasonably good starting guess.

  • Bisection method: linear convergence, one new bit (one decimal digit per 3.3 steps) per iteration.
  • Secant method: superlinear (order ≈ 1.618), faster than bisection, no derivative needed.
  • Newton's method: quadratic (order 2), fastest single-root convergence of standard methods.
  • Halley's method: cubic (order 3), uses second derivative; rarely worth the extra cost.

Derivative Approximation via Central Difference

This calculator computes f′(x) numerically using the central difference formula: f′(x) ≈ [f(x + h) − f(x − h)] / (2h), with h = 10⁻⁷. This symmetric formula has O(h²) truncation error, far more accurate than the forward difference [f(x+h) − f(x)] / h which has only O(h) error. The value h = 10⁻⁷ balances truncation error (decreases with h) against floating-point cancellation error (increases with h), and is optimal for double-precision arithmetic.

  • The numerical derivative introduces a small error but is transparent to the user, no need to enter f′ manually.
  • For very flat functions (f′ near zero at the root), the numerical derivative becomes inaccurate, this is flagged.
  • Results are equivalent to analytical derivatives for all polynomial, trigonometric, and exponential functions tested.

Practical Applications of Newton-Raphson

Newton's method is one of the most widely used numerical algorithms in science and engineering. It underpins iterative solvers in finite element analysis, optimization, signal processing, and computer graphics. Specific applications include:

  • Square root computation: x = √a by solving f(x) = x² − a = 0. The fast inverse square root (used in game engines) is based on this.
  • Solving transcendental equations: e.g. x = cos(x) for fixed-point problems in physics.
  • Polynomial root finding: part of the Durand-Kerner and Jenkins-Traub algorithms for all roots of a polynomial.
  • Implicit function solving in physics simulations: Newton-Raphson is embedded in every major FEA solver.
  • Interest rate calculation: finding the IRR (internal rate of return) of cash flow series (Newton-Raphson on the NPV polynomial).

Frequently Asked Questions

What is Newton's method and what problem does it solve?

Newton's method (also called Newton-Raphson) is an iterative algorithm for finding roots of a real-valued function f(x), that is, values of x where f(x) = 0. It starts with an initial guess x₀ and repeatedly improves it using the formula xₙ₊₁ = xₙ − f(xₙ)/f′(xₙ).

  • Each iteration computes a tangent line to y = f(x) at the current point.
  • The next approximation is where that tangent crosses the x-axis.
  • Convergence is quadratic, correct digits double each step.
  • Requires f to be differentiable near the root.

It can find roots of polynomials, trigonometric equations, exponentials, or any function expressible in closed form. It cannot directly find complex roots (only real roots are computed here).

How do I enter functions correctly in this calculator?

Use x as the variable. Supported syntax:

x^2 - 5 → x² − 5 2*x^3 - x + 1 → 2x³ − x + 1 sin(x) - 0.5 → sin x − 0.5 exp(x) - 3 → eˣ − 3 ln(x) - 1 → ln(x) − 1 sqrt(x) - 2 → √x − 2 cos(x)*x → x cos(x) abs(x) - 1 → |x| − 1

Use ^ for exponentiation, * for multiplication (required between numbers and x), and standard function names: sin, cos, tan, asin, acos, atan, exp, ln, log, sqrt, abs. Constants pi and e are built-in.

Why does Newton's method sometimes fail to converge?

Several situations can prevent convergence:

  • Derivative near zero: if f'(xₙ) ≈ 0, the next iterate jumps far away. Try a different starting point.
  • Poor initial guess: if x₀ is far from the root or near a local extremum, the method may converge to a different root or diverge.
  • Oscillation: some functions cause the iterates to cycle between two values without converging.
  • No real root: if f(x) has no real roots, the iteration diverges. (Example: x² + 1 = 0 has only complex roots.)
  • Discontinuous function: Newton's method requires f to be smooth (continuously differentiable) near the root.

Remedies: bracket the root first (find a and b where f(a) and f(b) have opposite signs), then use the midpoint as x₀. Or use a hybrid method like Brent's method which combines bisection and secant.

What does quadratic convergence mean in practice?

Quadratic convergence means the number of correct significant digits approximately doubles each iteration. If after one step you have 3 correct digits, after the next you have ~6, then ~12, then ~15 (machine precision).

Error sequence for x³−x−2=0, x₀=1.5: Iter 1: error ≈ 0.152 (0 decimal places) Iter 2: error ≈ 0.0228 (1 decimal place) Iter 3: error ≈ 2.7×10⁻⁴ (3 decimal places) Iter 4: error ≈ 3.9×10⁻⁸ (7 decimal places) Iter 5: error ≈ 4×10⁻¹⁵ (14 decimal places)

This is why Newton's method is so powerful, for most problems in science and engineering, 5–8 iterations yield results accurate to 15 decimal places.

How is the derivative computed if I only enter f(x)?

This calculator computes f′(x) automatically using the central difference formula:

f′(x) ≈ [f(x + h) − f(x − h)] / (2h), h = 10⁻⁷

The central difference is more accurate than the forward difference [f(x+h)−f(x)]/h because it has O(h²) truncation error instead of O(h). The step size h = 10⁻⁷ is chosen to balance truncation error (shrinks as h→0) against floating-point cancellation error (grows as h→0). For all standard functions (polynomials, trig, exponentials), this gives derivative accuracy equivalent to 6–8 significant figures, sufficient for Newton's method to converge to full machine precision.

What is the difference between Newton's method and bisection method?

  • Bisection: requires a bracket [a,b] where f(a)·f(b)<0. Always converges (linear). Halves the interval each step.
  • Newton's: requires only one starting point x₀ and the derivative. Converges quadratically when it converges, much faster.
  • Bisection: guaranteed convergence, slow (adds ~1 digit per 3.3 iterations).
  • Newton's: not guaranteed but usually very fast (doubles correct digits each iteration).
  • Hybrid: Brent's method combines both, guaranteed like bisection, fast like secant near the root.

In practice: use Newton's method when you have a good starting point. Use bisection first to bracket the root, then switch to Newton's for speed. For critical applications, use a robust hybrid method like Brent's or Illinois.

Can Newton's method find all roots of a polynomial?

Newton's method finds one root at a time, starting from one initial guess. To find all roots of a polynomial of degree n:

  • Run Newton's method from multiple starting points across the domain.
  • Once a root r is found, divide it out: f(x) / (x − r) to get a lower-degree polynomial.
  • Repeat for the deflated polynomial to find the next root.
  • Beware of numerical instability in polynomial deflation, the Jenkins-Traub algorithm handles this more robustly.

For a quadratic, use the quadratic formula. For cubics and quartics, dedicated solvers (Cardano's formula) are available. For degree 5+, numerical root-finding (Newton's method, Durand-Kerner, etc.) is the only general approach.

Related Calculators