5.4.25 · D1Scientific Computing (Python)

Foundations — Implementing root-finding from scratch — Newton-Raphson, bisection

3,156 words14 min readBack to topic

Before you can read a single line of the parent note, you need to own every symbol it throws at you. This page builds each one from absolute zero, in an order where each idea leans on the one before it. Nothing here assumes you've seen the notation.


1. What is a function ? What does mean? What is ?

Picture a curve drawn on graph paper. The horizontal axis carries the input ; the vertical axis carries the height . Every input picks out one height on the curve.

Figure s01 — "A function turns an input into one height." A cyan curve on blueprint grid. An amber input value on the horizontal axis is traced up with a dashed line to the curve, then across to its height on the vertical axis — showing the single input-to-output mapping, and the white line .

Figure — Implementing root-finding from scratch — Newton-Raphson, bisection

2. What is a root ? Reading the star

On the graph, a root is a point where the curve touches or crosses the horizontal axis — because the axis is exactly the line ("height ," from §1).

Figure s02 — "A root is where the curve meets the line ." A cyan curve crossing the white horizontal axis at two amber dots; each dot is labelled with , showing that a root is exactly a crossing point of the curve and the zero line.

Figure — Implementing root-finding from scratch — Newton-Raphson, bisection

3. Subscripts:


4. Continuity — the "no gaps, no jumps" property

Figure s05 — "Continuity vs a jump." Left: a smooth cyan curve drawn in one unbroken stroke (continuous — pen never lifts). Right: an amber curve that leaps from below the axis straight to above it — an open circle below and a filled circle above mark the jump, with an arrow noting "no crossing here," showing how a discontinuity lets the curve skip over without ever touching it.

Figure — Implementing root-finding from scratch — Newton-Raphson, bisection

5. The interval , its endpoints, and the product

Figure s03 — "Opposite signs bracket a root." A cyan straight-through curve on the grid; amber dots mark the left endpoint with (below the white axis) and the right endpoint with (above it). The shaded band between them and a white dot on the axis show the root is trapped inside whenever the endpoint heights have opposite signs.

Figure — Implementing root-finding from scratch — Newton-Raphson, bisection

6. The absolute value and the idea of "error"


7. What is a slope, and the derivative ?

Figure s04 — "The derivative is the slope of the tangent line." A cyan curve with an amber tangent line touching it at a point . A white right-triangle under the tangent labels its "rise" and "run," and an annotation reads — defining the derivative as the steepness of the curve at that point.

Figure — Implementing root-finding from scratch — Newton-Raphson, bisection

8. The fraction — putting it together


9. Logarithm base 2: , the ceiling , and the bisection step count


Prerequisite map

The diagram below shows how these foundations feed the topic: the plain function idea splits into two branches (sign-tracking → bisection, slope-tracking → Newton), and both feed the parent topic Root-Finding from Scratch.

Function f and output f of x

Height y and the line y = 0

Root x-star where f is zero

Continuity no jumps on all of a b

Sign of f at a point

Interval a b and product f of a times f of b

Intermediate Value Theorem

Bisection method

Slope and tangent line

Derivative f prime nonzero

Guesses x0 x1 xn xn plus 1

Newton-Raphson method

Absolute value and error en

Stopping test and tolerance

Log base 2 and ceiling and step count

Root-finding from scratch


Equipment checklist

Test yourself — cover the right side.

I can read aloud and say what it means
"f of x": feed input to machine , read the output height off the curve.
I know what and the line are
is the vertical coordinate (the height ); is the horizontal axis, all points at height zero.
I know what is
The exact true root — the input where ; the star just marks "the real answer," distinct from guesses.
I can decode the subscripts in and
Labels for "the current guess" and "the next guess"; a subscript is a name tag, not a power.
I can define a continuous function on
One you can draw across the entire closed interval without lifting the pen — no jumps or holes anywhere in it.
I know what and its endpoints are
The interval of inputs from left endpoint to right endpoint ; are the heights there.
I know what tells me — and its edge case
Opposite signs at the endpoints, so a continuous curve crosses zero inside; but if an endpoint is itself a root then , so use or check endpoints first.
I can state the Intermediate Value Theorem in words
If is continuous on all of and goes from below the axis to above it, it must pass through zero somewhere in between.
I know what and mean
is the size of the gap between guess and true root; is the "close enough" tolerance where we stop.
I can explain slope and the tangent line
Slope = rise over run; the tangent is the straight line that matches the curve's direction at a point.
I know what is and where it comes from
The derivative: another machine giving the curve's steepness (tangent slope) at ; e.g. for it is .
I know the precondition of the Newton step
The step is only valid when ; a flat tangent means divide-by-zero and no crossing.
I understand why appears in Newton
It's height divided by slope = the horizontal run along the tangent needed to reach the axis.
I can derive the bisection step count with the ceiling
Width halves to ; error gives (round up, since steps are whole numbers).