4.8.29Numerical Methods

Solving nonlinear systems — Newton's method in n dimensions

1,733 words8 min readdifficulty · medium

WHAT are we solving?

The scalar Newton method xk+1=xkf(xk)/f(xk)x_{k+1}=x_k - f(x_k)/f'(x_k) is the n=1n=1 case. The only conceptual upgrade: the derivative ff' becomes a matrix (the Jacobian), and "divide by ff'" becomes "solve a linear system."


HOW — derivation from first principles

Step 1 — Linearize. Take a current guess xk\mathbf{x}_k and write the first-order Taylor expansion of each component fif_i around xk\mathbf{x}_k: fi(xk+h)fi(xk)+j=1nfixj(xk)hj.f_i(\mathbf{x}_k + \mathbf{h}) \approx f_i(\mathbf{x}_k) + \sum_{j=1}^n \frac{\partial f_i}{\partial x_j}(\mathbf{x}_k)\, h_j . Why this step? Multivariable Taylor's theorem says a smooth function near a point equals its value plus its gradient dotted with the displacement, plus higher order. We truncate after the linear term — that's the approximation that makes the problem solvable.

Step 2 — Stack into matrix form. Collect all nn rows. The matrix of partials is the Jacobian: J(x)=(f1x1f1xnfnx1fnxn),Jij=fixj.J(\mathbf{x}) = \begin{pmatrix} \dfrac{\partial f_1}{\partial x_1} & \cdots & \dfrac{\partial f_1}{\partial x_n}\\ \vdots & \ddots & \vdots \\ \dfrac{\partial f_n}{\partial x_1} & \cdots & \dfrac{\partial f_n}{\partial x_n}\end{pmatrix}, \qquad J_{ij} = \frac{\partial f_i}{\partial x_j}. So F(xk+h)F(xk)+J(xk)h\mathbf{F}(\mathbf{x}_k+\mathbf{h}) \approx \mathbf{F}(\mathbf{x}_k) + J(\mathbf{x}_k)\,\mathbf{h}. Why this step? The Jacobian is the nn-D analogue of the derivative ff': it is the best linear map approximating F\mathbf{F} at xk\mathbf{x}_k.

Step 3 — Demand the linear model hits zero. We want F(xk+h)=0\mathbf{F}(\mathbf{x}_k+\mathbf{h})=\mathbf{0}. Set the approximation to zero: F(xk)+J(xk)h=0        J(xk)h=F(xk).\mathbf{F}(\mathbf{x}_k) + J(\mathbf{x}_k)\,\mathbf{h} = \mathbf{0} \;\;\Longrightarrow\;\; J(\mathbf{x}_k)\,\mathbf{h} = -\mathbf{F}(\mathbf{x}_k). Why this step? This is now a linear system Ah=bA\mathbf{h}=\mathbf{b} — exactly the kind we can solve with LU/Gaussian elimination.

Step 4 — Solve & update.


WHY it converges so fast

Reason: we kept the linear term and threw away the O(h2)O(\|\mathbf{h}\|^2) remainder. So the new error is governed by that leftover quadratic term: ek+1Cek2,\|\mathbf{e}_{k+1}\| \le C\,\|\mathbf{e}_k\|^2, provided (1) x0\mathbf{x}_0 is close enough to x\mathbf{x}^*, and (2) J(x)J(\mathbf{x}^*) is nonsingular (invertible). If JJ is singular at the root, convergence degrades — same way scalar Newton crawls at a double root where f=0f'=0.

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

Worked Example 1 — circle ∩ parabola (n=2n=2)

Solve f1=x2+y24=0,f2=yx2=0.f_1 = x^2+y^2-4=0, \qquad f_2 = y-x^2=0.

Jacobian. J=(2x2y2x1).J=\begin{pmatrix} 2x & 2y \\ -2x & 1\end{pmatrix}. Why this step? Differentiate each fif_i w.r.t. each variable; row ii is fi\nabla f_i.

Start x0=(1,2)\mathbf{x}_0=(1,2).

  • F=(1+44,  21)=(1,1)\mathbf{F}=(1+4-4,\;2-1)=(1,1). Why? Just plug in; tells us how far from zero we are.
  • J=(2421)J=\begin{pmatrix}2&4\\-2&1\end{pmatrix}, det=2+8=10\det=2+8=10.
  • Solve JΔx=F=(1,1)J\Delta\mathbf{x}=-\mathbf{F}=(-1,-1): Δx=110(1422)(11)=110(34)=(0.3,0.4).\Delta\mathbf{x}=\frac1{10}\begin{pmatrix}1&-4\\2&2\end{pmatrix}\begin{pmatrix}-1\\-1\end{pmatrix}=\frac1{10}\begin{pmatrix}3\\-4\end{pmatrix}=(0.3,-0.4). Why this step? For 2×22\times2, J1=1det(dbca)J^{-1}=\frac1{\det}\begin{pmatrix}d&-b\\-c&a\end{pmatrix}; multiply by F-\mathbf{F}.
  • x1=(1.3,1.6)\mathbf{x}_1=(1.3,\,1.6).

Next x1=(1.3,1.6)\mathbf{x}_1=(1.3,1.6): F=(1.69+2.564,  1.61.69)=(0.25,0.09)\mathbf{F}=(1.69+2.56-4,\;1.6-1.69)=(0.25,-0.09) — already much smaller. Iterating converges to x(1.2496,1.5616)\mathbf{x}^*\approx(1.2496,1.5616). Why it shrank: the linear model was accurate near the root.


Worked Example 2 — checking the linear case

Solve the linear system (1234)x=(56)\begin{pmatrix}1&2\\3&4\end{pmatrix}\mathbf{x}=\begin{pmatrix}5\\6\end{pmatrix}, i.e. F(x)=Axb\mathbf{F}(\mathbf{x})=A\mathbf{x}-\mathbf{b}.

  • J=AJ=A (constant!). Why? (Axb)/x=A\partial(A\mathbf{x}-\mathbf{b})/\partial\mathbf{x}=A.
  • From any x0\mathbf{x}_0: Δx=A1(Ax0b)=A1bx0\Delta\mathbf{x}=-A^{-1}(A\mathbf{x}_0-\mathbf{b})=A^{-1}\mathbf{b}-\mathbf{x}_0, so x1=A1b\mathbf{x}_1=A^{-1}\mathbf{b}exact in one step.
  • Why this matters: Newton solves linear systems in a single iteration. This is a sanity-check (Forecast-then-verify): if your code needs many steps on a linear F\mathbf{F}, your Jacobian is wrong.


Algorithm (pseudo)

given F, J, x0, tol
for k = 0,1,2,...
    compute F(xk), J(xk)
    solve  J(xk) Δx = -F(xk)        # LU, NOT inverse
    xk+1 = xk + Δx
    if ||F(xk+1)|| < tol and ||Δx|| < tol: stop

Recall Feynman: explain to a 12-year-old

Imagine you're blindfolded on a bumpy hill and want the lowest valley point where the ground is flat. You feel the slope under your feet (that's the Jacobian — slope in every direction at once). You pretend the hill is a flat ramp with that slope, slide straight to where that ramp would hit the bottom, and take one step there. The hill isn't really flat, so you're not exactly right — but you're much closer. Feel the slope again, slide again. Each guess is way better than the last, and soon you're standing right on the spot.


Flashcards

What replaces the scalar derivative ff' in nn-D Newton?
The Jacobian matrix Jij=fi/xjJ_{ij}=\partial f_i/\partial x_j.
Write the core Newton update for systems.
Solve J(xk)Δxk=F(xk)J(\mathbf{x}_k)\,\Delta\mathbf{x}_k=-\mathbf{F}(\mathbf{x}_k), then xk+1=xk+Δxk\mathbf{x}_{k+1}=\mathbf{x}_k+\Delta\mathbf{x}_k.
Why solve JΔx=FJ\Delta\mathbf{x}=-\mathbf{F} instead of using J1J^{-1}?
Solving (one LU + back-sub) is cheaper (3×\sim 3\times) and more numerically stable than forming the inverse.
What convergence rate does Newton have near a simple root?
Quadratic: ek+1Cek2\|\mathbf{e}_{k+1}\|\le C\|\mathbf{e}_k\|^2 — correct digits roughly double per step.
Two conditions for quadratic convergence?
(1) x0\mathbf{x}_0 close enough to root; (2) J(x)J(\mathbf{x}^*) nonsingular.
How many iterations does Newton need for a linear F(x)=Axb\mathbf{F}(\mathbf{x})=A\mathbf{x}-\mathbf{b}?
Exactly one (since J=AJ=A is constant and the model is exact).
What does the Taylor truncation you discard control?
The O(h2)O(\|\mathbf{h}\|^2) remainder — it becomes the next error, giving quadratic convergence.
A good stopping criterion uses what two quantities?
Small step Δx\|\Delta\mathbf{x}\| AND small residual F(xk)\|\mathbf{F}(\mathbf{x}_k)\|.
What is damped Newton and when do you need it?
xk+1=xk+tkΔxk\mathbf{x}_{k+1}=\mathbf{x}_k+t_k\Delta\mathbf{x}_k with tk1t_k\le1 chosen by line search; needed when full step diverges/overshoots.
What goes wrong if JJ is singular at the root?
Convergence is no longer quadratic (slows down), analogous to a multiple root in 1-D where f=0f'=0.

Connections

Concept Map

is

resolve by

truncate to

partials form

best linear map for

demand root

gives

solved by

yields step to

iterate

approaches

generalises to

replaces f prime in

Nonlinear system F x = 0

Hard to solve directly

First-order Taylor expansion

Jacobian matrix J

Local linear approximation

Set model to zero

Linear system J dx = -F

Solve via LU or Gaussian elimination

Update x_k+1 = x_k + dx

Repeat until convergence

Scalar Newton n=1 case

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, ek nonlinear system F(x)=0\mathbf{F}(\mathbf{x})=\mathbf{0} solve karna seedha mushkil hai kyunki equations curved hote hain. Newton ka idea simple hai: kisi bhi smooth function ko apne current guess ke paas dekho toh woh ek straight (linear) map jaisa lagta hai. Toh hum curve ko uske tangent se replace karte hain, aur tangent ko zero karna toh ek linear system solve karna hai — jo hume aata hai (LU/Gaussian elimination se).

1-D wale Newton mein humne ff' se divide kiya tha. nn-D mein ff' ki jagah Jacobian matrix JJ aa jaati hai (har fif_i ka har variable ke saath partial derivative). Step nikalne ke liye hum JΔx=FJ\,\Delta\mathbf{x}=-\mathbf{F} ko solve karte hain, phir xk+1=xk+Δx\mathbf{x}_{k+1}=\mathbf{x}_k+\Delta\mathbf{x}. Yaad rakhna: kabhi bhi J1J^{-1} literally mat banao — solve karna sasta aur stable hota hai.

Sabse mast baat: convergence quadratic hota hai, matlab har step mein sahi digits roughly double ho jaate hain — 10210410810^{-2}\to10^{-4}\to10^{-8}. Par yeh tabhi hota hai jab starting guess x0\mathbf{x}_0 root ke paas ho aur JJ singular na ho. Agar guess door hai ya JJ flat hai, Newton diverge ya cycle kar sakta hai — tab damped Newton (chhota step tkt_k with line search) lagao.

Exam tip / sanity check: agar F\mathbf{F} linear hai (yaani AxbA\mathbf{x}-\mathbf{b}), toh Newton sirf ek hi step mein exact answer de dega, kyunki J=AJ=A constant hai aur linear model bilkul exact hai. Agar tumhare code ko linear case mein bhi bahut iterations lag rahe hain, toh samajh jao Jacobian galat hai.

Go deeper — visual, from zero

Test yourself — Numerical Methods

Connections