Practice / Initialisation and optimisers

Newton's method and second-order optimisation

Ten problems on Newton's method: the step as the minimiser of the quadratic model and the Newton decrement, the square root of 2 by hand, the proof of quadratic convergence with the error recurrence made exact, a one-dimensional minimisation with the digits doubling, affine invariance against gradient descent, why Newton finds critical points rather than minima and when its step points uphill, the Gauss–Newton approximation for least squares, Levenberg–Marquardt damping as an interpolation between Newton and gradient descent, the secant step as the first quasi-Newton update, and a two-cycle that shows convergence is only local, with worked solutions and the mistakes that iterate on f instead of f', treat Gauss–Newton as exact, take the Newton direction as a descent direction, assume convergence from any start, or expect rescaling the loss to rescale the step.

Before you start

Gradient descent uses the slope; Newton's method also uses the curvature, and the difference is the difference between a rate of convergence that depends on how stretched the loss is and one that does not. The method is simple to state, minimise the quadratic model and jump to its minimum, and everything interesting is in what the model gets wrong: far from the solution the model is poor, at a saddle its minimum is a maximum, and for a least-squares loss half of its Hessian is usually not worth computing. These ten problems derive the step and the decrement, compute 2\sqrt2 and a one-dimensional minimiser by hand and watch the correct digits double, prove quadratic convergence and make the error recurrence exact for a square root, show that the step is unchanged by a change of coordinates while gradient descent's is not, follow the method to a maximum, derive Gauss–Newton and the damping that turns it into Levenberg–Marquardt, take a secant step as the first quasi-Newton update, and end with a cubic on which undamped Newton cycles forever. The five mistakes at the end are the ones that produce an iteration that still runs: Newton on ff when the target is f′=0f' = 0, Gauss–Newton called exact, an uphill Newton direction fed to a line search, local convergence read as global, and a step that was expected to shrink with the loss.

  • ff is a twice-differentiable function of x∈Rnx \in \mathbb{R}^n (or of a scalar xx), with gradient ∇f\nabla f and Hessian H=∇2fH = \nabla^2f; a minimiser is x∗x^* and the error at step kk is ek=xk−x∗e_k = x_k - x^*. The quadratic model of ff at xx is mx(δ)=f(x)+∇f(x)⊤δ+12δ⊤H(x) δm_x(\delta) = f(x) + \nabla f(x)^\top\delta + \tfrac12\delta^\top H(x)\,\delta, the second-order Taylor polynomial (the Taylor-series page).
  • Newton's method for minimisation steps to the minimiser of the model: xk+1=xk+δkx_{k+1} = x_k + \delta_k with H(xk) δk=−∇f(xk)H(x_k)\,\delta_k = -\nabla f(x_k). For a scalar function this is xk+1=xk−f′(xk)/f′′(xk)x_{k+1} = x_k - f'(x_k)/f''(x_k). The Newton decrement is λ(x)2=∇f(x)⊤H(x)−1∇f(x)\lambda(x)^2 = \nabla f(x)^\top H(x)^{-1}\nabla f(x).
  • Newton's method for a root of g(x)=0g(x) = 0 is xk+1=xk−g(xk)/g′(xk)x_{k+1} = x_k - g(x_k)/g'(x_k); minimisation is root-finding on g=f′g = f', since g′=f′′g' = f''. ξ\xi denotes a point between xkx_k and x∗x^* supplied by Taylor's theorem.
  • Gradient descent is xk+1=xk−η∇f(xk)x_{k+1} = x_k - \eta\nabla f(x_k) with step size η>0\eta > 0. A symmetric matrix AA is positive definite (PD, A≻0A \succ 0) if v⊤Av>0v^\top Av > 0 for all v≠0v \neq 0 (the positive-definite page); its eigenvalues are λi\lambda_i with λmin⁡\lambda_{\min} and λmax⁡\lambda_{\max} the extremes. A direction dd is a descent direction at xx if ∇f(x)⊤d<0\nabla f(x)^\top d < 0.
  • For least squares, r(θ)∈RNr(\theta) \in \mathbb{R}^N is the residual vector with Jacobian J=∂r/∂θ∈RN×pJ = \partial r/\partial\theta \in \mathbb{R}^{N\times p} (numerator layout, the Jacobians page), and f(θ)=12∥r(θ)∥2f(\theta) = \tfrac12\|r(\theta)\|^2. ∇2rn\nabla^2r_n is the p×pp\times p Hessian of the nn-th residual.

Builds on: Partial derivatives, gradients and Hessians, Taylor series and linear approximation

Problems

  1. ·

    Show that the minimiser of the quadratic model mx(δ)m_x(\delta) when H(x)≻0H(x) \succ 0 is δ∗=−H(x)−1∇f(x)\delta^* = -H(x)^{-1}\nabla f(x), and that the model predicts the decrease f(x)−mx(δ∗)=12∇f(x)⊤H(x)−1∇f(x)=12λ(x)2f(x) - m_x(\delta^*) = \tfrac12\nabla f(x)^\top H(x)^{-1}\nabla f(x) = \tfrac12\lambda(x)^2. Why is H≻0H \succ 0 needed?

  2. ·

    Derive the root-finding iteration xk+1=xk−g(xk)/g′(xk)x_{k+1} = x_k - g(x_k)/g'(x_k) as the zero of the tangent line, and apply it to g(x)=x2−2g(x) = x^2 - 2 from x0=1x_0 = 1. Simplify the iteration, compute x1,x2,x3x_1, x_2, x_3 exactly and the errors xk−2x_k - \sqrt2 to two significant figures.

  3. ···

    Let x∗x^* be a root of gg with g′(x∗)≠0g'(x^*) \neq 0 and g′′g'' continuous. Show that ek+1=g′′(ξk)2g′(xk) ek2e_{k+1} = \dfrac{g''(\xi_k)}{2g'(x_k)}\,e_k^2 for some ξk\xi_k between xkx_k and x∗x^*, so that convergence is quadratic once it starts: ∣ek+1∣≤C∣ek∣2\lvert e_{k+1}\rvert \le C\lvert e_k\rvert^2 near x∗x^*. For g(x)=x2−ag(x) = x^2 - a, show the exact recurrence ek+1=ek2/(2xk)e_{k+1} = e_k^2/(2x_k) and check it against Problem 2.

  4. ··

    Minimise f(x)=ex−2xf(x) = e^x - 2x by Newton's method from x0=0x_0 = 0. Write the iteration, compute x1,x2,x3x_1, x_2, x_3 to four decimals and the errors xk−x∗x_k - x^* for k=1,…,4k = 1, \dots, 4, and verify that ek+1/ek2e_{k+1}/e_k^2 approaches the constant of Problem 3.

  5. ··

    Let y=Bx+cy = Bx + c with BB invertible, and define h(y)=f(x)h(y) = f(x), that is h(y)=f(B−1(y−c))h(y) = f\big(B^{-1}(y - c)\big). Show that ∇h(y)=B−⊤∇f(x)\nabla h(y) = B^{-\top}\nabla f(x) and ∇2h(y)=B−⊤∇2f(x)B−1\nabla^2h(y) = B^{-\top}\nabla^2f(x)B^{-1}, and that the Newton step in yy is BB times the Newton step in xx, so the iterates correspond: yk=Bxk+cy_k = Bx_k + c for all kk. Show that gradient descent does not have this property unless BB is orthogonal.

  6. ··

    Apply Newton's method to f(x)=x3−3xf(x) = x^3 - 3x from x0=−12x_0 = -\tfrac12: compute x1x_1 and x2x_2 and say where the iteration converges and what kind of point that is. Then, for f(x,y)=x2−y2f(x, y) = x^2 - y^2 at (1,2)(1, 2), compute the Newton step and show that it is not a descent direction.

  7. ···

    For f(θ)=12∥r(θ)∥2f(\theta) = \tfrac12\|r(\theta)\|^2 with r:Rp→RNr : \mathbb{R}^p \to \mathbb{R}^N and Jacobian JJ, show that ∇f=J⊤r\nabla f = J^\top r and ∇2f=J⊤J+∑n=1Nrn∇2rn\nabla^2f = J^\top J + \sum_{n=1}^N r_n\nabla^2r_n. The Gauss–Newton step drops the second term: δGN=−(J⊤J)−1J⊤r\delta_{\mathrm{GN}} = -(J^\top J)^{-1}J^\top r. Show that δGN\delta_{\mathrm{GN}} is the least-squares solution of the linearised problem min⁡δ∥r+Jδ∥2\min_\delta\|r + J\delta\|^2, and that for a linear residual r(θ)=Aθ−br(\theta) = A\theta - b Gauss–Newton equals Newton and reaches the solution in one step.

  8. ··

    The damped step is δμ=−(H+μI)−1∇f\delta_\mu = -(H + \mu I)^{-1}\nabla f for μ≥0\mu \ge 0 with H⪰0H \succeq 0. Show that (a) δμ→δNewton\delta_\mu \to \delta_{\mathrm{Newton}} as μ→0\mu \to 0 when H≻0H \succ 0, and δμ≈−1μ∇f\delta_\mu \approx -\tfrac1\mu\nabla f as μ→∞\mu \to \infty; (b) δμ\delta_\mu is a descent direction for every μ>0\mu > 0; (c) ∥δμ∥\|\delta_\mu\| is decreasing in μ\mu; (d) δμ\delta_\mu minimises mx(δ)+μ2∥δ∥2m_x(\delta) + \tfrac\mu2\|\delta\|^2.

  9. ··

    The secant method replaces g′(xk)g'(x_k) in Newton's iteration by the slope Bk=g(xk)−g(xk−1)xk−xk−1B_k = \dfrac{g(x_k) - g(x_{k-1})}{x_k - x_{k-1}}. Starting from x0=1x_0 = 1, x1=32x_1 = \tfrac32 for g(x)=x2−2g(x) = x^2 - 2, compute x2x_2 and x3x_3 and their errors. Show that BkB_k is the unique scalar satisfying the secant equation Bk(xk−xk−1)=g(xk)−g(xk−1)B_k(x_k - x_{k-1}) = g(x_k) - g(x_{k-1}), and that for g=f′g = f' this is the one-dimensional case of the quasi-Newton condition Bksk=ykB_ks_k = y_k with sk=xk−xk−1s_k = x_k - x_{k-1} and yk=∇f(xk)−∇f(xk−1)y_k = \nabla f(x_k) - \nabla f(x_{k-1}).

  10. ···

    Apply Newton's method to g(x)=x3−2x+2g(x) = x^3 - 2x + 2 from x0=0x_0 = 0 and from x0=−2x_0 = -2. Compute the first iterates in each case, say what happens, and explain the two outcomes in terms of Problem 3.

Worked solutions

Problem 1

Show that the minimiser of the quadratic model mx(δ)m_x(\delta) when H(x)≻0H(x) \succ 0 is δ∗=−H(x)−1∇f(x)\delta^* = -H(x)^{-1}\nabla f(x), and that the model predicts the decrease f(x)−mx(δ∗)=12∇f(x)⊤H(x)−1∇f(x)=12λ(x)2f(x) - m_x(\delta^*) = \tfrac12\nabla f(x)^\top H(x)^{-1}\nabla f(x) = \tfrac12\lambda(x)^2. Why is H≻0H \succ 0 needed?

  1. ∇δmx(δ)=∇f(x)+H(x) δ\nabla_\delta m_x(\delta) = \nabla f(x) + H(x)\,\delta.∇δ(g⊤δ)=g\nabla_\delta(g^\top\delta) = g and ∇δ(12δ⊤Hδ)=Hδ\nabla_\delta(\tfrac12\delta^\top H\delta) = H\delta for symmetric HH (the matrix-calculus page).
  2. ∇δmx=0  ⟺  Hδ=−∇f(x)  ⟺  δ∗=−H−1∇f(x)\nabla_\delta m_x = 0 \iff H\delta = -\nabla f(x) \iff \delta^* = -H^{-1}\nabla f(x).H≻0H \succ 0 is invertible (the positive-definite page's Problem 2).
  3. ∇δ2mx=H≻0\nabla_\delta^2m_x = H \succ 0, so δ∗\delta^* is the unique minimiser of mxm_x.A quadratic with PD Hessian has one critical point and it is the global minimum (the positive-definite page's Problem 6).
  4. mx(δ∗)=f(x)−∇f⊤H−1∇f+12∇f⊤H−1HH−1∇f=f(x)−12∇f⊤H−1∇fm_x(\delta^*) = f(x) - \nabla f^\top H^{-1}\nabla f + \tfrac12\nabla f^\top H^{-1}HH^{-1}\nabla f = f(x) - \tfrac12\nabla f^\top H^{-1}\nabla f.Substitute δ∗=−H−1∇f\delta^* = -H^{-1}\nabla f into the model; H−1HH−1=H−1H^{-1}HH^{-1} = H^{-1}.
  5. δ∗=−H(x)−1∇f(x)\delta^* = -H(x)^{-1}\nabla f(x) and f(x)−mx(δ∗)=12∇f(x)⊤H(x)−1∇f(x)=12λ(x)2f(x) - m_x(\delta^*) = \tfrac12\nabla f(x)^\top H(x)^{-1}\nabla f(x) = \tfrac12\lambda(x)^2The Newton step is the jump to the bottom of the local bowl; the decrement λ(x)2\lambda(x)^2 is how deep the bowl says the bottom is, and 12λ2\tfrac12\lambda^2 is the usual stopping test, since it is affine-invariant (Problem 5) where ∥∇f∥\|\nabla f\| is not. Without H≻0H \succ 0 step 2 still finds the critical point of the model, but step 3 fails: an indefinite HH makes that critical point a saddle of the model and the step may go uphill (Problem 6), and a singular HH leaves it undefined. The check compares δ∗\delta^* against a direct minimisation of the model and the decrease against the model's values.

Problem 2

Derive the root-finding iteration xk+1=xk−g(xk)/g′(xk)x_{k+1} = x_k - g(x_k)/g'(x_k) as the zero of the tangent line, and apply it to g(x)=x2−2g(x) = x^2 - 2 from x0=1x_0 = 1. Simplify the iteration, compute x1,x2,x3x_1, x_2, x_3 exactly and the errors xk−2x_k - \sqrt2 to two significant figures.

  1. The tangent line at xkx_k is ℓ(x)=g(xk)+g′(xk)(x−xk)\ell(x) = g(x_k) + g'(x_k)(x - x_k).The linear approximation of gg at xkx_k (the Taylor-series page).
  2. ℓ(x)=0  ⟺  x=xk−g(xk)/g′(xk)\ell(x) = 0 \iff x = x_k - g(x_k)/g'(x_k).Solve the linear equation; g′(xk)≠0g'(x_k) \neq 0 is needed.
  3. For g(x)=x2−2g(x) = x^2 - 2: xk+1=xk−xk2−22xk=2xk2−xk2+22xk=12(xk+2xk)x_{k+1} = x_k - \dfrac{x_k^2 - 2}{2x_k} = \dfrac{2x_k^2 - x_k^2 + 2}{2x_k} = \dfrac12\Big(x_k + \dfrac2{x_k}\Big).Put over the common denominator 2xk2x_k and split the fraction.
  4. x1=12(1+2)=32x_1 = \tfrac12(1 + 2) = \tfrac32, x2=12(32+43)=1712x_2 = \tfrac12\big(\tfrac32 + \tfrac43\big) = \tfrac{17}{12}, x3=12(1712+2417)=577408x_3 = \tfrac12\big(\tfrac{17}{12} + \tfrac{24}{17}\big) = \tfrac{577}{408}.23/2=43\tfrac{2}{3/2} = \tfrac43; 9+86=176\tfrac{9 + 8}{6} = \tfrac{17}6; 217/12=2417\tfrac{2}{17/12} = \tfrac{24}{17} and 1712+2417=289+288204=577204\tfrac{17}{12} + \tfrac{24}{17} = \tfrac{289 + 288}{204} = \tfrac{577}{204}.
  5. x1−2≈8.6×10−2x_1 - \sqrt2 \approx 8.6\times10^{-2}, x2−2≈2.5×10−3x_2 - \sqrt2 \approx 2.5\times10^{-3}, x3−2≈2.1×10−6x_3 - \sqrt2 \approx 2.1\times10^{-6}.2=1.41421356…\sqrt2 = 1.41421356\ldots against 1.51.5, 1.416‾1.41\overline{6} and 1.41421569…1.41421569\ldots.
  6. xk+1=12(xk+2/xk)x_{k+1} = \tfrac12\big(x_k + 2/x_k\big); x1=32x_1 = \tfrac32, x2=1712x_2 = \tfrac{17}{12}, x3=577408x_3 = \tfrac{577}{408}, with errors 8.6×10−28.6\times10^{-2}, 2.5×10−32.5\times10^{-3}, 2.1×10−62.1\times10^{-6}The number of correct digits roughly doubles each step: 11, 33, 66, and x4=665857470832x_4 = \tfrac{665857}{470832} is right to 1212 digits. This is the Babylonian method, Newton's method before Newton, and the averaging form of step 3 explains it: xkx_k and 2/xk2/x_k sit on opposite sides of 2\sqrt2, and their mean is much closer than either. Problem 3 proves the doubling and makes the error recurrence exact for this gg.

Problem 3

Let x∗x^* be a root of gg with g′(x∗)≠0g'(x^*) \neq 0 and g′′g'' continuous. Show that ek+1=g′′(ξk)2g′(xk) ek2e_{k+1} = \dfrac{g''(\xi_k)}{2g'(x_k)}\,e_k^2 for some ξk\xi_k between xkx_k and x∗x^*, so that convergence is quadratic once it starts: ∣ek+1∣≤C∣ek∣2\lvert e_{k+1}\rvert \le C\lvert e_k\rvert^2 near x∗x^*. For g(x)=x2−ag(x) = x^2 - a, show the exact recurrence ek+1=ek2/(2xk)e_{k+1} = e_k^2/(2x_k) and check it against Problem 2.

  1. 0=g(x∗)=g(xk)+g′(xk)(x∗−xk)+12g′′(ξk)(x∗−xk)20 = g(x^*) = g(x_k) + g'(x_k)(x^* - x_k) + \tfrac12g''(\xi_k)(x^* - x_k)^2.Taylor's theorem for gg about xkx_k, evaluated at x∗x^*, with the Lagrange remainder; x∗−xk=−ekx^* - x_k = -e_k.
  2. g(xk)=g′(xk) ek−12g′′(ξk) ek2g(x_k) = g'(x_k)\,e_k - \tfrac12g''(\xi_k)\,e_k^2.Rearrange step 1, using (x∗−xk)=−ek(x^* - x_k) = -e_k and (x∗−xk)2=ek2(x^* - x_k)^2 = e_k^2.
  3. ek+1=xk+1−x∗=ek−g(xk)g′(xk)=ek−ek+g′′(ξk)2g′(xk)ek2=g′′(ξk)2g′(xk)ek2e_{k+1} = x_{k+1} - x^* = e_k - \dfrac{g(x_k)}{g'(x_k)} = e_k - e_k + \dfrac{g''(\xi_k)}{2g'(x_k)}e_k^2 = \dfrac{g''(\xi_k)}{2g'(x_k)}e_k^2.Subtract x∗x^* from the Newton update and substitute step 2 for g(xk)g(x_k); the linear terms cancel exactly.
  4. Near x∗x^*, g′(xk)→g′(x∗)≠0g'(x_k) \to g'(x^*) \neq 0 and g′′(ξk)→g′′(x∗)g''(\xi_k) \to g''(x^*), so ∣ek+1∣≤C∣ek∣2\lvert e_{k+1}\rvert \le C\lvert e_k\rvert^2 with C≈∣g′′(x∗)∣2∣g′(x∗)∣C \approx \dfrac{\lvert g''(x^*)\rvert}{2\lvert g'(x^*)\rvert}.Continuity bounds the ratio once xkx_k is close; the error is squared each step, and if C∣ek∣<1C\lvert e_k\rvert < 1 the sequence C∣ek∣C\lvert e_k\rvert is squared each step too, which is the doubling of correct digits.
  5. For g(x)=x2−ag(x) = x^2 - a: xk+1−a=12(xk+axk)−a=xk2−2a xk+a2xk=(xk−a)22xkx_{k+1} - \sqrt a = \dfrac12\Big(x_k + \dfrac a{x_k}\Big) - \sqrt a = \dfrac{x_k^2 - 2\sqrt a\,x_k + a}{2x_k} = \dfrac{(x_k - \sqrt a)^2}{2x_k}.Common denominator, then recognise the perfect square. Here g′′=2g'' = 2 is constant, so step 3's ξk\xi_k drops out and the recurrence is exact.
  6. Problem 2: e2=e12/(2x1)=(0.0858)2/3=2.45×10−3e_2 = e_1^2/(2x_1) = (0.0858)^2/3 = 2.45\times10^{-3} and e3=e22/(2x2)=(2.453×10−3)2/2.83‾=2.12×10−6e_3 = e_2^2/(2x_2) = (2.453\times10^{-3})^2/2.8\overline{3} = 2.12\times10^{-6}.Step 5 with x1=32x_1 = \tfrac32 and x2=1712x_2 = \tfrac{17}{12}; both match Problem 2 to the digits shown.
  7. ek+1=g′′(ξk)2g′(xk)ek2e_{k+1} = \dfrac{g''(\xi_k)}{2g'(x_k)}e_k^2, quadratic convergence with C≈∣g′′(x∗)∣2∣g′(x∗)∣C \approx \dfrac{\lvert g''(x^*)\rvert}{2\lvert g'(x^*)\rvert}; for x2−ax^2 - a, exactly ek+1=ek22xke_{k+1} = \dfrac{e_k^2}{2x_k}, which reproduces Problem 2's errorsThe proof is one line of Taylor: Newton solves the linear part of gg exactly, so what remains is the quadratic remainder. Three things in it are conditions, not decorations: g′(x∗)≠0g'(x^*) \neq 0 (at a double root the convergence drops to linear with ratio 12\tfrac12), xkx_k close enough that C∣ek∣<1C\lvert e_k\rvert < 1 (Problem 10 shows what happens otherwise), and g′′g'' bounded. For minimisation, g=f′g = f' and the condition is f′′(x∗)≠0f''(x^*) \neq 0, a non-degenerate minimum.

Problem 4

Minimise f(x)=ex−2xf(x) = e^x - 2x by Newton's method from x0=0x_0 = 0. Write the iteration, compute x1,x2,x3x_1, x_2, x_3 to four decimals and the errors xk−x∗x_k - x^* for k=1,…,4k = 1, \dots, 4, and verify that ek+1/ek2e_{k+1}/e_k^2 approaches the constant of Problem 3.

  1. f′(x)=ex−2f'(x) = e^x - 2 and f′′(x)=exf''(x) = e^x; f′=0f' = 0 at x∗=log⁡2≈0.6931x^* = \log 2 \approx 0.6931, where f′′=2>0f'' = 2 > 0, a minimum.Differentiate; ex=2e^x = 2 has the unique solution log⁡2\log 2, and a positive second derivative there makes it a strict minimum.
  2. xk+1=xk−exk−2exk=xk−1+2e−xkx_{k+1} = x_k - \dfrac{e^{x_k} - 2}{e^{x_k}} = x_k - 1 + 2e^{-x_k}.Newton on g=f′g = f' with g′=f′′g' = f''; divide each term of the numerator by exke^{x_k}.
  3. x1=0−1+2=1x_1 = 0 - 1 + 2 = 1; x2=1−1+2e−1≈0.7358x_2 = 1 - 1 + 2e^{-1} \approx 0.7358; x3≈0.7358−1+2e−0.7358≈0.6940x_3 \approx 0.7358 - 1 + 2e^{-0.7358} \approx 0.6940.e−1≈0.36788e^{-1} \approx 0.36788 and e−0.7358≈0.47914e^{-0.7358} \approx 0.47914.
  4. e1≈0.3069e_1 \approx 0.3069, e2≈0.04261e_2 \approx 0.04261, e3≈8.95×10−4e_3 \approx 8.95\times10^{-4}, e4≈4.0×10−7e_4 \approx 4.0\times10^{-7}.Subtract log⁡2=0.693147…\log 2 = 0.693147\ldots; x4=x3−1+2e−x3≈0.6931476x_4 = x_3 - 1 + 2e^{-x_3} \approx 0.6931476.
  5. e2/e12≈0.452e_2/e_1^2 \approx 0.452, e3/e22≈0.493e_3/e_2^2 \approx 0.493, e4/e32≈0.500e_4/e_3^2 \approx 0.500, and Problem 3's constant is g′′(x∗)2g′(x∗)=ex∗2ex∗=12\dfrac{g''(x^*)}{2g'(x^*)} = \dfrac{e^{x^*}}{2e^{x^*}} = \dfrac12.g=ex−2g = e^x - 2 has g′=g′′=exg' = g'' = e^x; the ratios approach 12\tfrac12 from below as xk→x∗x_k \to x^*.
  6. xk+1=xk−1+2e−xkx_{k+1} = x_k - 1 + 2e^{-x_k}; x1=1x_1 = 1, x2≈0.7358x_2 \approx 0.7358, x3≈0.6940x_3 \approx 0.6940; errors 0.310.31, 0.0430.043, 9.0×10−49.0\times10^{-4}, 4.0×10−74.0\times10^{-7}, with ek+1/ek2→12e_{k+1}/e_k^2 \to \tfrac12Correct digits: 00, 11, 33, 66, then 1313 at x5x_5. Each Newton step is a gradient step with the step size η=1/f′′(xk)\eta = 1/f''(x_k) chosen by the curvature: 11 at x0x_0, 1/e1/e at x1x_1, and 12\tfrac12 near the solution, which is why no learning rate appears. A fixed η=12\eta = \tfrac12 would converge only linearly, with ratio ∣1−12f′′(xk)∣\lvert 1 - \tfrac12f''(x_k)\rvert, and η=1\eta = 1 would overshoot: f′′f'' varies by a factor of ee over the first step. Mistake 1 applies this iteration to ff instead of f′f'.

Problem 5

Let y=Bx+cy = Bx + c with BB invertible, and define h(y)=f(x)h(y) = f(x), that is h(y)=f(B−1(y−c))h(y) = f\big(B^{-1}(y - c)\big). Show that ∇h(y)=B−⊤∇f(x)\nabla h(y) = B^{-\top}\nabla f(x) and ∇2h(y)=B−⊤∇2f(x)B−1\nabla^2h(y) = B^{-\top}\nabla^2f(x)B^{-1}, and that the Newton step in yy is BB times the Newton step in xx, so the iterates correspond: yk=Bxk+cy_k = Bx_k + c for all kk. Show that gradient descent does not have this property unless BB is orthogonal.

  1. x=B−1(y−c)x = B^{-1}(y - c) has Jacobian ∂x/∂y=B−1\partial x/\partial y = B^{-1}, so ∇h(y)=(B−1)⊤∇f(x)=B−⊤∇f(x)\nabla h(y) = (B^{-1})^\top\nabla f(x) = B^{-\top}\nabla f(x).Chain rule for a scalar through a linear map: the gradient picks up the transpose of the Jacobian (the Jacobians page).
  2. ∇2h(y)=B−⊤∇2f(x)B−1\nabla^2h(y) = B^{-\top}\nabla^2f(x)B^{-1}.Differentiate step 1 again in yy: ∇f(x)\nabla f(x) changes by ∇2f(x) ∂x/∂y=∇2f(x)B−1\nabla^2f(x)\,\partial x/\partial y = \nabla^2f(x)B^{-1}, with the constant B−⊤B^{-\top} in front.
  3. Newton in yy: δy=−(B−⊤HB−1)−1B−⊤∇f=−BH−1B⊤B−⊤∇f=−BH−1∇f=B δx\delta_y = -\big(B^{-\top}HB^{-1}\big)^{-1}B^{-\top}\nabla f = -BH^{-1}B^\top B^{-\top}\nabla f = -BH^{-1}\nabla f = B\,\delta_x.(B−⊤HB−1)−1=BH−1B⊤(B^{-\top}HB^{-1})^{-1} = BH^{-1}B^\top, the inverse of a product in reverse order; B⊤B−⊤=IB^\top B^{-\top} = I.
  4. If yk=Bxk+cy_k = Bx_k + c then yk+1=yk+δy=Bxk+c+Bδx=B(xk+δx)+c=Bxk+1+cy_{k+1} = y_k + \delta_y = Bx_k + c + B\delta_x = B(x_k + \delta_x) + c = Bx_{k+1} + c.Induction on kk with step 3; it starts because y0=Bx0+cy_0 = Bx_0 + c by choice.
  5. Gradient descent in yy: yk+1=yk−ηB−⊤∇fy_{k+1} = y_k - \eta B^{-\top}\nabla f, while the image of the xx-step is B(xk−η∇f)+c=yk−ηB∇fB(x_k - \eta\nabla f) + c = y_k - \eta B\nabla f. These agree for every ∇f\nabla f only when B−⊤=BB^{-\top} = B, that is B⊤B=IB^\top B = I.Compare the two updates term by term; equality for all gradient vectors forces the matrices to be equal.
  6. ∇h=B−⊤∇f\nabla h = B^{-\top}\nabla f, ∇2h=B−⊤∇2fB−1\nabla^2h = B^{-\top}\nabla^2fB^{-1}, δy=Bδx\delta_y = B\delta_x, so yk=Bxk+cy_k = Bx_k + c throughout; gradient descent is invariant only under orthogonal BBNewton's method does not care how the problem is parameterised: rescale a feature by 10001000, change units, rotate the axes, and it takes the same path, because the Hessian's change undoes the gradient's. Gradient descent sees the scaling as a change in conditioning (the positive-definite page's Problem 9), which is why feature normalisation, batch norm and Adam's per-coordinate scaling matter for first-order methods and are irrelevant to Newton. The decrement λ2=∇f⊤H−1∇f\lambda^2 = \nabla f^\top H^{-1}\nabla f is invariant for the same reason, so it is the right stopping criterion. Mistake 5 is the special case B=cIB = cI.

Problem 6

Apply Newton's method to f(x)=x3−3xf(x) = x^3 - 3x from x0=−12x_0 = -\tfrac12: compute x1x_1 and x2x_2 and say where the iteration converges and what kind of point that is. Then, for f(x,y)=x2−y2f(x, y) = x^2 - y^2 at (1,2)(1, 2), compute the Newton step and show that it is not a descent direction.

  1. f′(x)=3x2−3f'(x) = 3x^2 - 3 and f′′(x)=6xf''(x) = 6x; the critical points are x=±1x = \pm1, with f′′(1)=6>0f''(1) = 6 > 0 (minimum) and f′′(−1)=−6<0f''(-1) = -6 < 0 (maximum).Differentiate; 3x2−3=03x^2 - 3 = 0 at x=±1x = \pm1; the sign of f′′f'' classifies them.
  2. x1=−12−3⋅14−36⋅(−12)=−12−−2.25−3=−12−0.75=−1.25x_1 = -\tfrac12 - \dfrac{3\cdot\tfrac14 - 3}{6\cdot(-\tfrac12)} = -\tfrac12 - \dfrac{-2.25}{-3} = -\tfrac12 - 0.75 = -1.25.Newton on f′f'; both numerator and denominator are negative, so the step is to the left, away from the minimum at +1+1.
  3. x2=−1.25−3⋅1.5625−3−7.5=−1.25+1.68757.5=−1.25+0.225=−1.025x_2 = -1.25 - \dfrac{3\cdot 1.5625 - 3}{-7.5} = -1.25 + \dfrac{1.6875}{7.5} = -1.25 + 0.225 = -1.025.The same iteration; the errors from −1-1 are 0.250.25 and then 0.0250.025, already shrinking quadratically.
  4. The iteration converges to x=−1x = -1, the local maximum.Newton solves f′=0f' = 0 and converges to whichever critical point it starts near; with f′′(x0)<0f''(x_0) < 0 the quadratic model is an upside-down parabola and its "minimiser" is a maximiser.
  5. For f(x,y)=x2−y2f(x, y) = x^2 - y^2: ∇f=(2x,−2y)⊤=(2,−4)⊤\nabla f = (2x, -2y)^\top = (2, -4)^\top and H=diag⁡(2,−2)H = \operatorname{diag}(2, -2), so δ=−H−1∇f=−(1,2)⊤=(−1,−2)⊤\delta = -H^{-1}\nabla f = -(1, 2)^\top = (-1, -2)^\top.Partial derivatives; HH is constant and indefinite, and H−1=diag⁡(12,−12)H^{-1} = \operatorname{diag}(\tfrac12, -\tfrac12).
  6. ∇f⊤δ=2⋅(−1)+(−4)⋅(−2)=−2+8=6>0\nabla f^\top\delta = 2\cdot(-1) + (-4)\cdot(-2) = -2 + 8 = 6 > 0.A positive directional derivative: ff increases along δ\delta, so δ\delta is an ascent direction. The step lands on (0,0)(0, 0), the saddle, where f′=0f' = 0.
  7. From x0=−12x_0 = -\tfrac12: x1=−1.25x_1 = -1.25, x2=−1.025x_2 = -1.025, converging to the local maximum x=−1x = -1; for x2−y2x^2 - y^2 at (1,2)(1, 2) the Newton step (−1,−2)⊤(-1, -2)^\top has ∇f⊤δ=6>0\nabla f^\top\delta = 6 > 0, an ascent direction, and lands on the saddleNewton's method finds critical points; which kind depends on the sign of the curvature it sees, and a loss with saddles, which every neural network has, hands it a step that may go up. The test is ∇f⊤δ=−∇f⊤H−1∇f\nabla f^\top\delta = -\nabla f^\top H^{-1}\nabla f, which is negative for every nonzero gradient exactly when H≻0H \succ 0. The fixes all modify HH: add μI\mu I with μ>−λmin⁡\mu > -\lambda_{\min} (Problem 8), flip the negative eigenvalues (saddle-free Newton), or use Gauss–Newton, whose J⊤JJ^\top J is PSD by construction (Problem 7). Mistake 3 hands the uphill direction to a line search.

Problem 7

For f(θ)=12∥r(θ)∥2f(\theta) = \tfrac12\|r(\theta)\|^2 with r:Rp→RNr : \mathbb{R}^p \to \mathbb{R}^N and Jacobian JJ, show that ∇f=J⊤r\nabla f = J^\top r and ∇2f=J⊤J+∑n=1Nrn∇2rn\nabla^2f = J^\top J + \sum_{n=1}^N r_n\nabla^2r_n. The Gauss–Newton step drops the second term: δGN=−(J⊤J)−1J⊤r\delta_{\mathrm{GN}} = -(J^\top J)^{-1}J^\top r. Show that δGN\delta_{\mathrm{GN}} is the least-squares solution of the linearised problem min⁡δ∥r+Jδ∥2\min_\delta\|r + J\delta\|^2, and that for a linear residual r(θ)=Aθ−br(\theta) = A\theta - b Gauss–Newton equals Newton and reaches the solution in one step.

  1. f=12∑nrn2f = \tfrac12\sum_nr_n^2, so ∂f∂θj=∑nrn∂rn∂θj=(J⊤r)j\dfrac{\partial f}{\partial\theta_j} = \sum_nr_n\dfrac{\partial r_n}{\partial\theta_j} = (J^\top r)_j.Chain rule on each square; Jnj=∂rn/∂θjJ_{nj} = \partial r_n/\partial\theta_j, so the sum over nn is the jj-th entry of J⊤rJ^\top r.
  2. ∂2f∂θi∂θj=∑n∂rn∂θi∂rn∂θj+∑nrn∂2rn∂θi∂θj=(J⊤J)ij+(∑nrn∇2rn)ij\dfrac{\partial^2f}{\partial\theta_i\partial\theta_j} = \sum_n\dfrac{\partial r_n}{\partial\theta_i}\dfrac{\partial r_n}{\partial\theta_j} + \sum_nr_n\dfrac{\partial^2r_n}{\partial\theta_i\partial\theta_j} = (J^\top J)_{ij} + \Big(\sum_nr_n\nabla^2r_n\Big)_{ij}.Product rule on rn ∂rn/∂θjr_n\,\partial r_n/\partial\theta_j: differentiate the first factor to get the Jacobian product, the second to get the residual times its Hessian.
  3. ∥r+Jδ∥2\|r + J\delta\|^2 is a quadratic in δ\delta with gradient 2J⊤(r+Jδ)2J^\top(r + J\delta), zero when J⊤Jδ=−J⊤rJ^\top J\delta = -J^\top r.The least-squares page's normal equations with design matrix JJ and target −r-r; J⊤J≻0J^\top J \succ 0 when JJ has full column rank.
  4. δGN=−(J⊤J)−1J⊤r\delta_{\mathrm{GN}} = -(J^\top J)^{-1}J^\top r is that solution.Step 3 solved for δ\delta; it is the Newton step for the model in which rr is replaced by its linearisation r+Jδr + J\delta.
  5. For r=Aθ−br = A\theta - b: J=AJ = A and ∇2rn=0\nabla^2r_n = 0, so ∇2f=A⊤A=J⊤J\nabla^2f = A^\top A = J^\top J and δGN=δNewton=−(A⊤A)−1A⊤(Aθ−b)=(A⊤A)−1A⊤b−θ\delta_{\mathrm{GN}} = \delta_{\mathrm{Newton}} = -(A^\top A)^{-1}A^\top(A\theta - b) = (A^\top A)^{-1}A^\top b - \theta.The dropped term is exactly zero for a linear residual; expand the product.
  6. θ+δGN=(A⊤A)−1A⊤b\theta + \delta_{\mathrm{GN}} = (A^\top A)^{-1}A^\top b, the least-squares solution, from any θ\theta.The θ\theta cancels; one step lands on the minimiser because the model is exact.
  7. ∇f=J⊤r\nabla f = J^\top r; ∇2f=J⊤J+∑nrn∇2rn\nabla^2f = J^\top J + \sum_nr_n\nabla^2r_n; δGN=−(J⊤J)−1J⊤r\delta_{\mathrm{GN}} = -(J^\top J)^{-1}J^\top r solves min⁡δ∥r+Jδ∥2\min_\delta\|r + J\delta\|^2; for r=Aθ−br = A\theta - b it is the Newton step and reaches (A⊤A)−1A⊤b(A^\top A)^{-1}A^\top b in one stepGauss–Newton keeps the half of the Hessian that is cheap (first derivatives only) and always PSD, and drops the half that needs second derivatives of every residual and can be indefinite. The dropped term is small when the residuals are small at the solution (a good fit) or the model is nearly linear, and then Gauss–Newton converges almost as fast as Newton; with large residuals it converges only linearly or not at all (Mistake 2). In practice the step is computed by solving Jδ≈−rJ\delta \approx -r by QR or the SVD rather than forming J⊤JJ^\top J, whose condition number is the square of JJ's. This is the iteration behind nonlinear least squares, bundle adjustment and the natural-gradient methods that use a Gauss–Newton matrix in place of the Hessian.

Problem 8

The damped step is δμ=−(H+μI)−1∇f\delta_\mu = -(H + \mu I)^{-1}\nabla f for μ≥0\mu \ge 0 with H⪰0H \succeq 0. Show that (a) δμ→δNewton\delta_\mu \to \delta_{\mathrm{Newton}} as μ→0\mu \to 0 when H≻0H \succ 0, and δμ≈−1μ∇f\delta_\mu \approx -\tfrac1\mu\nabla f as μ→∞\mu \to \infty; (b) δμ\delta_\mu is a descent direction for every μ>0\mu > 0; (c) ∥δμ∥\|\delta_\mu\| is decreasing in μ\mu; (d) δμ\delta_\mu minimises mx(δ)+μ2∥δ∥2m_x(\delta) + \tfrac\mu2\|\delta\|^2.

  1. (a) As μ→0\mu \to 0, (H+μI)−1→H−1(H + \mu I)^{-1} \to H^{-1} when HH is invertible; as μ→∞\mu \to \infty, (H+μI)−1=1μ(I+H/μ)−1→1μI(H + \mu I)^{-1} = \tfrac1\mu(I + H/\mu)^{-1} \to \tfrac1\mu I.Matrix inversion is continuous at an invertible matrix; factor μ\mu out and note H/μ→0H/\mu \to 0.
  2. (b) ∇f⊤δμ=−∇f⊤(H+μI)−1∇f<0\nabla f^\top\delta_\mu = -\nabla f^\top(H + \mu I)^{-1}\nabla f < 0 for ∇f≠0\nabla f \neq 0.H+μI≻0H + \mu I \succ 0 for μ>0\mu > 0 since its eigenvalues are λi+μ>0\lambda_i + \mu > 0, and the inverse of a PD matrix is PD (the positive-definite page's Problem 2).
  3. (c) With H=QΛQ⊤H = Q\Lambda Q^\top and g=Q⊤∇fg = Q^\top\nabla f: ∥δμ∥2=∑igi2(λi+μ)2\|\delta_\mu\|^2 = \sum_i\dfrac{g_i^2}{(\lambda_i + \mu)^2}, and each term decreases as μ\mu grows.(H+μI)−1=Q(Λ+μI)−1Q⊤(H + \mu I)^{-1} = Q(\Lambda + \mu I)^{-1}Q^\top and QQ preserves norms; the denominators increase with μ\mu.
  4. (d) ∇δ(mx(δ)+μ2∥δ∥2)=∇f+Hδ+μδ=0  ⟺  (H+μI)δ=−∇f\nabla_\delta\big(m_x(\delta) + \tfrac\mu2\|\delta\|^2\big) = \nabla f + H\delta + \mu\delta = 0 \iff (H + \mu I)\delta = -\nabla f.Problem 1's gradient plus ∇δ(μ2δ⊤δ)=μδ\nabla_\delta(\tfrac\mu2\delta^\top\delta) = \mu\delta; the Hessian H+μI≻0H + \mu I \succ 0 makes the critical point the minimum.
  5. δμ→δNewton\delta_\mu \to \delta_{\mathrm{Newton}} as μ→0\mu \to 0 and δμ≈−1μ∇f\delta_\mu \approx -\tfrac1\mu\nabla f as μ→∞\mu \to \infty; ∇f⊤δμ<0\nabla f^\top\delta_\mu < 0 for all μ>0\mu > 0; ∥δμ∥\|\delta_\mu\| decreases in μ\mu; δμ=arg⁡min⁡δ(mx(δ)+μ2∥δ∥2)\delta_\mu = \arg\min_\delta\big(m_x(\delta) + \tfrac\mu2\|\delta\|^2\big)Damping interpolates between Newton (trust the model, long step) and gradient descent with step 1/μ1/\mu (distrust it, short step along the gradient), and by (d) it is the model's minimiser under a penalty on the step length, the Lagrangian form of a trust region. Levenberg–Marquardt applies this to Gauss–Newton, (J⊤J+μI)δ=−J⊤r(J^\top J + \mu I)\delta = -J^\top r, raising μ\mu after a step that increases ff and lowering it after one that decreases ff; because J⊤J⪰0J^\top J \succeq 0, (b) guarantees every step is downhill. For an indefinite HH the same algebra works once μ>−λmin⁡\mu > -\lambda_{\min}, which is the standard repair for Problem 6's uphill step. Note that H+μIH + \mu I is not (1+μ)H(1 + \mu)H: damping turns the step towards the gradient, it does not just shorten it, and (c) is the only sense in which it is a shrinkage.

Problem 9

The secant method replaces g′(xk)g'(x_k) in Newton's iteration by the slope Bk=g(xk)−g(xk−1)xk−xk−1B_k = \dfrac{g(x_k) - g(x_{k-1})}{x_k - x_{k-1}}. Starting from x0=1x_0 = 1, x1=32x_1 = \tfrac32 for g(x)=x2−2g(x) = x^2 - 2, compute x2x_2 and x3x_3 and their errors. Show that BkB_k is the unique scalar satisfying the secant equation Bk(xk−xk−1)=g(xk)−g(xk−1)B_k(x_k - x_{k-1}) = g(x_k) - g(x_{k-1}), and that for g=f′g = f' this is the one-dimensional case of the quasi-Newton condition Bksk=ykB_ks_k = y_k with sk=xk−xk−1s_k = x_k - x_{k-1} and yk=∇f(xk)−∇f(xk−1)y_k = \nabla f(x_k) - \nabla f(x_{k-1}).

  1. g(x0)=−1g(x_0) = -1, g(x1)=14g(x_1) = \tfrac14, B1=14−(−1)32−1=5/41/2=52B_1 = \dfrac{\tfrac14 - (-1)}{\tfrac32 - 1} = \dfrac{5/4}{1/2} = \tfrac52, so x2=x1−g(x1)B1=32−1/45/2=32−110=1.4x_2 = x_1 - \dfrac{g(x_1)}{B_1} = \tfrac32 - \dfrac{1/4}{5/2} = \tfrac32 - \tfrac1{10} = 1.4.The slope of the chord through the two most recent points replaces the tangent slope 2x1=32x_1 = 3.
  2. g(x2)=1.96−2=−0.04g(x_2) = 1.96 - 2 = -0.04, B2=−0.04−0.251.4−1.5=−0.29−0.1=2.9B_2 = \dfrac{-0.04 - 0.25}{1.4 - 1.5} = \dfrac{-0.29}{-0.1} = 2.9, so x3=1.4−−0.042.9≈1.41379x_3 = 1.4 - \dfrac{-0.04}{2.9} \approx 1.41379.The same step with the points x1,x2x_1, x_2.
  3. Errors: x2−2≈−1.4×10−2x_2 - \sqrt2 \approx -1.4\times10^{-2}, x3−2≈−4.2×10−4x_3 - \sqrt2 \approx -4.2\times10^{-4}, and the next is x4−2≈2.1×10−6x_4 - \sqrt2 \approx 2.1\times10^{-6}.Subtract 1.41421356…1.41421356\ldots; the signs alternate because the chord's slope lags the tangent's.
  4. Bk(xk−xk−1)=g(xk)−g(xk−1)B_k(x_k - x_{k-1}) = g(x_k) - g(x_{k-1}) has the unique solution Bk=g(xk)−g(xk−1)xk−xk−1B_k = \dfrac{g(x_k) - g(x_{k-1})}{x_k - x_{k-1}} when xk≠xk−1x_k \neq x_{k-1}.A linear equation in one unknown with nonzero coefficient.
  5. With g=f′g = f' this reads Bk sk=ykB_k\,s_k = y_k where sk=xk−xk−1s_k = x_k - x_{k-1} and yk=f′(xk)−f′(xk−1)y_k = f'(x_k) - f'(x_{k-1}): the curvature estimate is the change in gradient per unit change in position.Rename; in one dimension the gradient is f′f' and the Hessian is the scalar f′′f'', which BkB_k approximates by a difference quotient.
  6. x2=1.4x_2 = 1.4, x3≈1.41379x_3 \approx 1.41379 with errors −1.4×10−2-1.4\times10^{-2} and −4.2×10−4-4.2\times10^{-4}; Bk=g(xk)−g(xk−1)xk−xk−1B_k = \dfrac{g(x_k) - g(x_{k-1})}{x_k - x_{k-1}} is the unique solution of Bksk=ykB_ks_k = y_k, the secant equationThe secant method needs no second derivative and converges superlinearly, with order ϕ=1+52≈1.618\phi = \tfrac{1 + \sqrt5}2 \approx 1.618 rather than 22: the errors here, 8.6×10−28.6\times10^{-2}, 1.4×10−21.4\times10^{-2}, 4.2×10−44.2\times10^{-4}, 2.1×10−62.1\times10^{-6}, gain about 1.61.6 times as many digits per step as the last. In nn dimensions the equation Bksk=ykB_ks_k = y_k has infinitely many solutions for the matrix BkB_k, and BFGS picks the one closest to the previous estimate that stays symmetric and positive definite; that choice is all that separates it from this problem, and it is why a quasi-Newton method converges superlinearly without ever forming a Hessian.

Problem 10

Apply Newton's method to g(x)=x3−2x+2g(x) = x^3 - 2x + 2 from x0=0x_0 = 0 and from x0=−2x_0 = -2. Compute the first iterates in each case, say what happens, and explain the two outcomes in terms of Problem 3.

  1. g′(x)=3x2−2g'(x) = 3x^2 - 2. From x0=0x_0 = 0: g(0)=2g(0) = 2, g′(0)=−2g'(0) = -2, so x1=0−2−2=1x_1 = 0 - \dfrac{2}{-2} = 1.The tangent at 00 has slope −2-2 and crosses zero at x=1x = 1.
  2. g(1)=1−2+2=1g(1) = 1 - 2 + 2 = 1, g′(1)=1g'(1) = 1, so x2=1−11=0x_2 = 1 - \dfrac11 = 0.The tangent at 11 has slope 11 and crosses zero at x=0x = 0.
  3. x3=1x_3 = 1, x4=0x_4 = 0, and so on: the iteration cycles between 00 and 11 for ever and never converges.Steps 1 and 2 repeat exactly; neither point is near a root, since g>0g > 0 on [0,1][0, 1] and in fact for every x>−1.77x > -1.77.
  4. From x0=−2x_0 = -2: g(−2)=−8+4+2=−2g(-2) = -8 + 4 + 2 = -2, g′(−2)=10g'(-2) = 10, x1=−2+0.2=−1.8x_1 = -2 + 0.2 = -1.8; g(−1.8)=−0.232g(-1.8) = -0.232, g′(−1.8)=7.72g'(-1.8) = 7.72, x2≈−1.8+0.03005=−1.76995x_2 \approx -1.8 + 0.03005 = -1.76995; then x3≈−1.7692927x_3 \approx -1.7692927, x4≈−1.7692924x_4 \approx -1.7692924.Two full Newton steps and two more carried to the digits shown; the real root is x∗≈−1.7692924x^* \approx -1.7692924.
  5. Errors from −2-2: 0.230.23, 3.1×10−23.1\times10^{-2}, 6.6×10−46.6\times10^{-4}, 3.1×10−73.1\times10^{-7}: quadratic, with ek+1/ek2e_{k+1}/e_k^2 settling near g′′(x∗)2g′(x∗)=6x∗2(3x∗2−2)=−10.62⋅7.39≈−0.72\dfrac{g''(x^*)}{2g'(x^*)} = \dfrac{6x^*}{2(3x^{*2} - 2)} = \dfrac{-10.6}{2\cdot 7.39} \approx -0.72.Problem 3's constant with g′′=6xg'' = 6x and g′(x∗)≈7.39g'(x^*) \approx 7.39; the error signs alternate because the constant is negative.
  6. From x0=0x_0 = 0 Newton cycles 0→1→0→⋯0 \to 1 \to 0 \to \cdots; from x0=−2x_0 = -2 it converges to x∗≈−1.76929x^* \approx -1.76929 with errors 0.230.23, 0.0310.031, 6.6×10−46.6\times10^{-4}, 3.1×10−73.1\times10^{-7}Problem 3 promises quadratic convergence only once C∣ek∣<1C\lvert e_k\rvert < 1 with CC evaluated near the root; from x0=0x_0 = 0 the error is 1.771.77, g′g' changes sign between x0x_0 and x∗x^* (at x=−2/3x = -\sqrt{2/3}), and the tangent line is a useless model of gg over that distance. The cubic has one real root and two complex ones, and the pair {0,1}\{0, 1\} is an attracting cycle of the Newton map: a whole interval of starts is pulled into it. For minimisation the same pathology appears when f′′f'' changes sign between the start and the minimiser. The practical cures are to damp the step (Problem 8) or to accept the full step only when it reduces ∣g∣\lvert g\rvert or ff by enough, a backtracking line search, and then to let the full step take over near the solution, where Problem 3 applies; Mistake 4 reads Problem 3 as a global guarantee.

Where this goes wrong

1. Newton's iteration applied to f instead of f'

The root-finding formula is the one everyone remembers, and the function to hand is the loss.

  1. For a root of gg: xk+1=xk−g(xk)/g′(xk)x_{k+1} = x_k - g(x_k)/g'(x_k)Right so far: Problem 2.
  2. “To minimise ff, run Newton on ff.”The habit that causes the mistake: Problem 4 minimised by solving f′=0f' = 0, so the function fed to the root-finder is f′f', and the division is by f′′f''.
  3. xk+1=xk−f(xk)/f′(xk)x_{k+1} = x_k - f(x_k)/f'(x_k) with f(x)=ex−2xf(x) = e^x - 2xThis looks for a root of ff, and ff has none: its minimum value is f(log⁡2)=2−2log⁡2≈0.61>0f(\log 2) = 2 - 2\log 2 \approx 0.61 > 0. From x0=0x_0 = 0: x1=0−1/(−1)=1x_1 = 0 - 1/(-1) = 1, x2=1−(e−2)/(e−2)=0x_2 = 1 - (e - 2)/(e - 2) = 0, a two-cycle like Problem 10's, and from other starts the iterates wander. The correct iteration is Problem 4's xk+1=xk−(exk−2)/exkx_{k+1} = x_k - (e^{x_k} - 2)/e^{x_k}. The same confusion in nn dimensions divides by the gradient instead of the Hessian, which is not even an operation; the step that exists is −H−1∇f-H^{-1}\nabla f, and its one-dimensional shadow is −f′/f′′-f'/f''.

2. Gauss–Newton taken to be the exact Newton step

For a linear residual the two coincide, and the equality is carried over to the nonlinear case.

  1. ∇f=J⊤r\nabla f = J^\top r and, for r=Aθ−br = A\theta - b, ∇2f=J⊤J\nabla^2f = J^\top JRight so far: Problem 7, steps 1 and 5.
  2. “The Hessian of a sum of squares is J⊤JJ^\top J.”The shortcut that causes the mistake: step 2 of Problem 7 has a second term, ∑nrn∇2rn\sum_nr_n\nabla^2r_n, that vanishes only when the residuals are linear in θ\theta or zero.
  3. ∇2f=J⊤J\nabla^2f = J^\top J for rn(θ)=θ1eθ2tn−ynr_n(\theta) = \theta_1e^{\theta_2t_n} - y_n, so Gauss–Newton converges quadraticallyFor this residual ∂2rn/∂θ1∂θ2=tneθ2tn\partial^2r_n/\partial\theta_1\partial\theta_2 = t_ne^{\theta_2t_n} and ∂2rn/∂θ22=θ1tn2eθ2tn\partial^2r_n/\partial\theta_2^2 = \theta_1t_n^2e^{\theta_2t_n}, so the true Hessian is J⊤J+∑nrn∇2rnJ^\top J + \sum_nr_n\nabla^2r_n, and the check finds the second term far from negligible away from a good fit. Gauss–Newton is Newton on the linearised residual, not on ff; its convergence is quadratic only if the residuals vanish at the solution, linear with a rate set by the size of the dropped term otherwise, and it can diverge for large-residual problems, which is the case Levenberg–Marquardt's damping (Problem 8) exists to rescue. The thing that is exactly true is weaker and more useful: J⊤JJ^\top J is always PSD, so the Gauss–Newton direction is always downhill.

3. Feeding the Newton direction to a line search without checking its sign

A line search makes any step safe, provided it is a direction along which the function decreases.

  1. δ=−H−1∇f\delta = -H^{-1}\nabla f and a line search picks the step length α\alpha along δ\deltaRight so far: the standard damped Newton template.
  2. “The line search will handle any problems with the step.”The habit that causes the mistake: a line search shortens a step; it cannot reverse one, and it assumes ∇f⊤δ<0\nabla f^\top\delta < 0.
  3. At (1,2)(1, 2) for f=x2−y2f = x^2 - y^2, search along δ=(−1,−2)⊤\delta = (-1, -2)^\top∇f⊤δ=6>0\nabla f^\top\delta = 6 > 0 (Problem 6): ff increases for every small α>0\alpha > 0, so a backtracking search halves α\alpha until it underflows and the iteration stalls, or an exact search returns α=0\alpha = 0. The direction is uphill because H=diag⁡(2,−2)H = \operatorname{diag}(2, -2) is indefinite, and no step length fixes a wrong direction. The repair is to the matrix, not the search: use H+μIH + \mu I with μ>2\mu > 2 (Problem 8), which makes ∇f⊤δμ<0\nabla f^\top\delta_\mu < 0, or replace the negative eigenvalue by its absolute value, which gives δ=(−1,2)⊤\delta = (-1, 2)^\top with ∇f⊤δ=−10\nabla f^\top\delta = -10. Checking the sign of ∇f⊤δ\nabla f^\top\delta before searching costs one dot product.

4. Reading quadratic convergence as convergence from any start

Newton's method is the fast one, and fast is heard as reliable.

  1. ∣ek+1∣≤C∣ek∣2\lvert e_{k+1}\rvert \le C\lvert e_k\rvert^2 near a root with g′(x∗)≠0g'(x^*) \neq 0Right so far: Problem 3.
  2. “Newton's method converges quadratically, so it converges.”The habit that causes the mistake: Problem 3's bound only shrinks the error when C∣ek∣<1C\lvert e_k\rvert < 1, which is a statement about where xkx_k is, not about the method.
  3. For g(x)=x3−2x+2g(x) = x^3 - 2x + 2, Newton from x0=0x_0 = 0 converges quadratically to the rootIt cycles 0→1→00 \to 1 \to 0 for ever (Problem 10), and from x0=0.5x_0 = 0.5 it wanders before landing in the same cycle; only starts near enough to x∗≈−1.769x^* \approx -1.769, where g′g' keeps its sign, get the promised doubling of digits. In minimisation the analogue is a start on the far side of an inflection point, where f′′f'' has the wrong sign and the step goes to a maximum (Problem 6). Gradient descent with a small enough step decreases ff from any start on a smooth bounded-below function; Newton trades that guarantee for speed, and the globalisation strategies, damping, line searches and trust regions, are what buy the guarantee back. In practice a first-order method brings the iterate into the basin and the second-order method finishes.

5. Expecting the Newton step to scale with the loss

Dividing a summed loss by the number of examples makes the gradient NN times smaller, and the learning rate has to be retuned; the same is expected of the Newton step.

  1. For f~=cf\tilde f = cf with c>0c > 0: ∇f~=c∇f\nabla\tilde f = c\nabla f and ∇2f~=c∇2f\nabla^2\tilde f = c\nabla^2fRight so far: a constant comes through both derivatives.
  2. “Scaling the loss by cc scales every step by cc.”The habit that causes the mistake: true for gradient descent, where −η∇f~=−cη∇f-\eta\nabla\tilde f = -c\eta\nabla f; Problem 5 showed Newton ignores reparameterisations, and this is the simplest one.
  3. The Newton step for f~\tilde f is cc times the Newton step for ff−(c∇2f)−1(c∇f)=−1cc (∇2f)−1∇f=−(∇2f)−1∇f-(c\nabla^2f)^{-1}(c\nabla f) = -\tfrac1c c\,(\nabla^2f)^{-1}\nabla f = -(\nabla^2f)^{-1}\nabla f: the cc cancels, and the step is identical, which is the regression page's observation that Newton's step for logistic regression is the same for the mean loss and the summed loss. Nothing needs retuning when the loss is rescaled, and no learning rate exists to retune, which is one of the method's attractions. The step that does scale is the damped one of Problem 8, because μI\mu I is not multiplied by cc: −(cH+μI)−1c∇f=−(H+μcI)−1∇f-(cH + \mu I)^{-1}c\nabla f = -(H + \tfrac\mu cI)^{-1}\nabla f, so rescaling the loss is equivalent to rescaling the damping, and Levenberg–Marquardt's μ\mu has to be chosen relative to the size of J⊤JJ^\top J.

Print this set: newtons-method-and-second-order-optimisation.pdf (problems, answers, and worked solutions on separate pages).