4.1.33Calculus I — Limits & Derivatives

Newton-Raphson method for root finding

1,697 words8 min readdifficulty · medium3 backlinks

What is the method?

WHAT each piece means

  • f(xn)f(x_n): how far above/below zero we currently are.
  • f(xn)f'(x_n): the slope of the tangent at the current guess.
  • f(xn)/f(xn)f(x_n)/f'(x_n): the horizontal distance the tangent travels to reach the axis.

Deriving it from scratch (tangent-line argument)

Alternative derivation (Taylor series — shows why it's so fast)

Expand ff near xnx_n and demand f(root)=0f(\text{root})=0: 0=f(xn)+f(xn)(rxn)+12f(ξ)(rxn)20 = f(x_n) + f'(x_n)(r - x_n) + \tfrac{1}{2}f''(\xi)(r-x_n)^2 Dropping the quadratic term and solving for rr gives the same formula. The discarded term is O((rxn)2)O((r-x_n)^2) — this is the seed of quadratic convergence: the error roughly squares each step.


Figure — Newton-Raphson method for root finding

Worked Example 1 — compute 2\sqrt{2}

Solve f(x)=x22=0f(x)=x^2-2=0, so f(x)=2xf'(x)=2x. Iteration: xn+1=xnxn222xn=xn2+1xnx_{n+1} = x_n - \frac{x_n^2-2}{2x_n} = \frac{x_n}{2} + \frac{1}{x_n} Why this step? Simplifying gives the classic "average your guess with 2/x2/x" formula.

Start x0=1x_0 = 1:

  • x1=12+1=1.5x_1 = \tfrac{1}{2}+1 = 1.5Why? plug x0=1x_0=1 in.
  • x2=0.75+0.6667=1.41667x_2 = 0.75 + 0.6667 = 1.41667Why? feed x1x_1 back in.
  • x3=1.41421568...x_3 = 1.41421568...Why? one more pass; now correct to 6 digits.

True 2=1.41421356...\sqrt2 = 1.41421356... — compare x2=1.41667x_2=1.41667 (3 correct digits: 1,4,11,4,1) to x3=1.41421568x_3=1.41421568 (6 correct digits: 1,4,1,4,2,11,4,1,4,2,1). The number of correct digits roughly doubled in one step (3→6), the signature of quadratic convergence.

Worked Example 2 — a transcendental root

Solve f(x)=cosxx=0f(x)=\cos x - x = 0, f(x)=sinx1f'(x) = -\sin x - 1. xn+1=xncosxnxnsinxn1x_{n+1} = x_n - \frac{\cos x_n - x_n}{-\sin x_n - 1} Start x0=1x_0 = 1 (radians):

  • f(1)=0.54031=0.4597f(1)=0.5403-1=-0.4597, f(1)=0.84151=1.8415f'(1)=-0.8415-1=-1.8415. Why? evaluate both at the guess.
  • x1=10.45971.8415=10.2497=0.7503x_1 = 1 - \frac{-0.4597}{-1.8415} = 1 - 0.2497 = 0.7503.
  • x20.73911x_2 \approx 0.73911, x30.73909x_3 \approx 0.73909 — converged to the Dottie number.

Worked Example 3 — when it MISBEHAVES

Solve f(x)=x32x+2=0f(x)=x^3 - 2x + 2 = 0 with x0=0x_0 = 0. f(x)=3x22f'(x)=3x^2-2, so f(0)=2f'(0)=-2.

  • x1=022=1x_1 = 0 - \frac{2}{-2} = 1.
  • f(1)=1f(1)=1, f(1)=1f'(1)=1, x2=11=0x_2 = 1 - 1 = 0.
  • Back to 00! The iteration cycles 0100\to1\to0\to\cdots forever. Why this matters: Newton-Raphson is local, not guaranteed global.


Recall Feynman: explain to a 12-year-old

Imagine the curve is a dark hill and you can only feel the slope right under your feet. You can't see where the ground hits sea level. So you pretend the hill keeps going perfectly straight (the slope you feel) and you walk to where that straight line touches sea level. You're not there yet, but you're closer. You feel the slope again, draw a new straight line, walk again. After a few walks you're standing almost exactly on the spot — and each walk cuts your remaining distance enormously, not just a little.



Flashcards

What is the Newton-Raphson update formula?
xn+1=xnf(xn)f(xn)x_{n+1} = x_n - \dfrac{f(x_n)}{f'(x_n)}
From what geometric object is the formula derived?
The tangent line at (xn,f(xn))(x_n, f(x_n)), finding where it crosses the xx-axis.
Why subtract f/ff/f' rather than add?
You move against the current error: the term f/ff/f' is the horizontal jump the tangent takes to reach zero.
What rate of convergence does NR have at a simple root?
Quadratic — the error roughly squares each step (number of correct digits doubles).
What condition can make NR blow up or oscillate?
f(xn)0f'(x_n) \approx 0 (near-horizontal tangent) or a poor starting guess; it can cycle or diverge.
At a double root, what happens to convergence?
It degrades from quadratic to linear.
Newton-Raphson iteration for a\sqrt a via f(x)=x2af(x)=x^2-a?
xn+1=12(xn+axn)x_{n+1} = \tfrac{1}{2}\left(x_n + \tfrac{a}{x_n}\right)
What stopping criterion is typically used?
xn+1xn<ε|x_{n+1}-x_n| < \varepsilon or f(xn)<ε|f(x_n)| < \varepsilon.
Where does the quadratic-convergence guarantee come from?
The dropped Taylor term is O((error)2)O((\text{error})^2), so the next error is proportional to the square of the current error.

Connections

  • Tangent line and linear approximation — NR is repeated linearization.
  • Taylor series — explains quadratic convergence.
  • Derivatives — definition and rules — supplies ff'.
  • Fixed-point iteration — NR is a special, fast fixed-point scheme g(x)=xf/fg(x)=x-f/f'.
  • Bisection method — slower but guaranteed; often combined with NR (safeguarded Newton).
  • Roots of polynomials — common application domain.

Concept Map

motivates

formalised as

set y=0

solve for xn+1

needs

alt derivation gives

dropped O of square term

digits double each step

iterate until

yields

applied in

applied in

Solve f x = 0 algebra fails

Tangent line approximates curve locally

Point-slope tangent at xn

Iteration xn+1 = xn - f/f'

Deriv f' xn slope

Set tangent y = 0

Taylor expansion near xn

Quadratic convergence

Stop when below tolerance

Converges to root

sqrt 2 via x^2-2

cos x - x transcendental

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, Newton-Raphson ka idea bahut simple hai. Tumhe f(x)=0f(x)=0 solve karna hai par algebra se nahi ho raha. Toh trick yeh hai: kisi bhi smooth curve ko zoom karke dekho toh woh apni tangent line jaisi dikhti hai. Straight line ka root nikalna trivial hai — bas dekho woh xx-axis ko kahan kaatti hai. Wahi tumhara next guess ban jaata hai. Phir wahan se nayi tangent, naya jump. Har baar tum root ke kaafi paas aate jaate ho.

Formula hai xn+1=xnf(xn)/f(xn)x_{n+1} = x_n - f(x_n)/f'(x_n). Yaad rakhne ka mantra: "New = Old minus Height-over-Slope". f(xn)f(x_n) tumhari current height hai (kitne upar/neeche ho zero se), f(xn)f'(x_n) slope hai. Minus sign zaroori hai — tum overshoot ko subtract karte ho, add nahi. Sign galat kiya toh root ke door bhaag jaoge.

Sabse mast baat: yeh method quadratic convergence deta hai (simple root par). Matlab correct digits har step mein roughly double ho jaate hain. 2\sqrt2 wale example mein dekha — x2=1.41667x_2=1.41667 mein 3 correct digit, phir x3=1.41421568x_3=1.41421568 mein 6 correct digit (3 se 6, double!). Bohot fast! Taylor series se yeh samajh aata hai: jo error term hum drop karte hain woh error ka square hota hai, isliye agla error chhota chhota square hota jaata hai.

Par savdhaan: yeh local method hai. Agar starting guess kharaab hai, ya f(xn)f'(x_n) zero ke paas hai (flat tangent), toh iteration cycle kar sakti hai ya udd sakti hai — humne x32x+2x^3-2x+2 wale example mein dekha jahan 0100\to1\to0 loop ban gaya. Aur double root par speed quadratic se sirf linear ho jaati hai. Toh good initial guess do, ff' ko check karo, aur tab Newton-Raphson tumhara sabse fast dost hai.

Go deeper — visual, from zero

Test yourself — Calculus I — Limits & Derivatives

Connections