Skip to content
Tactiverge

School/○ Innovator/Week 7

Newton's method: ride the tangent

Bisection needs about 20 steps for six decimal places. Newton's method often needs four. What's the catch?

About 40 min · 3 goals · Checked by automated tests

1.Why should I care?

Newton's method uses the slope of the function to jump straight towards the root. Near a well-behaved root it roughly doubles the number of correct digits every step, which is why calculators and microcontrollers use it for square roots. But it trusts the tangent, and tangents can lie.

  • ◇ Derive and apply the Newton update x ← x − f(x)/f′(x).
  • ◇ Compare the convergence of Newton's method and bisection on the same equation.
  • ◇ Recognise and guard against Newton's failure modes: zero slope, overshoot and divergence.

2.Watch

→ Watch the first part, where Newton's method is introduced as following the tangent line to zero, and notice how the starting guess decides where you end up.

Starts with Newton's method as a practical root finder, then shows beautifully how sensitive it is to the starting guess.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

The video is optional: everything you need is also in the lesson text and the interactive.

3.Predict

Newton's method on x² − 2 from x₀ = 1 gives x₁ = 1.5, then x₂ ≈ 1.41667. Roughly how many correct decimal places will x₃ have?

Guess first. Being wrong here is how the surprise works.

4.Discover

Choose x² − 2 and Newton. Step four times and compare the error column with bisection's. Then choose arctan x (Newton trap): start at 1.0, then at 1.5. What does the tangent do from 1.5?

Loading the interactive…

Can't use the interactive? Read a description instead

The stepper shows Newton's method on x² − 2 from 1: the orange tangent at each guess meets the axis at the next guess, 1.5, 1.41667, 1.4142157, with the error column shrinking from 10⁻¹ to 10⁻³ to 10⁻⁶ to 10⁻¹². For arctan x from 1.5, each tangent lands further away and the readout reports divergence.

5.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1 · a fresh version every time

A microcontroller finds a vector length L = √12 with Newton's method on f(x) = x**2 - 12, using x = x - (x**2 - 12) / (2*x). Starting from x0 = 1, what is x after 2 iterations? Give 4 decimal places.

6.Understand

Fast when close

From a good starting guess, Newton's method converges quadratically: the number of correct digits roughly doubles each step. For x² − 2 from 1, four steps give about 12 correct digits, where bisection on [0, 2] would need about 40.

It needs the derivative

You must supply f′(x), worked out by hand or estimated numerically. If f′(x_k) = 0 the tangent is flat and never crosses zero: the method can't continue. Guard against it and cap the number of steps.

It can run away

If the start is far from the root, or the function flattens out, the tangent can throw the next guess further away. arctan x from x₀ = 1.5 diverges. Engineers often bracket first with bisection, then switch to Newton once close, or reject any Newton step that leaves the bracket.

Explain it another way

You're on a hillside in fog and want to reach sea level. Look at the slope under your feet and walk straight downhill as if the slope never changed. Near the coast that works brilliantly; on a long flat plateau it can send you miles the wrong way.

Derivation: Where the Newton update comes from
  1. Near a guess x_k, replace the curve by its tangent line: y ≈ f(x_k) + f′(x_k)·(x − x_k).

  2. Find where that line crosses zero: 0 = f(x_k) + f′(x_k)·(x − x_k).

  3. Solve for x: x_{k+1} = x_k − f(x_k)/f′(x_k). This needs f′(x_k) ≠ 0.

  4. For f(x) = x² − c, f′(x) = 2x, so x_{k+1} = x_k − (x_k² − c)/(2x_k) = (x_k + c/x_k)/2: average the guess with c divided by the guess.

  5. Near a simple root the error obeys e_{k+1} ≈ C·e_k², so an error of 10⁻³ becomes about 10⁻⁶, then 10⁻¹². That's quadratic convergence.

Worked example 1

Newton's method with a step limit and a flat-slope guard, compared with the true root.

import math


def newton(f, df, x, tol=1e-12, max_steps=20):
    """Return (estimate, steps). Raises ValueError on a flat tangent or no convergence."""
    for step in range(1, max_steps + 1):
        slope = df(x)
        if slope == 0:
            raise ValueError(f"flat tangent at x = {x}")
        x_new = x - f(x) / slope
        if abs(x_new - x) < tol:
            return x_new, step
        x = x_new
    raise ValueError("did not converge")


root, steps = newton(lambda x: x * x - 2, lambda x: 2 * x, 1.0)
print(root, steps, abs(root - math.sqrt(2)) < 1e-15)   # 1.414213562373095 6 True

try:
    newton(math.atan, lambda x: 1 / (1 + x * x), 1.5)
except (ValueError, OverflowError) as err:
    print("arctan from 1.5:", type(err).__name__)

Common mix-ups

  • Newton's method always finds the nearest root.
    ✓ It can jump to a different root, or diverge, depending on the starting guess.
  • If a few steps look like they are settling, the answer is right.
    ✓ Check |f(x)| is small and the change between steps is below tolerance, and cap the steps.

7.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 2 · a fresh version every time

A microcontroller finds a vector length L = √3 with Newton's method on f(x) = x**2 - 3, using x = x - (x**2 - 3) / (2*x). Starting from x0 = 5, what is x after 1 iteration? Give 4 decimal places.

Practice 3

Newton's method on f(x) = x² − 4 starts at x₀ = 0. What happens?

Practice 4

Which statement compares bisection and Newton fairly?

Practice 5

Newton's method on f(x) = x³ − 2x − 5 from x₀ = 2. What is x₁ (4 decimal places)?

8.Apply it

Write a hybrid solver: keep a bisection bracket, try a Newton step each iteration, and fall back to bisection whenever Newton would leave the bracket. Test it on x³ − 2x − 5 on [2, 3] and on arctan x on [−1, 2], and count steps compared with pure bisection.

9.Reflect

Concepts: Root finding and iterative methods · Derivatives and rates of change