Replace the curve by its tangent line and jump to where the tangent crosses the axis. Near a simple root the number of correct digits doubles every step; far from it, anything can happen.
Md Mahbub E Noor · Assistant Professor CSE-3107 Numerical Methods · B.Sc. 3rd Year 1st Semester Department of CSE, University of Barishal
Why this lecture
The problem: divide without dividing
Division is the slowest arithmetic operation in hardware. Can a chip compute 1/7 using only multiplication and subtraction?
We want x=1/7: the root of f(x)=x1−7
Some rule xn+1=(something) that improves a guess using only × and −
Bisection would need 20 steps for 6 digits; fixed-point iteration needs the right g
Today's method gives the rule xn+1=xn(2−7xn), and the digits double every step
n
xn
correct digits
0
0.1
0
1
0.13
1
2
0.1417
2
3
0.14284777
5
4
0.14285714
10+
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
2 / 21
Today's goals
Derive the Newton–Raphson formula geometrically and from Taylor series
Carry out Newton's method by hand to a required accuracy (iteration tables)
We want the x where the curve crosses the axis.Start at a guess x₀ and go up to the curve.Slide down the tangent line until it hits the axis.That point is the new guess x₁. Go up to the curve again.Slide down the new tangent.x₂ = 1.619 is already close.Two steps: 3 → 2.106 → 1.619. The next gives 1.444, then 1.419. Very fast.
In plain words
Up close, a curve looks like its tangent line
A line is easy: find where the tangent crosses the axis
Use that as the new guess and repeat: very fast near the root
New words today
tangent
the line that just touches the curve at a point
derivative f′(x)
the slope of the tangent
Newton step
x − f(x)/f′(x)
quadratic convergence
correct digits double each step
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
4 / 21
Deriving the formula
Tangent line at x_ny=f(xn)+f′(xn)(x−xn)
Set y = 0xn+1=xn−f′(xn)f(xn)
Same thing from Taylor (Lecture 3)0=f(r)≈f(xn)+f′(xn)(r−xn)⇒r≈xn−f′(xn)f(xn)
Geometric: follow the tangent down to the axis
Analytic: keep the first two Taylor terms, solve the linear equation
Needs f′(x) and one starting value x0; no bracket
Fixed-point view: g(x)=x−f/f′ has g′(r)=f′(r)2f(r)f′′(r)=0
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
5 / 21
The method, step by step
The Newton–Raphson algorithm
Find f′(x); choose x0 near the root (from a sketch or a sign change)
Compute xn+1=xn−f′(xn)f(xn)
If f′(xn)=0 (flat tangent), stop and choose another x0
Repeat until ∣xn+1−xn∣<ε (the required digits stop changing)
Answer: the last xn+1; check that f(xn+1)≈0
Pseudocode
input f, df, x0, tol, N
x ← x0
repeat up to N times:
d ← df(x)
if d = 0: stop (flat tangent)
x_new ← x − f(x) / d
if |x_new − x| < tol:
return x_new
x ← x_new
stop: no convergence
One function value and one derivative value per step. No bracket, so nothing guarantees convergence: the cap N matters.
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
6 / 21
Explore: tangent after tangent
The dashed orange line is the tangent at xn
Its crossing gives xn+1
Look at the ∣xn+1−xn∣ column: 2×10−2, 4×10−4, 10−7, 10−14
Compare: bisection needed 14 steps for 10−4; Newton needs 3
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
7 / 21
Problem 1: f(x)=2x3−2x−5
Problem 1"Find out the root of the following equation using the Newton–Raphson method: f(x)=2x3−2x−5." Here f′(x)=6x2−2; f(1)=−5, f(2)=7, so start at x0=1.5.
n
xn
f(xn)
f′(xn)
xn+1=xn−f/f′
∣xn+1−xn∣
0
1.500000
−1.250000
11.500000
1.608696
0.108696
1
1.608696
0.108901
13.527410
1.600645
0.008050
2
1.600645
0.000625
13.372391
1.600599
0.000047
3
1.600599
0.000000
13.371494
1.600599
0.000000
Root ≈ 1.600599 (correct to 6 decimals after 3 iterations). Check: f(1.600599)=2(4.100667)−3.201198−5≈0.
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
8 / 21
Problem 2: 3x+sinx=ex to 5 decimal places
Problem 2"Use Newton–Raphson method to find a real root of the equation 3x+sinx=ex correct up to 5 decimal places."
1
f(x)=3x+sinx−ex, f′(x)=3+cosx−ex; f(0)=−1, f(1)=1.123189: root in (0,1); take x0=0
x=0.36042 (to 5 decimal places). Radians! A calculator in degree mode gives nonsense.
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
9 / 21
Classical vs numerical
Same problem, two approaches: x3−x−2=0
Algebra
Classical (exact formula)
Cardano (1545): x=31+26/27+31−26/27
=1.2559834+0.2653963=1.5213797
Needs square and cube roots (computed by Newton inside the calculator!), and 1−26/27=0.0187 is a cancellation that loses about 2 digits
vs
Algorithm
Numerical (Newton)
xn+1=xn−3xn2−1xn3−xn−2 from 1.5
3 iterations: 1.521739, 1.521380, 1.5213797
Same answer, simpler, and the same code works for any cubic
When the classical approach cannot work
The quintic x5−x−1=0
Abel–Ruffini theorem (1824): there is no formula in radicals for general degree-5 equations, and this one is a standard example. Newton from x0=1: x=1.167304 in 5 iterations.
Even where a formula exists, numerical methods are often simpler and more accurate; beyond degree 4 they are the only general option.
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
10 / 21
Why so fast? Quadratic convergence
Error relation (from Taylor about x_n)en+1≈2f′(r)f′′(r)en2,en=xn−r
Errors are squared each step: 10−2→10−4→10−8→10−16
Correct digits roughly double each step
Measured ratio 0.768 matches theory 2(3r2−1)6r=0.768 ✓
Only near a simple root (f′(r)=0); far away, no promise
n
xn for x3−x−2
∣en∣
∣en+1∣/en2
0
1.5
2.1e−2
0.786
1
1.521739130
3.6e−4
0.768
2
1.521379806
9.9e−8
0.768
3
1.521379707
7.6e−15
—
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
11 / 21
Newton inside your computer
Square root
f(x)=x2−N
Exactly the Babylonian method of Lecture 1. 10 from x0=3: 3.166667, 3.162281, 3.162278.
xn+1=xn−2xnxn2−N=21(xn+xnN)
Division without dividing
f(x)=x1−N
Only multiplications! CPUs and GPUs compute 1/N like this. 1/7 from x0=0.1: 0.13, 0.1417, 0.142848, 0.14285714.
xn+1=xn(2−Nxn)
Cube root
f(x)=x3−N
317 from x0=2.5: 2.573333, 2.571283, 2.571282.
xn+1=31(2xn+xn2N)
Graphics
Fast inverse square root
The famous Quake III code computes 1/x with a bit-trick guess followed by one Newton step y(1.5−0.5xy2).
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
12 / 21
Newton–Raphson in Python and C
Supply both f and f′
Stops when ∣xn+1−xn∣<tol
Guards: f′(x)=0 check and an iteration cap
Try x0=0.6 (near the minimum of f) and see the big first jump
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
13 / 21
Practice
Practice problem
Problem 3"Newton–Raphson's method can fail to converge, or converge to an unintended root, for certain functions or starting points. Describe two distinct scenarios in which this happens, each with a brief illustrative example. Then explain how the Secant method removes the requirement of an analytical derivative and identify one drawback it introduces in exchange."
How to write a complete answer
Scenario 1, stationary point: f(x)=x2−1, x0=0: f′(0)=0, the tangent never meets the axis
Multiple roots, unless you use x−mf/f′ with known multiplicity m
Rule of thumb: bracket first, then Newton. Safety from bisection, speed from the tangent.
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
16 / 21
Comparison
Comparative analysis: x3−x−2=0 (root 1.521380)
Method
Start
Iterations for 10−6
Evaluations
Order
Guaranteed?
Bisection
[1,2]
20
≈ 22 of f
1 (rate ½)
yes
False position
[1,2]
12
≈ 14 of f
1
yes
Fixed point, g=(x+2)1/3
1.5
7
7 of g
1 (rate 0.14)
if ∣g′∣<1
Newton
1.5
3
3 of f + 3 of f′
2
no
Newton from a poor start
0.6
13
13 + 13
2 (eventually)
no
Kepler's equation, e=0.9: fixed point 11 iterations, Newton 6. Newton wins on iterations, but each iteration costs two evaluations, and it needs a good start.
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
17 / 21
Roadmap
Limitations, and where we fix them
Newton is the fastest classical method near a simple root. Its weaknesses are exactly the topics that follow:
What it does well (keep this)
Quadratic convergence: digits double
One starting value, no bracket
Systematic: no guessing a g
Generalises to systems and to optimisation
LimitationHow it is overcomeWhere
Needs the derivative f′
→
Replace the tangent by a secant through two recent points
Click a card to see the exact Newton step inside each system.
🖥️ Division in hardware
Where exactly: floating-point division units in many processors and GPUs. A small table gives a first guess for 1/b; then Newton steps on f(x)=1/x−b refine it using only multiplications.
xn+1=xn(2−bxn)
n
0
1
2
3
4
xn for b=7
0.1
0.13
0.1417
0.14284777
0.14285714
The error squares each step: 2 or 3 steps from a table look-up give full single precision. Then a/b = a × (1/b).
🎮 Fast inverse square root
Where exactly: normalising vectors for lighting: 1/x for millions of vectors per frame. A bit-level trick gives a rough guess y0; one Newton step on f(y)=1/y2−x makes it accurate.
y1=y0(1.5−0.5xy02)
Example x=2, rough guess y0=0.7
y1=0.7(1.5−0.5⋅2⋅0.49)=0.707
True value 1/2=0.7071068: one step took the error from 1% to 0.015%
No division and no square root: only multiplications. Modern CPUs have a hardware rsqrt estimate followed by exactly this Newton step.
🛰️ Kepler's equation, Newton style
Where exactly: orbit computation (GPS, satellite tracking): solve f(E)=E−esinE−M=0 with f′(E)=1−ecosE.
eccentricity e
0.1
0.5
0.9
fixed point (L8)
5
6
11
Newton
3
4
6
Iterations to 10⁻⁶ from E₀ = M = 1. Newton's advantage grows as the orbit becomes more elliptical.
📊 Logistic regression (IRLS)
Where exactly: statistics packages and scikit-learn's newton-cg solver. To maximise the log-likelihood, apply Newton to its gradient: each step solves a weighted least-squares problem (iteratively reweighted least squares).
wk+1=wk−H−1∇ℓ(wk),H=XTSX,;S=diag(pi(1−pi))
Typically converges in under 10 iterations, where gradient descent may need thousands. The cost is solving a linear system with H each step (Lectures 11–13), and the idea is developed in Lecture 25.
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
19 / 21
Checkpoint
Checkpoint · think, then discuss with your neighbourNewton's method for f(x)=x2−5 starting from x0=2. What is x1?
A2.5
B2.25
C2.2361
D1.75
B. x1=2−44−5=2+0.25=2.25. Next: x2=2.236111, x3=2.236068=5.
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
20 / 21
Summary
Key points
xn+1=xn−f(xn)/f′(xn): the tangent's crossing; from first-order Taylor
Quadratic convergence near a simple root: en+1≈2f′f′′en2, digits double
Square root, reciprocal and cube root algorithms are Newton's method
Failures: f′≈0, cycles, divergence from poor x0; only linear at multiple roots
In practice: bracket first, then Newton, with safeguards
Opening problem: solved
Newton on f(x)=1/x−7 gives xn+1=xn−−1/xn21/xn−7=xn(2−7xn): only multiplication. From 0.1: 0.13, 0.1417, 0.14284777, 0.14285714.
Homework
Find the root of xlog10x=1.2 by Newton's method starting at x0=2.5, to 5 decimal places.
Derive the Newton iteration for 3N and compute 317 from x0=2.5.
Find the positive root of cosx=xex by Newton's method, 4 decimal places.
Lab: find a starting value for x3−2x+2 that leads to the cycle, and one that converges. Explain using the graph.
Next lecture
Secant method and nonlinear systems. Newton without derivatives, a comparison of all five methods, and Newton for several equations at once.
Md Mahbub E Noor
Lecture 9: Newton–Raphson Method
University of Barishal
21 / 21
Keys →Space next step · ← back A reveal the whole slide number + Enter jump to slide S slide list · F full screen · N notes [] previous / next lecture · L lab In a code box: Ctrl+Enter runs the code