This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Notebooks · posts/newton-doubles-the-digits

Newton's method doubles the correct digits

Newton's method on , one cell at a time. From the error is after four steps and zero after five; bisection needs 39 halvings to promise as much. Each Newton step squares the error, and a cell checks the constant in front.

A notebook: the prose between the cells says what each one is for, and each cell's output appears under it. Press Run all, or run a cell with Shift+Enter.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 16–30

One step

The tangent to at has slope and passes through . It crosses zero at , which is what the cell above printed. Already is close to 2.

Before running the next cell, guess how many steps it takes to get every digit a double can hold, about 16.

[2]lines 43–72

Why the digits double

Write the error as . One step gives

so . Near the root , and the error is squared at every step and scaled by . An error of becomes , then : the number of correct digits doubles.

The cell below measures for the first four steps. Far from the root the ratio is with still far from ; by the fourth step it matches to four digits.

[3]lines 91–112

Against bisection

Bisection keeps an interval where changes sign and halves it. After halvings of the midpoint is within of the root, one binary digit per step, and that guarantee is all it has: it never fails, and it never speeds up. The figure plots of Newton's error beside of bisection's guarantee. Newton's curve bends down; bisection's is a straight line.

[4]lines 124–174