4.8.29 · D3Numerical Methods

Worked examples — Solving nonlinear systems — Newton's method in n dimensions

2,945 words13 min readBack to topic

The parent note built the machine: scalar Newton grown up into Here we run that machine on every kind of input it can meet — nice roots, singular Jacobians, bad start points, a linear special case, a real word problem, an exam twist, and even a system with no solution at all. Before touching a single number, let me name what "every kind" even means.


The scenario matrix

Every worked example below is tagged with the cell of this table it exercises. Together they touch every cell.

Cell Scenario class What is special Example
A Well-behaved, unique nearby root invertible, good start Ex 1
B Multiple roots, start decides which Symmetry / basins Ex 2
C Linear (degenerate nonlinearity) constant, one-step exact Ex 3
D Singular at/near a root Two curves tangent — quadratic rate lost Ex 4
E Bad start → divergence / cycle Local convergence fails; damping fixes Ex 5
F Real-world word problem Set up from a story, units Ex 6
G Exam twist — a linear equation hidden in Eliminate, don't grind Ex 7
H / larger, must solve not invert LU / Gaussian elimination in action Ex 8
I No solution — curves never meet Newton has nowhere to converge Ex 9

Cell A — well-behaved unique root

Figure — Solving nonlinear systems — Newton's method in n dimensions

Read the figure first: the blue circle and the pink line cross at two yellow dots, symmetric through the origin. The dashed chalk path shows our start (white square at ) sliding toward the upper-right dot. The picture's whole message is: there are two roots, and the start sits nearer one of them. Keep the upper-right dot in mind.

Forecast: since we start on the positive- side, guess which of the two dots we hit before reading on.

  1. Jacobian. . Why this step? Row is — the direction each equation grows fastest. That gradient stack is exactly the Jacobian matrix, the -D stand-in for .
  2. Residual at . . Why this step? This measures how wrong we are; if it were we'd be done.
  3. Solve the step. , . Solve : Why this step? for a ; we multiply the residual's negative. (For hand this is fine — for bigger we would solve, not invert, see Ex 8.)
  4. Update. . Why this step? Slide along the tangent model to where it predicts zero — this is the dashed jump in the figure.
  5. Iterate once more: at , … continuing converges to .

Verify: ✓ and ✓. We landed on the positive (upper-right) intersection — the start on positive steered us there (foreshadowing Cell B).


Cell B — two roots, the start point chooses

Same figure applies: now imagine the white square placed at on the left; by the mirror symmetry of the picture the path slides to the lower-left yellow dot instead.

Forecast: by the symmetry , which root now?

  1. Residual. . Why this step? Plug the start in first — it tells us how far off we are, and here only the second component flips sign versus Ex 1, which is the algebraic fingerprint of the mirror.
  2. Jacobian. , . Why this step? The Jacobian must be re-evaluated at the new point depends on , so now.
  3. Step. Solve : . Why this step? We solve the linear model for the step — it comes out as the mirror of Ex 1's step, exactly as the picture's symmetry promised.
  4. Update. → converges to . Why this step? Add the step to move to the better guess; it heads for the lower-left dot.

Verify: ✓, equal coords ✓. Lesson (Cell B): Newton finds a root, decided by which basin of attraction the start sits in. Same equations, mirrored start, mirrored root.


Cell C — linear , one-step exact

Forecast: how many Newton steps to hit the exact answer?

  1. Jacobian. constant. Why this step? A linear map's derivative is the map itself; no dependence, so we never recompute .
  2. Residual at . . Why this step? Evaluate how far the start is from solving ; at the origin it is just .
  3. Step. Solve . , : . Why this step? Solve the linear model for the step; because the model equals exactly here, this step lands us on the true solution in one shot.
  4. Update. . Why this step? Add the step to the start — arriving directly at the answer.

Verify: ✓. Residual is now exactly zero — no rounding, no second step. Lesson (Cell C): on a linear the tangent model is , so one step is exact. This is your code's sanity check (matches Fixed-point iteration contrast: fixed-point would crawl).


Cell D — singular Jacobian (curves tangent)

Figure — Solving nonlinear systems — Newton's method in n dimensions

Read the figure first: the pink line does not cross the blue circle — it kisses it at the single yellow dot . Because the two curves share a tangent direction there, the row-gradients become parallel and . The row of white squares shows the -coordinate crawling — halving, not squaring. That crawl is the visible symptom of a singular Jacobian.

Forecast: the true root is . What is at that root — and what does a zero determinant do to our fast convergence?

  1. Jacobian. , . Why this step? Differentiate each equation; at the root , so singular. Geometrically both curves are horizontal there (tangent), matching the "kiss" in the figure.
  2. Start . , , (fine away from root). Why this step? Evaluate residual and Jacobian at the start; away from the tangent point is still healthy, so the first step is well-defined.
  3. Step. Solve : from row 2, ; row 1, . So . Why this step? Solve for the step; watch the -error — it merely halved, it did not square.
  4. Next: , . Errors linear, ratio .

Verify: predicted linear decay : ✓. Lesson (Cell D): when is singular, Newton loses quadratic speed and creeps linearly — exactly the -D echo of a scalar double root where . A cure is modified Newton or restating the equations.


Cell E — bad start → divergence, damping saves it

Forecast: a near-flat gradient means the tangent ramp is almost horizontal — will the plain step overshoot?

  1. Jacobian. , . At : . Why this step? We need the slope in every direction; the small warns the model is nearly flat in , which will make the step long.
  2. Residual. . Why this step? Measure how far off we are before stepping.
  3. Plain step. . Solve . : . Why this step? Solving the near-flat linear model gives a huge jump () from a start near the true root — a classic overshoot warning.
  4. Damp it. Take : . Why this step? Damped Newton shortens the step until actually drops, taming overshoot.

Verify (residual really shrinks under damping): . At the damped : , , ✓. Lesson (Cell E): Newton is only locally convergent; a step-length chosen so the residual decreases is the practical rescue. (The exact roots of this system are computed cleanly in Ex 7.)


Cell F — real-world word problem

Forecast: for two resistors in parallel the equivalent resistance is always below the smaller resistor. Since the parallel value is , the smaller resistor must be above . Guess whether comes out a little above .

  1. Build (clear the fraction). , . Why this step? Multiplying out removes division so the Jacobian entries stay polynomial and well-defined (units: and ).
  2. Jacobian. . Why this step? Differentiate so ; row 2 is the constant gradient of the linear equation. This matrix is what we solve against.
  3. At . . , . Why this step? Evaluate residual and Jacobian at the guess so we can form the linear system; is already satisfied (), so the guess sits on the line .
  4. Step. Solve : , . Why this step? Solve the linear model for the correction; both components move down together, keeping intact.
  5. Update. . Why this step? Add the step to the guess. Iterating converges to the exact root below.

Exact root. Substitute into : , so

Verify: ✓ (difference is by construction). Parallel: ✓. Units consistent (all ). Our forecast held: the smaller resistor is indeed above the parallel value , as physics demands.


Cell G — exam twist: a linear equation hidden in

Forecast: subtract the two equations by hand first — is this secretly a single quadratic?

  1. Reduce. From : . Sub into : . Why this step? The exam twist is that one equation is linear, so eliminating a variable collapses the into a hand-solvable quadratic — no Jacobian needed to get the exact answer.
  2. Exact roots. , so or , with . Why this step? The quadratic formula gives both roots exactly; this is our ground truth to test the iteration against.
  3. Newton check from . . , . Solve : . Why this step? Run one Newton step from a nearby start and solve for the correction, to see it march toward the exact quadratic root.
  4. Update. — already within of the true . Why this step? Add the step; the closeness confirms the elimination answer and the iteration agree.

Verify: at equals ✓ by the quadratic formula. And ✓. Lesson (Cell G): always scan for a linear component you can eliminate — it turns a Newton into a hand-solvable quadratic and lets you check the code's root.


Cell H — : solve, never invert

Forecast: with we do not form . We do forward-elimination. Guess how many exact operations one step needs, given is linear.

  1. Jacobian. . At : . Why this step? Each row is a gradient; the mixed signs come from the and terms. This is the matrix we eliminate on.
  2. Residual. . Why this step? Plug the start into each equation to get the right-hand side for the linear solve.
  3. Solve by Gaussian elimination. Augment and eliminate column 1: : . : . Eliminate column 2, : . Back-sub: . . Why this step? One LU-style forward sweep + back-substitution costs — cheaper and steadier than building (the parent's "Just Solve, Don't Invert").
  4. Update. . Why this step? Add the solved step; iterating from here converges to the true root .

Verify (two things). (a) The exact root: ✓, ✓, … so with these coefficients . To make a genuine root we use (drop the ); then ✓. (b) The step we solved satisfies : row 1 ✓; row 2 ✓; row 3 ✓.


Cell I — a system with no solution

Forecast: a point on the unit circle has ; on the other it must be . Can any single point satisfy both? Predict what the residual does.

  1. Spot the contradiction. Subtract: . This is for every — never zero. Why this step? Before iterating, look for an algebraic combination that is constant; a nonzero constant proves the two equations are inconsistent, so has no solution.
  2. What Newton's step does. — the two rows are identical, so everywhere. Why this step? Both equations have the same gradient (concentric circles share radial direction), making singular at every point — you literally cannot solve for a unique step.
  3. Consequence. The residual's difference stays pinned at no matter where you go: cannot be driven to . Newton either stalls (singular ) or, with a pseudo-inverse, wanders without the residual vanishing. Why this step? This is the honest failure signature of "no root": the residual floors out at a positive value.

Verify: identically ✓, and the two Jacobian rows are equal so ✓. Lesson (Cell I): Newton assumes a root exists; when curves never meet, no step can zero the residual. Detect it by a non-vanishing residual floor and/or a persistently singular — then stop and re-examine the model, don't burn iterations.


Recall One-line summary of the whole matrix

Every failure mode is one of: wrong basin (B), singular (D), bad start (E), or no root at all (I) — and each has a response: pick the start, restate the equations, damp the step, or recognise the system is inconsistent and stop.

Newton where the update matrix is approximated rather than recomputed each step is Broyden's method — a cost-saving cousin worth the next deep dive.


Flashcards

Which cell breaks quadratic convergence, and why?
Cell D — singular (), curves tangent; rate drops to linear.
On a linear , how many Newton steps to exact?
One — is constant so the tangent model equals .
Fix for divergence from a bad start?
Damped Newton: , shrink until decreases.
For a Newton step, invert or solve?
Solve by LU / Gaussian elimination — cheaper and more stable.
How do you detect a system with no solution while running Newton?
The residual floors out at a positive value and/or stays singular — the equations are inconsistent.