HT2026 Continuous Maths notes


Remaining TODOs: 27


1. Derivatives and Taylorโ€™s Theorem

1.1. Continuity and differentiation

Definition 1.1.1: Let ๐‘“:๐ทโ†’โ„,๐ทโІโ„.

๐‘“ is continuous at ๐‘ฅ if limโ„Žโ†’0๐‘“(๐‘ฅ+โ„Ž)=๐‘“(๐‘ฅ).

๐‘“ is continuous if it is continuous at every ๐‘ฅโˆˆ๐ท.

Definition 1.1.2: Let ๐‘“:๐ทโ†’โ„,๐ทโІโ„๐‘›.

๐‘“ is continuous at ๐’™ if lim๐’‰โ†’๐ŸŽ๐‘“(๐’™+๐’‰)=๐‘“(๐’™).

๐‘“ is continuous if it is continuous at every ๐’™โˆˆ๐ท.

Theorem 1.1.3: If ๐‘” and ๐‘” are continuous, so are:

  • ๐‘“+๐‘”
  • ๐‘๐‘“ โˆ€๐‘โˆˆโ„
  • ๐‘“๐‘› โˆ€๐‘›โˆˆโ„•
  • ๐‘“๐‘”
  • ๐‘“โˆ˜๐‘”
  • max(๐‘“,๐‘”)
  • |๐‘“|
  • exp(๐‘“)
  • ๐‘“๐›ผ โˆ€๐›ผโˆˆโ„, when ๐‘“ strictly positive
  • log๐‘“, where ๐‘“ strictly positive
  • ๐‘“๐‘”, where ๐‘” nonzero

Definition 1.1.4: Let ๐‘“:๐ทโ†’โ„,๐ทโІโ„.

๐‘“ is differentiable at ๐‘ฅ if limโ„Žโ†’0๐‘“(๐‘ฅ+โ„Ž)โˆ’๐‘“(๐‘ฅ)โ„Ž=๐‘‘ exists. Then ๐‘‘ is the derivative of ๐‘“ at ๐‘ฅ.

๐‘“ is differentiable if it is differentiable at every ๐‘ฅโˆˆ๐ท.

Remark: If a function is not continuous, it is not differentiable.

Definition 1.1.5: A secant is a line that connects two points on a surface.

A tangent can be thought of as a limit of secants as the distance between the two points tend to 0.

Remark: If ๐‘“ and ๐‘” are differentiable, so are all the combinations that preserve continuity mentioned earlier, with the exception of max(๐‘“,๐‘”) and |๐‘“|.
Remark: The derivative is a linear operator.

Theorem 1.1.6 (Quotient rule):

dd๐‘ฅ๐‘“๐‘”=๐‘”d๐‘“d๐‘ฅโˆ’๐‘“d๐‘”d๐‘ฅ๐‘”2.

Theorem 1.1.7 (Derived quotient rule):

dd๐‘ฅ(๐‘“๐‘”๐‘˜)=๐‘”d๐‘“d๐‘ฅโˆ’๐‘˜๐‘“d๐‘”d๐‘ฅ๐‘”๐‘˜+1.
Proof: Exercise; see problem sheet 0

1.2. Taylorโ€™s theorem for univariate functions

Theorem 1.2.1 (Taylor's Theorem (univariate)): For ๐‘“:โ„โ†’โ„,๐‘ฅ0โˆˆโ„,

๐‘“(๐‘ฅ)=โˆ‘๐‘–=0๐‘˜(๐‘ฅโˆ’๐‘ฅ0)๐‘–๐‘–!d๐‘–๐‘“d๐‘ฅ๐‘–(๐‘ฅ0)โŸTaylor polynomial+(๐‘ฅโˆ’๐‘ฅ0)๐‘˜+1(๐‘˜+1)!d๐‘˜+1๐‘“d๐‘ฅ๐‘˜+1(๐œ‰)โŸError term

for some ๐œ‰โˆˆ(๐‘ฅ0,๐‘ฅ).

The Taylor polynomial (of degree ๐‘˜) is also written ๐‘“ฬ‚๐‘˜(๐‘ฅ), and the error term, or Lagrange remainder term is denoted by ๐‘’๐‘˜+1(๐‘ฅ,๐‘ฅ0).

So, we can write ๐‘“(๐‘ฅ)=๐‘“ฬ‚๐‘˜(๐‘ฅ)+๐‘’๐‘˜+1(๐‘ฅ,๐‘ฅ0) for any ๐‘˜โˆˆโ„• so long as the first ๐‘˜+1 derivatives of ๐‘“ all exist and are continuous on (๐‘ฅ0,๐‘ฅ).

For small ๐‘’๐‘˜+1(๐‘ฅ,๐‘ฅ0), ๐‘“(๐‘ฅ)โ‰ˆ๐‘“ฬ‚๐‘˜(๐‘ฅ).

Remark: ๐‘“ฬ‚๐‘˜(๐‘ฅ) is the unique ๐‘˜-order polynomial that agrees with ๐‘“ as to its first ๐‘˜ derivatives at ๐‘ฅ0.
Remark:Taylorโ€™s Theorem is not the same as a Taylor series; the Taylor series is an infinite sum and does not always converge to the correct answer. (If ๐‘’๐‘˜+1(๐‘ฅ,๐‘ฅ0) tends to 0 for large ๐‘˜ and small enough (๐‘ฅ0โˆ’๐‘ฅ), the series does converge and that function is analytic).

1.3. Partial and vector derivatives

Definition 1.3.1: Let ๐‘“:โ„2โŸถโ„.

๐œ•๐‘“๐œ•๐‘ฅ is the partial derivative of ๐‘“(๐‘ฅ,๐‘ฆ) with respect to ๐‘ฅ, as if ๐‘ฆ were constant.

๐œ•2๐‘“๐œ•๐‘ฆ๐œ•๐‘ฅ means differentiate first with respect to ๐‘ฅ, then ๐‘ฆ. In general this is not equal to ๐œ•2๐‘“๐œ•๐‘ฅ๐œ•๐‘ฆ, but often it is.

Definition 1.3.2: Let ๐‘“:โ„๐‘›โŸถโ„. Then the vector derivative is

d๐‘“d๐’™=(๐œ•๐‘“๐œ•๐‘ฅ1โ‹ฎ๐œ•๐‘“๐œ•๐‘ฅ๐‘›).

It turns out that this makes sense to be a derivative, because

lim๐’‰โ†’๐ŸŽ๐‘“(๐’™+๐’‰)โˆ’๐‘“(๐’™)โˆ’(d๐‘“d๐’™)โŠค๐’‰โ€–๐’‰โ€–=0.

Remark: Some standard derivatives for vectors that are analogous to scalars:

  • dd๐’™๐’‚โŠค๐’™=๐’‚
  • dd๐’™๐’™โŠค๐€๐’™=(๐€+๐€โŠค)๐’™
  • dd๐’™โ€–๐’™โ€–=๐’™โ€–๐’™โ€–

Remark: Similarly to scalar derivatives, the vector derivative is linear and has a product and quotient rule.

The chain rule for ๐‘“โˆ˜๐‘”,๐‘“:โ„๐‘›โŸถโ„,๐‘”:โ„โ†’โ„ is the same as for scalars:

dd๐’™(๐‘”โˆ˜๐‘“)=(d๐‘”d๐’™โˆ˜๐‘“)d๐‘“d๐’™.

For ๐’‡:โ„๐‘šโŸถโ„๐‘›,๐‘”:โ„๐‘›โ†’โ„,

dd๐’™(๐‘”โˆ˜๐’‡)=๐‰(๐’‡)โŠค(d๐‘”d๐’™โˆ˜๐’‡)

where ๐‰ is the Jacobian - see Definitionย 1.4.2.

Remark: The type of the vector derivative of ๐‘“:โ„๐‘›โ†’โ„ is

d๐‘“d๐’™:โ„๐‘›โ†’โ„๐‘›.

Also

dd๐’™:(โ„๐‘›โ†’โ„)โ†’(โ„๐‘›โ†’โ„๐‘›).

Definition 1.3.3: Let ๐‘“:โ„๐‘›โ†’โ„. Then the Hessian of ๐‘“ is

๐‡(๐‘“)=(๐œ•2๐‘“๐œ•๐‘ฅ12โ‹ฏ๐œ•2๐‘“๐œ•๐‘ฅ1๐œ•๐‘ฅ๐‘›โ‹ฎโ‹ฑโ‹ฎ๐œ•2๐‘“๐œ•๐‘ฅ๐‘›๐œ•๐‘ฅ1โ‹ฏ๐œ•2๐‘“๐œ•๐‘ฅ๐‘›2).
Remark: The Hessian is analogous to the second derivative of a scalar function.
Theorem 1.3.4 (Clairaut's theorem): If everything is continuous, ๐‡(๐‘“)=๐‡(๐‘“)โŠค.

1.4. Vector fields and the Jacobian

Definition 1.4.1: A vector field or vector-valued function is a function ๐’‡:๐ทโ†’โ„๐‘š for ๐ทโІโ„๐‘›.

Remark: A vector field ๐‘“ can be decomposed into

๐’‡(๐’™)=(๐‘“1(๐’™)โ‹ฎ๐‘“๐‘š(๐’™)).

Definition 1.4.2: The derivative of a vector field ๐’‡:โ„๐‘›โ†’โ„๐‘š is the Jacobian, ๐‰(๐’‡):โ„๐‘›โ†’โ„๐‘šร—๐‘›, where

๐‰(๐’‡)=(๐œ•๐‘“1๐œ•๐‘ฅ1โ‹ฏ๐œ•๐‘“1๐œ•๐‘ฅ๐‘›โ‹ฎโ‹ฑโ‹ฎ๐œ•๐‘“๐‘š๐œ•๐‘ฅ1โ‹ฏ๐œ•๐‘“๐‘š๐œ•๐‘ฅ๐‘›).

Remark: For ๐‘“:โ„๐‘›โ†’โ„,

๐‰(๐’‡)=(d๐‘“d๐’™)โŠค.
Remark: The Jacobian is a linear operator, i.e. ๐‰(๐€๐’‡)=๐€๐‰(๐’‡) for constant ๐€.

Definition 1.4.3: The Jacobian has a dot-product rule:

๐‰(๐’‡โŠค๐’ˆ)=๐’ˆโŠค๐‰(๐’‡)+๐’‡โŠค๐‰(๐’ˆ).

Definition 1.4.4: The Jacobian has a scalar-vector product rule:

๐‰(๐‘“๐’ˆ)=๐’ˆd๐‘“โŠคd๐’™+๐‘“๐‰(๐’ˆ).

Definition 1.4.5: The Jacobian has a chain rule, called the partial chain rule:

๐‰(๐’ˆโˆ˜๐’‡)=(๐‰(๐‘”)โˆ˜๐’‡)๐‰(๐’‡).

Remark: Some standard Jacobians:

๐‰(๐’™)=๐ผ;๐‰(๐€๐’™)=๐€.

Remark: The Hessian is a Jacobian:

๐‡(๐‘“)=๐‰(d๐‘“d๐’™)โŠค.

Luckily because of Clairautโ€™s Theorem, the transpose can usually be ignored.

Note that this basically just says that the second derivative is the derivative of the derivative.

Remark: Given vectors ๐’™๐‘–,

โˆ‘๐’™๐‘–๐’™๐‘–โŠค=๐—,

where the rows of ๐— are the ๐’™๐‘–โŠคs.

Moreover, given scalars ๐‘‘๐‘–,

โˆ‘๐‘‘๐‘–๐’™๐‘–๐’™๐‘–โŠค=๐—โŠค๐ƒ๐—,

with ๐— as before and ๐ƒ a diagonal matrix with the ๐‘‘๐‘–s as the diagonal entries.

These identities can come in handy when computing the Jacobian.

1.5. Taylorโ€™s theorem for multivariate functions

Theorem 1.5.1 (Taylor's Theorem for multivariate functions): For ๐‘“:โ„๐‘›โ†’โ„,๐‘˜โˆˆโ„•, if ๐’™=๐’™๐ŸŽ+๐’‰,

๐‘“(๐’™)=๐‘“(๐’™๐ŸŽ)+ [โ„Ž1๐œ•๐œ•๐‘ฅ1(๐‘ฅ0)+โ€ฆ+โ„Ž๐‘›๐œ•๐œ•๐‘ฅ๐‘›๐‘“](๐’™๐ŸŽ)+ 12![(โ„Ž1๐œ•๐œ•๐‘ฅ1+โ€ฆ+โ„Ž๐‘›๐œ•๐œ•๐‘ฅ๐‘›)2๐‘“](๐’™๐ŸŽ)+ โ€ฆ+ 1๐‘˜![(โ„Ž1๐œ•๐œ•๐‘ฅ1+โ€ฆ+โ„Ž๐‘›๐œ•๐œ•๐‘ฅ๐‘›)๐‘˜๐‘“](๐’™๐ŸŽ)} ๐‘˜th order Taylor polynomial,๐‘“ฬ‚๐‘˜+ 1(๐‘˜+1)![(โ„Ž1๐œ•๐œ•๐‘ฅ1+โ€ฆ+โ„Ž๐‘›๐œ•๐œ•๐‘ฅ๐‘›)๐‘˜+1๐‘“](๐’™๐ŸŽ+๐œ‰๐’‰)โŸError termfor some๐œ‰โˆˆ(0,1).

Here, the brackets with partial derivatives inside are carrying out operator algebra - they are not multiplication, but follow the same distributive rules so can be though of as so.

The Taylor polynomials up to degree 2 can be written a bit more nicely:

๐‘“ฬ‚0(๐’™)=๐‘“(๐’™๐ŸŽ);๐‘“ฬ‚1(๐’™)=๐‘“(๐’™๐ŸŽ)+๐’‰โŠคd๐‘“d๐’™(๐’™๐ŸŽ);๐‘“ฬ‚2(๐’™)=๐‘“(๐’™๐ŸŽ)+๐’‰โŠคd๐‘“d๐’™(๐’™๐ŸŽ)+12๐’‰โŠค๐‡(๐‘“)(๐’™๐ŸŽ)๐’‰.

For higher powers, we need tensors which are beyond the scope of this course.

The error terms (up to ๐‘˜=2) can be written in a similar fashion but evaluated at ๐’™๐ŸŽ+๐œ‰๐’‰ for some ๐œ‰โˆˆ(0,1).

Theorem 1.5.2: err๐‘˜+1(๐’™,๐’™๐ŸŽ) is small in the sense that

limโ€–๐’™โˆ’๐’™๐ŸŽโ€–โ†’0err๐‘˜+1(๐’™,๐’™๐ŸŽ)โ€–๐’™โˆ’๐’™๐ŸŽโ€–๐‘˜= 0.
(Proof not needed.)

2. Optimisation

Definition 2.1: Let ๐‘“:โ„๐‘›โ†’โ„.

The canonical optimisation problem is to find

min๐‘ฅโˆˆ๐น๐‘“(๐‘ฅ)orargmin๐‘ฅโˆˆ๐น๐‘“(๐‘ฅ)

.

Note that argmin is a set.

๐นโŠ‚โ„๐‘› is the feasible region.

If ๐น=โ„๐‘›, the optimisation is unconstrained.

If ๐นโŠ‚โ„๐‘›, the optimisation is constrained. The standard form for constraints is:

๐น={๐’™โˆˆโ„๐‘›|๐‘”1(๐’™)=0,โ€ฆ,๐‘”๐‘™(๐’™)=0โŸequality constraints, โ„Ž1(๐’™)โ‰ฅ0,โ€ฆ,โ„Ž๐‘š(๐’™)โ‰ฅ0โŸinequality constraints}.
Definition 2.2: If ๐น is empty, there is no solution and the optimisation problem is inconsistent.
Remark: The problem can also have no solution if, in the feasible region, the function tends to โˆ’โˆž or there is a vertical asymptote.

2.1. Optimisation in 1 dimension

Solutions to argmin๐‘ฅโˆˆโ„๐‘“(๐‘ฅ) satisfy the 1st-order condition d๐‘“d๐‘ฅ=0. But so do non-solutions!

Stationary points can be classified by Taylorโ€™s theorem.

If d๐‘“d๐‘ฅ(๐‘ฅ0)=0, then ๐‘“(๐‘ฅ)=๐‘“(๐‘ฅ0)+๐‘ฅโˆ’๐‘ฅ02d2๐‘“d๐‘ฅ2(๐œ‰) for some ๐œ‰โˆˆ(๐‘ฅ0,๐‘ฅ). So if the second derivative is positive, then for some region around ๐œ‰, ๐‘“(๐‘ฅ)>๐‘“(๐‘ฅ0) around ๐‘ฅ0, so ๐‘ฅ is a minimum. Similarly, if the second derivative is negative, then ๐‘“(๐‘ฅ)<๐‘“(๐‘ฅ0) around ๐‘ฅ0 so ๐‘ฅ is a maximum.

If the second derivative is 0, this doesnโ€™t necessarily mean that it is a point of inflection; we need to look for the first nonzero derivative. If the first nonzero derivative is odd, then it is a stationary point of inflection - since the function changes concavity around the stationary point - but if the first nonzero derivative is an even derivative, use the same rules as for the second derivative.

However, this doesnโ€™t always work (e.g. ๐‘“(๐‘ฅ)=๐‘’โˆ’1๐‘ฅ2,๐‘“(0)=0 has all of its derivatives at 0 equal to 0).

For constrained optimisations, do the same but also consider the endpoints.

2.2. Positive/negative (semi)definiteness

Definition 2.2.1: Given a symmetric matrix ๐€, ๐€ is

  • positive definite if ๐’™โŠค๐€๐’™>0 for all ๐’™โ‰ 0
  • positive semidefinite if ๐’™โŠค๐€๐’™โ‰ฅ0 for all ๐’™โ‰ 0
  • negative definite if ๐’™โŠค๐€๐’™<0 for all ๐’™โ‰ 0
  • negative semidefinite if ๐’™โŠค๐€๐’™โ‰ค0 for all ๐’™โ‰ 0
  • indefinite otherwise

Theorem 2.2.2 (Spectral theorem): If ๐€ is an ๐‘›ร—๐‘› symmetric matrix, then there exists a basis (for โ„๐‘›) of orthogonal eigenvectors of ๐€.

Proof: See LA.

Proposition 2.2.3:

These are equivalent to certain conditions on the eigenvalues: positive definite iff all eigenvalues strictly positive, positive semidefinite iff all eigenvalues positive, etc.

Proof (for positive definiteness):

Let ๐€ be a symmetric matrix. By the spectral theorem, there exists an orthogonal basis of โ„๐‘› โŸจ๐’™1,โ€ฆ,๐’™๐‘›โŸฉ; w.l.o.g. let the ๐’™๐‘–s be unit vectors. Let ๐œ†1,โ€ฆ,๐œ†๐‘› be the corresponding eigenvalues.

First suppose that ๐œ†1,โ€ฆ,๐œ†๐‘›>0. By the spectral theorem, โŸจ๐’™1,โ€ฆ,๐’™๐‘›โŸฉ forms an orthogonal basis for โ„๐‘›, so for any ๐’—โˆˆโ„๐‘›, โˆƒ๐‘1,โ€ฆ,๐‘๐‘›โˆˆโ„ s.t. ๐’—=๐‘1๐’™1+โ€ฆ+๐‘๐‘›๐’™๐‘›.

Then for any ๐’—โ‰ ๐ŸŽ,

๐’—โŠค๐€๐’—=๐‘12๐’™1โŠค๐€๐’™1+โ€ฆ+๐‘๐‘›2๐’™๐‘›โŠค๐€๐’™๐‘›by distributivity of mat-vec mult.=๐‘12๐œ†1๐’™1โŠค๐’™1+โ€ฆ+๐‘๐‘›2๐œ†๐‘›๐’™๐‘›โŠค๐’™๐‘›=๐‘12๐œ†1+โ€ฆ+๐‘๐‘›2๐œ†๐‘›because the๐’™๐‘–s unit vectors.

Since (โˆ—)2โ‰ฅ0 and the ๐œ†๐‘–s are strictly positive, and there exists at least one non-zero ๐‘๐‘–, the sum of the products of positive numbers must be positive, so ๐’—โŠค๐€๐’— is positive definite.

Conversely, suppose that ๐€ is positive definite.

Then, for all 1โ‰ค๐‘–โ‰ค๐‘›,

๐’™๐‘–โŠค๐€๐’™๐‘–>0because๐’™๐‘–โ‰ ๐ŸŽand๐€positive definiteโŸน๐œ†๐‘–๐’™๐‘–โŠค๐’™๐‘–>0โŸน๐œ†๐‘–>0because๐’™๐‘–unit vector.

Remark:

Given a symmetric 2ร—2 matrix ๐ดโ‰”(๐‘Ž๐‘๐‘๐‘) with eigenvalues ๐œ†1,๐œ†2,

๐œ†1๐œ†2=๐‘Ž๐‘โˆ’๐‘2.

Hence

  • ๐‘Ž๐‘โˆ’๐‘2<0โŸน๐€ indefinite;
  • ๐‘Ž๐‘โˆ’๐‘2>0โˆง๐‘Ž>0โŸน๐€ positive definite;
  • ๐‘Ž๐‘โˆ’๐‘2=0โˆง๐‘Ž+๐‘โ‰ฅ0โŸน๐€ positive semidefinite
  • ๐‘Ž๐‘โˆ’๐‘2>0โˆง๐‘Ž<0โŸน๐€ negative definite;
  • ๐‘Ž๐‘โˆ’๐‘2=0โˆง๐‘Ž+๐‘โ‰ค0โŸน๐€ negative semidefinite.
Definition 2.2.4: The pivots of a matrix are the entries on the diagonal when in echelon form, obtained without row multiplication or row swaps.

Remark: A symmetric matrix ๐€ is

  • positive definite if all its pivots >0
  • positive semidefinite if all its pivots are โ‰ฅ0
  • negative definite if all its pivots <0
  • negative semidefinite if all its pivots โ‰ค0
  • indefinite otherwise

but the definiteness conditions hold only if the pivots can be found without row swaps

Remark: Definiteness works a bit like signs for scalars. Pos def equivalent to positive, pos semidef quivalent to nonnegative, etc. Incl. (pos def)โˆ’1 pos def (and this always exists, in this case).

Remark: If ๐€ is positive (semi)definite then so are

  • ๐‘๐€ for any ๐‘>0
  • ๐€โˆ’1, which is guaranteed to exist if ๐€ is positive definite
  • ๐€๐๐€ for any positive (semi)definite ๐ต
  • any upper-left submatrix of ๐€ TODO intuition
  • ๐‚โŠค๐€๐‚, if ๐‚ is of full rank, regardless of if ๐‚ is square or not - but if ๐‘ not of full rank, we can still guarantee positive semidefiniteness TODO intuition
  • ๐€โˆ’๐’—๐’—โŠค, if ๐’—โŠค๐€โˆ’1๐’—<1
Remark: For any symmetric matrix ๐‚, ๐‚โˆ’๐œ†๐ˆ is positive semidefinite if ๐œ†โ‰ค the smallest eigenvalue of ๐‚. It is positive definite if the inequality is strict.
Remark: The zero matrix is both positive semidefinite and negative semidefinite.

TODO: lookup: diagonally dominant

2.3. Unconstrained optimisation over โ„๐‘›

Solutions to argmin๐‘ฅโˆˆโ„๐‘›, if they exist, satisfy the 1st-order condition d๐‘“d๐’™=๐ŸŽ. This is in general not easy to solve as it is a system of ๐‘› (not necessarily linear) equations.

In higher dimensions, stationary points can be local minima, local maxima or saddle points.

Definition 2.3.1: A saddle point is a stationary point at which moving in some directions gives a more positive result, and in another direction decreases.

We can classify these higher-dimensional stationary points using the Hessian, similarly to how we used the second derivative for scalar functions.

Theorem 2.3.2:If ๐‡(๐‘“)(๐’™) is positive definite, then ๐‡(๐‘“)(๐’™โˆ—) is positive definite for ๐’™โˆ— close to ๐’™.

Hence if the Hessian at ๐’™ is positive definite, the stationary point at ๐’™ is a local minimum. If the Hessian is negative definite, the stationary point is a local maximum. If the Hessian is indefinite, the stationary point is a saddle point.

If the Hessian is semidefinite, you cannot determine anything other than that the point is not a local minimum/maximum. For better analysis we would need to use the 3rd-order Taylor approximation.

Fact: the outer product of a vector with itself is always positive semidefinite. Proof: ๐’—โŠค(๐’ƒ๐’ƒโŠค)๐’—=(๐’—โŠค๐’ƒ)2โ‰ฅ0.

2.4. Convexity

Definition 2.4.1: A set ๐ทโІโ„๐‘› is convex if

โˆ€๐’™๐Ÿ,๐’™๐Ÿโˆˆ๐ท,๐›ผโˆˆ(0,1),(1โˆ’๐›ผ)๐’™๐Ÿ+๐›ผ๐’™๐Ÿโˆˆ๐ท.

That is, the line connecting any ๐’™๐Ÿ,๐’™๐Ÿโˆˆ๐ท lies wholly in ๐ท.

Definition 2.4.2: A function ๐‘“:๐ทโŸถโ„ for convex ๐ทโІโ„๐‘› is convex if

โˆ€๐’™๐Ÿ,๐’™๐Ÿโˆˆ๐ท,๐›ผโˆˆ(0,1),๐‘“((1โˆ’๐›ผ)๐’™๐Ÿ+๐›ผ๐’™๐Ÿ)โ‰ค(1โˆ’๐›ผ)๐‘“(๐’™๐Ÿ)+๐›ผ๐‘“(๐’™๐Ÿ).

That is, any point on ๐‘“ between ๐’™๐Ÿ and ๐’™๐Ÿ lies below the secant between ๐’™๐Ÿ and ๐’™๐Ÿ.

Equivalently, every secant on ๐‘“ lies above the surface of ๐‘“.

If the inequality is strict, ๐‘“ is strictly convex if the inequality is the other way around, ๐‘“ is concave or strictly concave in a similar manner.

Theorem 2.4.3: If ๐‘“ is convex, every stationary point is a global minimum.
Theorem 2.4.4: If ๐‘“ is strictly convex, there is at most one stationary point, and that is the global minimum.
Remark: If carrying out unconstrained optimisation on a convex function, just solve the first-order condition (once you have established that there is a minimum).
Remark: In one dimension, ๐‘“ is convex if d2๐‘“d๐‘“2โ‰ฅ0 everywhere; if the inequality is strict then ๐‘“ is strictly convex. The implication does not hold in reverse.
Remark: Convexity does not imply the existence of a minimum!
Remark: For higher dimensions, ๐‘“ is is convex iff ๐‡(๐‘“) is positive semidefinite everywhere; if (but not only if) ๐‡(๐‘“) is positive definite everywhere, then ๐‘“ is strictly convex.

Remark:

Some common convex and concave functions:

  • Linear functions are both convex and concave.
  • |๐‘ฅ|๐‘ for ๐‘>1 is strictly convex
  • ๐‘’๐‘ฅ is strictly convex
  • log๐‘ฅ is strictly concave
  • for convex ๐‘“, โˆ’๐‘“ is concave
  • ๐’™โ†ฆ๐’™โŠค๐€๐’™ is convex if ๐€ is positive semidefinite, strictly convex if ๐€ is positive definite
  • for convex ๐‘“,๐‘”, ๐‘“+๐‘” is convex
  • for convex ๐‘“, ๐‘“(๐€๐’™+๐’ƒ) is convex (but strict convexity is only preserved if ๐€ has full rank)
  • for convex ๐‘“,๐‘”, max(๐‘“,๐‘”) is convex
  • for convex ๐‘“, exp(๐‘“) is convex

Theorem 2.4.5: For ๐‘“:โ„โŸถโ„,๐‘”:โ„โ†’โ„,

๐‘“convexโˆง{๐‘“increasingโˆง๐‘”convex๐‘“decreasingโˆง๐‘”concave}โŸน๐‘“โˆ˜๐‘”convex;๐‘“concaveโˆง{๐‘“increasingโˆง๐‘”concave๐‘“decreasingโˆง๐‘”convex}โŸน๐‘“โˆ˜๐‘”concave.

Proof: ๐‘“โˆ˜๐‘” convex iff (๐‘“โˆ˜๐‘”)โ€ณโ‰ฅ0 everywhere.

dd๐‘ฅ(๐‘“โˆ˜๐‘”)=(d๐‘“d๐‘ฅ(๐‘”(๐‘ฅ)))โ‹…d๐‘”d๐‘ฅ.d2d๐‘ฅ2(๐‘“โˆ˜๐‘”)=(d2๐‘“d๐‘ฅ2(๐‘”(๐‘ฅ)))โ‹…(d๐‘”d๐‘ฅ)2+d๐‘“d๐‘ฅ(๐‘”(๐‘ฅ))d2๐‘”d๐‘”2.

(d๐‘”d๐‘ฅ)2 is always positive, so we require d2๐‘“d๐‘ฅ2 to be positive everywhere, i.e. ๐‘“ is convex. We then require d๐‘“d๐‘ฅ and d2๐‘“d๐‘”2 to have the same signs everywhere, so either ๐‘“ is increasing and ๐‘” is convex, or ๐‘“ is decreasing and ๐‘” is concave.

The proof for concavity is similar.

Remark: These conditions are sufficient but not necessary.
Remark: Theoremย 2.4.5 can be used also for ๐‘“:โ„โ†’โ„,๐‘”:โ„๐‘›โ†’โ„.

Theorem 2.4.6:

Let ๐‘“:โ„๐‘›โ†’โ„, ๐’ˆ:โ„๐‘šโ†’โ„๐‘› such that

๐’ˆโ‰”(๐‘”1โ‹ฎ๐‘”๐‘›)

with ๐‘”1,โ€ฆ,๐‘”๐‘›:โ„๐‘šโ†’โ„.

Then if ๐‘“ is (strictly) convex, and for each ๐‘–โˆˆ{1,โ€ฆ,๐‘›}, either

{๐‘“(strictly) increasing in its๐‘–th argumentโˆง๐‘”๐‘–(strictly) convex,or๐‘“(strictly) decreasing in its๐‘–th argumentโˆง๐‘”๐‘–(strictly) concave,

then ๐‘“โˆ˜๐’ˆ is (strictly) convex.

Theorem 2.4.7 (Jenson's inequality): For a random variable ๐‘‹ and convex function ๐‘“,

๐‘“(๐”ผ[๐‘‹])โ‰ค๐”ผ[๐‘“(๐‘ฅ)].

(This is not on the syllabus but is useful)

2.5. Optimisation tricks

Theorem 2.5.1:If ๐‘” is strictly increasing, then

argmin๐‘“(๐‘ฅ)=argmin๐‘”(๐‘“(๐‘ฅ)).

Theorem 2.5.2: If ๐‘” is injective/1-to-1 then

argmin๐‘“(๐‘ฅ)=๐‘”(argmin๐‘“(๐‘”(๐‘ฅ))).

2.6. Optimisation over โ„๐‘› with equality constraints

Remark: Given a minimisation problem with an equality constraint, it can sometimes be reduced to an unconstrained problem:

  • Given ๐‘”(๐‘ฅ,๐‘ฆ)=๐‘ฅ+๐‘ฆ+1,

    min๐’™โˆˆโ„2|๐‘”(๐’™)=0๐‘“(๐’™)=min๐‘ฅโˆˆโ„๐‘“(๐‘ฅ,โˆ’1โˆ’๐‘ฅ)
  • Given ๐‘”(๐‘ฅ,๐‘ฆ)=๐‘ฅ2+๐‘ฆ2โˆ’1,

    min๐’™โˆˆโ„2|๐‘”(๐’™)=0๐‘“(๐‘ฅ1,๐‘ฅ2)=min๐œƒโˆˆ(0,2๐œ‹]๐‘“(sin๐œƒ,cos๐œƒ)

But usually, this isnโ€™t the case.

Theorem 2.6.1 (Lagrange's theorem / method of Lagrange multipliers): For a minimisation problem with one equality constraint, minimise ๐‘“(๐’™) subject to ๐‘”(๐’™)=0, the stationary points must satisfy

d๐‘“d๐’™=๐œ†d๐‘”d๐’™,

i.e. a first order condition is dd๐‘ฅ(๐‘“(๐’™)โˆ’๐œ†๐‘”(๐’™))=๐ŸŽ.

Proof:

TODO

Definition 2.6.2: The Lagrangian of such a minimisation problem is

ฮ›(๐œ†,๐’™)=๐‘“(๐’™)โˆ’๐œ†๐‘”(๐’™).

The stationary points of ๐‘“(๐’™) where ๐‘”(๐’™)=๐ŸŽ are the stationary points of ฮ›.

Remark: It is not simple to determine if the stationary points of the Lagrangian are a minimum, maximum or saddle point of the problem. It is not sufficient to look at the definiteness of the Hessian of ฮ›, or the convexity of ๐‘“.

TODO: look up bordered Hessian

Theorem 2.6.3: For min๐‘“(๐’™)s.t.๐‘”1(๐’™)=0,โ€ฆ,๐‘”๐‘™(๐’™)=0,

the Lagrangian is

ฮ›(๐€,๐’™)=๐‘“(๐’™)โˆ’๐œ†1๐‘”1(๐’™)โˆ’โ€ฆโˆ’๐œ†๐‘™๐‘”๐‘™(๐’™).

Then the stationary points of the minimisation problem are the stationary points of the Lagrangian.

2.7. Inequality contrained optimisation (over โ„๐‘›)

Definition 2.7.1: Given a minimisation problem min๐‘“(๐’™) subject to โ„Ž(๐’™)โ‰ฅ0, at the solution, โ„Ž is tight if โ„Ž(๐’™)=0, and slack if โ„Ž(๐’™)>0.

To solve such a minimisation, solve:

  • for tight constraints via the previous section;
  • for slack constraints, by solving the usual first-order condition d๐‘“d๐’™=๐ŸŽ (as usual), and ignoring any solutions outside of the feasible region.

Either way, d๐‘“d๐’™=๐œ‡dโ„Žd๐’™, with ๐œ‡โ‰ฅ0: if we find a minimum of ๐‘“ on the boundary of the feasible region, where โ„Ž(๐’™)=0, then the gradients of ๐‘“ and โ„Ž at that point must be parallel and in the same direction, otherwise we could move into the interior of the feasible region, where โ„Ž(๐’™)โ‰ฅ0, while decreasing ๐‘“ (so on the boundary ๐œ‡>0); on the interior of the feasible region, ๐‘“ can attain a minimum independent of the constraint, so ๐œ‡=0.

Note that in both cases, ๐œ‡โ„Ž(๐’™)=0.

Therefore for inequality constraints, we can find stationary points of the lagrangian ฮ›(๐œ‡,๐’™)=๐‘“(๐’™)โˆ’๐œ‡โ„Ž(๐’™) that satisfy the constraint, simultaneously with ๐œ‡โ‰ฅ0, ๐œ‡โ„Ž(๐’™)=0.

Corollary 2.7.2 (Complementary slackness): At a minimum of an minimisation problem with constraint โ„Ž(๐’™)=0 and Lagrange multiplier ๐œ‡,

[๐œ‡โ‰ฅ0โˆงโ„Ž(๐’™)=0]โˆจ[๐œ‡=0โˆงโ„Ž(๐’™)>0].
Theorem 2.7.3: When optimising ๐‘“ with one inequality constraint, if ๐‘“ is convex and the feasible set is convex, then either every stationary point inside the constraint is a global minimum, or one of the stationary points on the constraint is a global minimum.

TODO KKT conditions (not on syllabus)

TODO: what to do when mix of equality and inequality constraints

3. Algorithms for numerical integration

3.1. 1-dimensional integration

Here we will consider approximating the integral of ๐‘“ over a small interval [๐‘Ž,๐‘], with ๐‘š=๐‘Ž+๐‘2.

The simplest approximation is the 0th order Taylor approximation; this is equal to the approximation using the 1st order Taylor approximation.

Definition 3.1.1: The midpoint rule: define

๐‘€1[๐‘“,๐‘Ž,๐‘]โ‰”โˆซ๐‘Ž๐‘๐‘“ฬ‚1(๐‘ฅ)d๐‘ฅ=(๐‘โˆ’๐‘Ž)๐‘“(๐‘š).

The subscript 1 indicates that it is operating over 1 strip. The notation for this (and other methods in this section) is not standard.

Theorem 3.1.2: The error of the midpoint rule,

err(๐‘€1)[๐‘“,๐‘Ž,๐‘]=๐‘€1[๐‘“,๐‘Ž,๐‘]โˆ’โˆซ๐‘Ž๐‘๐‘“(๐‘ฅ)d๐‘ฅ,

is bounded by

โˆ’(๐‘โˆ’๐‘Ž)324๐ท2โ‰คerr(๐‘€1)[๐‘“,๐‘Ž,๐‘]โ‰คโˆ’(๐‘โˆ’๐‘Ž)324๐ท2,

where

๐ท๐‘˜=min๐‘ฅโˆˆ(๐‘Ž,๐‘)d๐‘˜๐‘“d๐‘ฅ๐‘˜,๐ท๐‘˜=max๐‘ฅโˆˆ(๐‘Ž,๐‘)d๐‘˜๐‘“d๐‘ฅ๐‘˜.

Proof:

err(๐‘€1)[๐‘“,๐‘Ž,๐‘]=๐‘€1[๐‘“,๐‘Ž,๐‘]โˆ’โˆซ๐‘Ž๐‘๐‘“(๐‘ฅ)d๐‘ฅ=(๐‘โˆ’๐‘Ž)๐‘“(๐‘š)โˆ’โˆซ๐‘Ž๐‘๐‘“(๐‘š)+(๐‘ฅโˆ’๐‘š)d๐‘“d๐‘ฅ(๐‘š)+(๐‘ฅโˆ’๐‘š)22d2๐‘“d๐‘ฅ2(๐œ‰)d๐‘ฅfor some๐œ‰โˆˆ(๐‘Ž,๐‘)=(๐‘โˆ’๐‘Ž)๐‘“(๐‘š)โˆ’(๐‘โˆ’๐‘Ž)๐‘“(๐‘š)โˆ’[(๐‘ฅโˆ’๐‘š)]๐‘Ž๐‘d๐‘“d๐‘ฅ(๐‘š)โˆ’[(๐‘ฅโˆ’๐‘š)36]๐‘Ž๐‘d2๐‘“d๐‘ฅ2(๐œ‰)=โˆ’((๐‘โˆ’๐‘Ž+๐‘2)36โˆ’(๐‘Žโˆ’๐‘Ž+๐‘2)36)d2๐‘“d๐‘ฅ2(๐œ‰)=โˆ’(๐‘โˆ’๐‘Ž)324d2๐‘“d๐‘ฅ2(๐œ‰).

We can bound d2๐‘“d๐‘ฅ2(๐œ‰) by ๐ท2โ‰คd2๐‘“d๐‘ฅ2(๐œ‰)โ‰ค๐ท2, so

โˆ’(๐‘โˆ’๐‘Ž)324๐ท2โ‰คerr(๐‘€1)[๐‘“,๐‘Ž,๐‘]โ‰คโˆ’(๐‘โˆ’๐‘Ž)324๐ท2.

Definition 3.1.3: Instead of Taylorโ€™s theorem, we can use polynomial interpolation - a polynomial that agrees with ๐‘“ at some points.

Definition 3.1.4: The Trapezium rule creates a trapezium with the axis and the endpoints of the strip. It is generally worse than the midpoint rule, so will not be assessed in the course.

๐‘‡1[๐‘“,๐‘Ž,๐‘]=๐‘โˆ’๐‘Ž2(๐‘“(๐‘Ž)+๐‘“(๐‘)).

Theorem 3.1.5: The error bound for the trapezium rule is

112(๐‘โˆ’๐‘Ž)3๐ท2โ‰คerr(๐‘‡1)[๐‘“,๐‘Ž,๐‘]โ‰ค112(๐‘โˆ’๐‘Ž)3๐ท2.
Remark: The error bound is twice as big as the midpoint rule.

Definition 3.1.6: Simpsonโ€™s rule interpolates a parabola from the endpoints and midpoints. The derivation is quite complicated but the resulting formula is very simple: it is just a weighted average. Although this is over a single strip, Simpsonโ€™s rule is usually considered to operate over 2 strips, for notational consistency (as we will see later).

๐‘†2[๐‘“,๐‘Ž,๐‘]=๐‘โˆ’๐‘Ž6(๐‘“(๐‘Ž)+4๐‘“(๐‘š)+๐‘“(๐‘)).

Theorem 3.1.7: The error bound for Simpsonโ€™s rule is

12880(๐‘โˆ’๐‘Ž)5๐ท4โ‰คerr(๐‘†2)[๐‘“,๐‘Ž,๐‘]โ‰ค12880(๐‘โˆ’๐‘Ž)5๐ท4.
Remark: This error bound is much better, if ๐‘Ž and ๐‘ are close. But this error bound only applies if the function has at least 4 derivatives; otherwise, the method can still be used, but we canโ€™t bound the error in this manner.
Remark:Booleโ€™s rule gives a similar formula for interpolating a quartic polynomial, but is a bit more complicated and doesnโ€™t offer much improvement over Simpsonโ€™s rule.

Higher order Taylor approximations might not be a great choice for a better approximation because:

Higher-order polynomial interpolation also might not be a good idea:

Definition 3.1.8: The Runge function is

๐‘“(๐‘ฅ)=11+25(2๐‘ฅโˆ’1)2.

Higher-order polynomial interpolation on the Runge function, using evenly spaced points, is really bad.

A better method is just to split the interval into smaller strips and use an easier method on each of them. This is guaranteed to converge to the right answer regardless of which method you use, so long as the function is continuous.

Definition 3.1.9: The composite midpoint rule is essential just an average of all the heights of the ๐‘›+1 endpoints of ๐‘› strips, multiplied by the width of the region.

๐‘€๐‘›[๐‘“,๐‘Ž,๐‘]=๐‘โˆ’๐‘Ž๐‘›(๐‘“(๐‘ฅ0+๐‘ฅ12)+โ€ฆ+๐‘“(๐‘ฅ๐‘›โˆ’1+๐‘ฅ๐‘›2)).

Theorem 3.1.10: The error bound for the composite midpoint rule is

โˆ’(๐‘โˆ’๐‘Ž)324๐‘›2๐ท2โ‰คerr(๐‘€๐‘›)[๐‘“,๐‘Ž,๐‘]โ‰คโˆ’(๐‘โˆ’๐‘Ž)324๐‘›2๐ท2.
Remark: The main computation cost is ๐‘› evaluations of ๐‘“; the error is ๐‘‚(๐‘›โˆ’2) so this is pretty good for the amount of work we do.

Definition 3.1.11: The composite Simpsonโ€™s rule is again akin to a weighted average, now with coefficients 1,4,2,4,โ€ฆ,4,1, with the 1s and 4s as before and the 2s coming from where the endpoints are repeated.

๐‘†๐‘›[๐‘“,๐‘Ž,๐‘]=๐‘โˆ’๐‘Ž3๐‘›(๐‘“(๐‘ฅ0)+4๐‘“(๐‘ฅ1)+2๐‘“(๐‘ฅ2)+4๐‘“(๐‘ฅ3)+โ€ฆ+4๐‘“(๐‘ฅ๐‘›โˆ’1)+๐‘“(๐‘ฅ๐‘›)).

Theorem 3.1.12: The error bound for the composite Simpsonโ€™s rule is

(๐‘โˆ’๐‘Ž)5180๐‘›4๐ท4โ‰คerr(๐‘†๐‘›)[๐‘“,๐‘Ž,๐‘]โ‰ค(๐‘โˆ’๐‘Ž)5180๐‘›4๐ท4.
Remark: The main computational cost is again in evaluations of ๐‘“, this time ๐‘›+1=๐‘‚(๐‘›). But now the error bound is ๐‘‚(๐‘›โˆ’4) which is even better relative to the amount of work we do.

We can make improvements on these methods:

Also note that these methods canโ€™t help with integrals with ยฑโˆž in either of the limits.

3.2. Integration in ๐‘‘ dimensions

In two dimensions, โˆซ๐‘…๐‘“(๐‘ฅ,๐‘ฆ)d(๐‘ฅ,๐‘ฆ) is the volume under a surface in region ๐‘…โІโ„2.

Theorem 3.2.1 (Fubini's Theorem):

โˆซ๐‘…๐‘“(๐‘ฅ,๐‘ฆ)d(๐‘ฅ,๐‘ฆ)=โˆซ๐‘ฅ0๐‘ฅ1โˆซ๐‘ฆ0๐‘ฆ1๐‘“(๐‘ฅ,๐‘ฆ)d๐‘ฆd๐‘ฅ

for sufficiently nice ๐‘“ and ๐‘… (we need to be able to express the bounds nicely). This โ€œsplitโ€ integral is called an iterated integral.

This extends to higher dimensions as expected.

As long as everything is integrable, the order doesnโ€™t matter.

We can use the methods we already know to approximate higher-dimensional integrals, as long as we can split the integral into iterated integrals.

Remark: The midpoint rule can be extended to multiple dimensions by converting into an iterated integral via Fubiniโ€™s theorem, and then applying the 1-dimensional midpoint rule to successive inner integrals. For a ๐‘‘-dimensional integral ๐ผ of the function ๐‘“ over the unit hypercube, the midpoint rule with ๐‘› strips in each dimension gives

๐‘€๐‘›[๐‘“,๐ŸŽ,๐Ÿ]=1๐‘›๐‘‘โˆ‘๐‘–1=0๐‘›โ‹ฏโˆ‘๐‘–๐‘‘=0๐‘›๐‘“(2๐‘–1โˆ’12๐‘›,โ€ฆ,2๐‘–๐‘‘โˆ’12๐‘›).

This is just taking the average of the value of ๐‘“ at the midpoints of each hypercube in a grid over the region.

Remark: Simpsonโ€™s rule can also be extended to higher dimensions: for 2 dimensions,

๐‘†๐‘›[๐‘“,๐ŸŽ,๐Ÿ]=19๐‘›2โˆ‘๐‘–=0๐‘›+1โˆ‘๐‘—=0๐‘›+1๐‘ค๐‘–๐‘—๐‘“(๐‘–๐‘›+1,๐‘—๐‘›+1)

where

๐–=(1424โ‹ฏ41416816โ‹ฏ1642848โ‹ฏ82416816โ‹ฏ164โ‹ฎโ‹ฎโ‹ฎโ‹ฎโ‹ฑโ‹ฎโ‹ฎ416816โ‹ฏ1641424โ‹ฏ41).

Remark: In ๐‘‘ dimensions,

err(๐‘€๐‘›)[๐‘“,๐‘…]=๐‘‚(๐‘‘๐‘›โˆ’2)err(๐‘†๐‘›)[๐‘“,๐‘…]=๐‘‚(๐‘‘๐‘›โˆ’4).

This seems quite good, but we do ๐‘‚(๐‘›๐‘‘) evaluations of the function; so relative to the work, the error becomes steadily worse.

This is called the โ€œcurse of dimensionalityโ€โ€ฆ all of these methods improve extremely slowly in high dimensions.

Definition 3.2.2: Monte Carlo integration does the midpoint rule, but using random points according to some distribution.

Consider sampling random points along a scalar function:

๐‘‹โˆผUnif[๐‘Ž,๐‘](i.e. p.d.f ๐‘(๐‘ฅ)=1๐‘โˆ’๐‘Žfor๐‘ฅโˆˆ[๐‘Ž,๐‘],0otherwise).Note that๐”ผ[๐‘“(๐‘‹)]=โˆซโˆ’โˆžโˆž๐‘“(๐‘ฅ)๐‘(๐‘ฅ)d๐‘ฅ=1๐‘โˆ’๐‘Žโˆซ๐‘Ž๐‘๐‘“(๐‘ฅ)d๐‘ฅ,and also thatlim๐‘โ†’โˆž[1๐‘โˆ‘๐‘–=1๐‘๐‘“(๐‘ฅ๐‘–)]=๐”ผ[๐‘“(๐‘‹)].

Therefore, given ๐‘‹1,โ€ฆ,๐‘‹๐‘ i.i.d. according to Unif[๐‘Ž,๐‘], for large enough ๐‘,

โˆซ๐‘Ž๐‘๐‘“(๐‘ฅ)d๐‘ฅโ‰ˆ๐‘โˆ’๐‘Ž๐‘โˆ‘๐‘–=1๐‘๐‘“(๐‘‹๐‘–).

We extend this to ๐‘‘ dimensions, using the notation

๐‘€๐ถ๐‘[๐‘“,๐‘…]โ‰”๐ด(๐‘…)1๐‘โˆ‘๐‘–=1๐‘๐‘“(๐‘ฟ๐’Š)

for large ๐‘ to approximate โˆซ๐‘…๐‘“(๐’™)d๐’™, with ๐‘ฟ1,โ€ฆ,๐‘ฟ๐‘ i.i.d. uniformly distributed across the region ๐‘…, and ๐ด(๐‘…) the area of the region ๐‘….

Remark: This is called Monte Carlo integration because it is a Monte Carlo algorithm; the answer is random.
Remark: This is in contrast to Las Vegas algorithms, which have random running time but nonrandom answer.

Lemma 3.2.3:

Monte Carlo integration is unbiased (on average it is correct).

Proof: Take ๐‘ฟ๐Ÿ,โ€ฆ,๐‘ฟ๐‘ต i.i.d. with pdf

๐‘(๐’™)={1๐ด(๐‘…)for๐’™โˆˆ๐‘…,0otherwise.

Then

๐”ผ[๐‘€๐ถ๐‘[๐‘“,๐‘…]]=๐”ผ[๐ด(๐‘…)1๐‘โˆ‘๐‘–=1๐‘๐‘“(๐‘ฟ๐’Š)]=๐ด(๐‘…)๐‘โˆ‘๐‘–=1๐‘๐”ผ[๐‘“(๐‘ฟ๐’Š)]by linearity of expectation=๐ด(๐‘…)๐‘โˆ‘๐‘–=1๐‘โˆซ๐‘…๐‘“(๐’™)๐ด(๐‘…)d๐’™=โˆซ๐‘…๐‘“(๐’™)d๐’™.

Proposition 3.2.4:

Var(๐‘€๐ถ๐‘[๐‘“,๐‘…])=๐‘‰๐‘

for a constant ๐‘‰. Moreover, ๐‘‰ can be approximated by ๐‘‰ฬ‚ that can be expressed in terms of ๐ด(๐‘…), ๐‘, and the ๐‘“(๐‘ฟ๐’Š)s.

Proof:

Var(๐‘€๐ถ๐‘[๐‘“,๐‘…])=Var(๐ด(๐‘…)1๐‘โˆ‘๐‘“(๐‘ฟ๐’Š))=๐ด(๐‘…)2๐‘2Var(โˆ‘๐‘“(๐‘ฟ๐’Š))=๐ด(๐‘…)2๐‘2โˆ‘Var(๐‘“(๐‘ฟ๐’Š))because๐‘‹๐‘–s indep because๐‘ฟ๐’Šs i.i.d.=๐ด(๐‘…)2๐‘Var(๐‘“(๐‘ฟ๐’Š))because all variances equal because๐‘ฟ๐’Šs i.i.d.=๐‘‰๐‘with๐‘‰โ‰”๐ด(๐‘…)2Var(๐‘“(๐‘ฟ๐’Š)).
๐‘‰=๐ด(๐‘…)2Var(๐‘“(๐’™))=๐ด(๐‘…)2(๐”ผ[๐‘“(๐‘ฟ๐’Š)2]โˆ’๐”ผ[๐‘“(๐‘ฟ๐’Š)]2)=๐ด(๐‘…)2(โˆซ๐‘…๐‘“(๐’™)2๐ด(๐‘…)d๐’™โˆ’(โˆซ๐‘…๐‘“(๐’™)๐ด(๐‘…)d๐’™)2)โ‰ˆ๐ด(๐‘…)2๐‘โˆ‘๐‘–๐‘“2(๐‘ฟ๐’Š)โˆ’(๐ด(๐‘…)๐‘โˆ‘๐‘–๐‘“(๐‘ฟ๐’Š))2โ‰•๐‘‰ฬ‚.

Definition 3.2.5: The standard error is the square root of the estimated variance,

SE=๐‘‰ฬ‚๐‘=๐‘‚(๐‘โˆ’12)
Remark: This all looks quite bad, but none of it is dependent on the dimension, so this is actually quite good! The goodness of the algorithm only depends on the area of the region we are integrating over, and the โ€œwigglinessโ€ of the function.

Lemma 3.2.6:

Monte Carlo integration is consistent:

โ„™(|err(๐‘€๐ถ๐‘)[๐‘“,๐‘…]|โ‰ฅ๐œ€)โ†’๐‘โ†’โˆž0 โˆ€๐œ€.

Proof: Let ๐‘Œ=๐‘€๐ถ๐‘[๐‘“,๐‘…].

Then

๐”ผ[๐‘Œ]=โˆซ๐‘…๐‘“(๐’™)d๐’™,Var(๐‘Œ)=๐‘‰๐‘for some๐‘‰โˆˆโ„.

Then by Chebyshevโ€™s inequality,

โ„™(|๐‘Œโˆ’๐”ผ[๐‘Œ]|โ‰ฅ๐‘)โ‰ค๐‘‰๐‘๐‘2โ†’๐‘โ†’โˆž0

Theorem 3.2.7 (Central Limit Theorem): If ๐‘Œ1,..,๐‘Œ๐‘ i.i.d., then

๐”ผ[๐‘Œ]=๐œ‡โˆงVar(๐‘Œ)=๐œŽ2>0โŸน1๐‘โˆ‘๐‘–=1๐‘๐‘Œ๐‘–โ†’๐‘(๐œ‡,๐œŽ2๐‘)

(This is not a precise statement.)

That is, a large sample of i.i.d. random variables tends to a normal distribution.

Lemma 3.2.8:

For large ๐‘, the error is distributed approximately according to ๐‘(0,๐‘‰ฬ‚๐‘).

Proof:

Let๐‘Œ๐‘–=๐‘“(๐‘ฟ๐’Š)๐ด(๐‘…)โˆ’โˆซ๐‘…๐‘“(๐’™)d๐’™=err(๐‘€๐ถ1)[๐‘“,๐‘…].

Then ๐”ผ[๐‘Œ๐‘–]=0 and Var(๐‘Œ๐‘–)=๐‘‰1โ‰ˆ๐‘‰ฬ‚.

Then

err(๐‘€๐ถ๐‘)[๐‘“,๐‘…]=1๐‘โˆ‘๐‘–๐‘Œ๐‘–โŸถ๐‘(0,๐‘‰๐‘)by the central limit theoremโ‰ˆ๐‘(0,๐‘‰ฬ‚๐‘)byLemmaย 3.2.6.

Corollary 3.2.9: The error of Monte Carlo integration is within 1 standard error about 68% of the time; within 2 standard errors 95% of the time; and within 3 standard error about 99.7% of the time.

Remark:

  • There is no guarantee on the error (you could get really unlucky)
  • Sampling even from strangely shaped regions is actually easy - just sample from a tight box around it, and reject any samples that are outside the region
  • This sampling technique could be quite time consuming in higher dimensions
  • Finding the area of the region could be quite difficult - but we can estimate it by considering the size of the sampling box and also how many samples were rejected. (Note that this is also a Monte Carlo integral! of the function {[1,๐‘ฅโˆˆ๐‘…][0,๐‘ฅโˆ‰๐‘…]). We therefore need to adjust the standard error.

Remark: Some improvements we could make:

  • Divide ๐‘… into subregions, perhaps recursively (stratified sampling)
  • Sample some parts of ๐‘… more densely, using the pdf of ๐‘ฟ๐’Š as ๐‘”, then

    ๐‘€๐ถ๐‘[๐‘“,๐‘…]=1๐‘โˆ‘๐‘–๐‘“(๐‘ฟ๐’Š)๐‘”(๐‘ฟ๐’Š)
    (importance sampling)
  • Subtract an easy integral (a control variate) to make the Monte Carlo integral smaller, so that the error is smaller

These donโ€™t change the asymptotic error, but can give a better constant term.

4. Accuracy

Definition 4.1: Approximating ๐‘ข by ๐‘ขฬƒ,

  • ๐‘ขฬƒโˆ’๐‘ข is the error
  • |๐‘ขฬƒโˆ’๐‘ข| is the absolute error
  • |๐‘ขฬƒโˆ’๐‘ข||๐‘ข| is the relative error.

For vector ๐’–, replace |โˆ—| with the Euclidean norm โ€–โˆ—โ€–.

Definition 4.2: If ๐‘“(๐‘ฅ) is an ideal function of ๐‘ฅ, and ๐‘“ฬ‚(๐‘ฅ) is an approximate implementation of ๐‘“, then

  • ๐‘“ฬ‚(๐‘ฅ)โˆ’๐‘“(๐‘ฅ) is the forward error
  • ๐‘ฅฬƒโˆ’๐‘ฅ is the backward error, where ๐‘“ฬ‚(๐‘ฅ)=๐‘“(๐‘ฅฬƒ).

Definition 4.3: A floating-point number is a binary rational approximation to real numbers:

๐‘ฅฬƒ=ยฑ(1+๐‘š2๐‘)โ‹…2๐‘’

where ๐‘š is the mantissa, ๐‘ is the fixed precision (of the mantissa), and ๐‘’ is the exponent.

The IEEE 754 standard specifies:

  • single precision floats: 23 bit mantissa precision, 8 bit exponent, 1 sign bit
  • double precision: 52 bit mantissa precision, 11 bit exponent, 1 sign bit

Definition 4.4: Machine epsilon is the ๐œ€ such that every ๐‘ฅโˆˆโ„ is representable with a relative error of no more than ๐œ€.

Note that ๐œ€ is the relative error when we try to represent

๐‘ฅ=1.000โ€ฆ0โž๐‘times12โ‹…2๐‘’

for any representable exponent ๐‘’.

Then

๐œ€=|1โ‹…2๐‘’โˆ’1.000โ€ฆ0โž๐‘times12โ‹…2๐‘’||1.000โ€ฆ1โ‹…2๐‘’|=|2โˆ’(๐‘+1)||1.000โ€ฆ1|โ‰ˆ2โˆ’(๐‘+1).

Machine epsilon is therefore 2โˆ’24 for floats, and 2โˆ’53 for doubles.

Some people define ๐œ€ to be the smallest ๐œ€ such that 1+๐œ€ is representable. This is double the definition used here.

Remark: Every ๐‘ฅโˆˆโ„ can be represented as a floating point number with relative error no more than ๐œ€.
Remark: If the result of a computation is orders of magnitude smaller than the inputs, we can get โ€œcatastrophic cancellationโ€ leading to very large relative errors. E.g. subtraction of close numbers can round really badly for large inputs.

Definition 4.5: Truncation error occurs when approximating an infinite process by a finite process.

Roundoff error is due to floating-point storage and computation.

4.1. Iterative methods

Definition 4.1.1: Starting with an initial estimate ๐‘ฅ0 approximating unknown ๐‘ฅโˆ—, we repeatedly refine it with ๐‘ฅ๐‘›+1=๐‘“(๐‘ฅ๐‘›), stopping when some criterion is met, e.g. |๐‘ฅ๐‘›+1โˆ’๐‘ฅ๐‘›| < delta.

The error at step ๐‘› is ๐œ€๐‘›=๐‘ฅ๐‘›โˆ’๐‘ฅโˆ—.

If ๐œ€๐‘›โ†’0 as ๐‘›โ†’โˆž:

  • ๐‘ฅ๐‘› has linear convergence if for some 0<๐‘Ž<1,

    |๐œ€๐‘›+1||๐œ€๐‘›|โ†’๐‘Ž
  • ๐‘ฅ๐‘› has sublinear convergence if

    |๐œ€๐‘›+1|๐œ€(๐‘›)||โ†’1
    • in particular ๐‘ฅ๐‘› has logarithmic convergence if

      |๐œ€๐‘›+2โˆ’๐œ€๐‘›+1||๐œ€๐‘›+1โˆ’๐œ€๐‘›|โ†’1
  • ๐‘ฅ๐‘› converges superlinearly if

    |๐œ€๐‘›+1||๐œ€๐‘›|โ†’0
    • in particular ๐‘ฅ๐‘› has order-๐‘ž convergence for ๐‘žโ‰ฅ1 if

      |๐œ€๐‘›+1||๐‘›|๐‘žโ†’๐‘Ž
      for some ๐‘Ž>0
Remark: Linear convergence is called that not because the error is ๐‘‚(๐‘›), but because the amount of work you need to do to get an extra decimal place is constant, i.e. on a log plot we get a straight line.

Example:

  • ๐œ€๐‘›=2โˆ’๐‘› converges linearly
  • ๐œ€๐‘›=1๐‘›๐‘˜ converges logarithmically (a straight line on a log-log graph)
  • ๐œ€๐‘›=2โˆ’2๐‘› converges superlinearly, and in fact converges quadratically. On a log plot, this is an inverted parabola.
Remark: This can all be extended to vectors easily, by replacing |โˆ—| with โ€–โˆ—โ€–.
Remark: Before finding how quickly an iterative method converges, first determine if it converges at all: assume that it does converge, and show it converges to the right thing, then find an expression for ๐œ€๐‘›+1 in terms of ๐œ€๐‘›, then in terms of ๐œ€0 with induction, and show that that tends to 0.

Lemma 4.1.2: If ๐‘ฅ๐‘› converges with order ๐‘ž, then ๐‘ฅ2๐‘› converges with order ๐‘ž2.

Proof: If |๐œ€๐‘›+1||๐œ€๐‘›|๐‘žโ†’๐‘Ž for ๐‘Ž>0, then

|๐œ€2(๐‘›+1)||๐œ€2๐‘›|๐‘ž2=|๐œ€2๐‘›+2||๐œ€2๐‘›+1|๐‘ž(|๐œ€2๐‘›+1||๐œ€2๐‘›|๐‘ž)๐‘žโ†’๐‘Ž๐‘ž+1,
with ๐‘Ž๐‘ž+1>0.

5. Algorithms for root-finding

5.1. 1-dimensional root-finding

Definition 5.1.1: A root of ๐‘“:โ„โ†’โ„ is ๐‘ฅโˆ— with ๐‘“(๐‘ฅโˆ—)=0.

Definition 5.1.2: A bracket is an interval (๐‘Ž0,๐‘0) with

๐‘“(๐‘Ž0)๐‘“(๐‘0)<0.
Theorem 5.1.3: If ๐‘“ is continuous, every bracket contains at least one root.
Remark: This does not hold in higher dimensions.

Remark: We can effectively use binary search to find roots using brackets. However, we might not find an exact zero (because floating point), so we terminate when the interval is small enough, guess ๐‘ฅโˆ— is the midpoint of the interval, and can bound ๐‘ฅโˆ— by the bracket.

This is called interval bisection.

Iterating, we get a sequence ๐‘ฅ0,๐‘ฅ1,โ€ฆ with

|๐œ€๐‘›|<|๐‘0โˆ’๐‘Ž0|2๐‘›+1

so this method converges linearly.

Definition 5.1.4: Newtonโ€™s method in 1 dimension approximates ๐‘“ by its first-order Taylor polynomial.

๐‘“ฬ‚(๐‘ฅ)=๐‘“(๐‘ฅ0)+(๐‘ฅโˆ’๐‘ฅ0)d๐‘“d๐‘ฅ(๐‘ฅ0).

Take a guess ๐‘ฅ0, then find the root of the first-order Taylor polynomial at ๐‘ฅ0; this is ๐‘ฅ1, i.e.

0=๐‘“(๐‘ฅ๐‘›)+(๐‘ฅ๐‘›+1โˆ’๐‘ฅ๐‘›)d๐‘“d๐‘ฅ(๐‘ฅ๐‘›)โŸน๐‘ฅ๐‘›+1=๐‘ฅ๐‘›โˆ’๐‘“(๐‘ฅ๐‘›)d๐‘“d๐‘ฅ(๐‘ฅ๐‘›).

This converges quadratically for some ๐‘ฅ0. We can also get stuck at a fixed point, or hit a turning point and divide by zero, or diverge.

Remark: Some limitations of Newtonโ€™s method:

  • you need to be able to evaluate the derivative
  • fails if d๐‘“d๐‘ฅ(๐‘ฅ๐‘›)=0 (throw an error)
  • iteration can get stuck in a loop
  • iteration can diverge

Theorem 5.1.5: The forward error estimate for Newtonโ€™s method is

|๐‘ฅโˆ—โˆ’๐‘ฅ๐‘›|โ‰ˆ|๐‘ฅ๐‘›+1โˆ’๐‘ฅ๐‘›|.

Proof:

๐‘“ฬ‚(๐‘ฅโˆ—)=๐‘“(๐‘ฅ๐‘›)+(๐‘ฅโˆ—โˆ’๐‘ฅ๐‘›)d๐‘“d๐‘ฅ(๐‘ฅ๐‘›)โ‰ˆ0for root๐‘ฅโˆ—.โˆด|๐‘ฅ๐‘›โˆ’๐‘ฅโˆ—|โ‰ˆ|๐‘“(๐‘ฅ๐‘›)d๐‘“d๐‘ฅ(๐‘ฅ๐‘›)|=|๐‘ฅ๐‘›+1โˆ’๐‘ฅ๐‘›|by the definition of๐‘ฅ๐‘›+1.

Remark: So we might choose to terminate when successive iterations are sufficiently close, by some parameter ๐‘ก๐‘œ๐‘™, often 2๐œ€ or 4๐œ€, preferably by some relative error.

We can also look at backward error, |๐‘“(๐‘ฅ๐‘›)|<๐‘ก๐‘œ๐‘™.

Thereโ€™s no one best way of doing a stopping condition, you should think about it.

Remark: You also must stop at a sensible upper bound of steps so you donโ€™t get stuck in an infinite loop (ideally with a warning that convergence didnโ€™t happen).

You must also stop if an iteration step is poorly defined.

Lemma 5.1.6:

Let ๐ผ๐‘=(๐‘ฅโˆ—โˆ’๐‘,๐‘ฅโˆ—+๐‘) for some ๐‘โˆˆโ„.

Let

๐ด(๐‘)=max๐›ฝโˆˆ๐ผ๐‘|d2๐‘“d๐‘ฅ2(๐›ฝ)|min๐›ผโˆˆ๐ผ๐‘|d๐‘“d๐‘ฅ(๐›ผ)|.

Then if ๐‘ฅ๐‘›โˆˆ๐ผ๐‘, then |๐œ€๐‘›+1|โ‰ค๐ด(๐‘)2๐œ€๐‘›2.

Proof:

Suppose ๐‘ฅ๐‘›โˆˆ๐ผ๐‘.

|๐œ€๐‘›+1|=|๐‘ฅ๐‘›+1โˆ’๐‘ฅโˆ—|=|๐‘ฅ๐‘›โˆ’๐‘“(๐‘ฅ๐‘›)๐‘“โ€ฒ(๐‘ฅ๐‘›)โˆ’๐‘ฅโˆ—|=|(๐‘ฅ๐‘›โˆ’๐‘ฅโˆ—)๐‘“โ€ฒ(๐‘ฅ๐‘›)โˆ’๐‘“(๐‘ฅ๐‘›)๐‘“โ€ฒ(๐‘ฅ๐‘›)|=|(๐‘“(๐‘ฅโˆ—)โˆ’(๐‘“(๐‘ฅ๐‘›)+(๐‘ฅโˆ—โˆ’๐‘ฅ๐‘›)๐‘“โ€ฒ(๐‘ฅ๐‘›)))||(๐‘“โ€ฒ(๐‘ฅ๐‘›))|because๐‘“(๐‘ฅโˆ—)=0=|12(๐‘ฅ๐‘›โˆ’๐‘ฅโˆ—)2๐‘“โ€ณ(๐œ‰)||๐‘“โ€ฒ(๐‘ฅ๐‘›)|for some๐œ‰โˆˆ(๐‘ฅโˆ—,๐‘ฅ๐‘›),by Taylor's theorem=12๐œ€๐‘›2|๐‘“โ€ณ(๐œ‰)||๐‘“โ€ฒ(๐‘ฅ๐‘›)|โ‰ค๐ด(๐‘)2๐œ€๐‘›2.

Lemma 5.1.7:

For ๐ด(๐‘),๐ผ๐‘ as before, if ๐‘ฅ0โˆˆ๐ผ๐‘ and ๐‘๐ด(๐‘)2<1 then ๐‘ฅ๐‘› converges to ๐‘ฅโˆ— at least quadratically.

Proof:

Suppose ๐‘๐ด(๐‘)2<1 and that ๐‘ฅ๐‘›โˆˆ๐ผ๐‘ as before. Note that |๐œ€๐‘›|<๐‘ from the definition of ๐ผ.

|๐œ€๐‘›+1|โ‰ค๐ด(๐‘)2๐œ€๐‘›2fromLemmaย 5.1.6=|๐œ€๐‘›||๐œ€๐‘›|๐ด(๐‘)2โ‰ค|๐œ€๐‘›|because|๐œ€๐‘›|๐ด(๐‘)2<๐‘๐ด(๐‘)2<1by suppositionโˆด๐‘ฅ๐‘›+1โˆˆ๐ผ.

Then letting ๐œŒ=|๐œ€๐‘›|๐ด(๐‘)2, by induction, ๐‘ฅ๐‘›โˆˆ๐ผ for all ๐‘›, and |๐œ€๐‘›|โ‰ค๐œŒ๐‘›|๐‘ฅ0|. ๐œŒ<1 so |๐œ€๐‘›|โ†’0 as ๐‘›โ†’โˆž.

Therefore ๐‘ฅ๐‘›โ†’๐‘ฅโˆ—.

Moreover,

|๐œ€๐‘›+1||๐œ€๐‘›|2โ‰ค๐ด(๐‘)2,

so we have at least quadratic convergence (it might be better if it actually tends to 0; we donโ€™t have equality).

Remark: The important thing here is that we have proven that the ๐‘ฅ๐‘›s stay within ๐ผ๐‘.
Remark: The condition on ๐‘ here, ๐‘๐ด(๐‘)2<1, is a sufficient condition for ๐ผ๐‘ to be a basin of convergence.

Lemma 5.1.8: Let ๐ฝ๐‘=(๐‘ฅ0โˆ’๐‘,๐‘ฅ0+๐‘), and let

๐ต(๐‘)=max๐›ฝโˆˆ๐ฝ๐‘|d2๐‘“d๐‘ฅ2(๐›ฝ)|min๐›ผโˆˆ๐ฝ๐‘|d๐‘“d๐‘ฅ(๐›ผ)|.

Then if ๐‘ฅโˆ—โˆˆ๐ฝ๐‘ and ๐‘๐ต(๐‘)2<1, then ๐‘ฅ๐‘›โ†’๐‘ฅโˆ— quadratically.

Proof:

Suppose that ๐‘ฅโˆ—โˆˆ๐ฝ๐‘ and ๐‘๐ต(๐‘)2<1.

From Lemmaย 5.1.6,

|๐œ€๐‘›+1|โ‰ค๐œ€๐‘›2๐ด(๐‘)2<|๐œ€๐‘›|,

because the interval contained within ๐ฝ๐‘ with ๐‘ฅโˆ— at its centre, ๐ผ๐‘‘, must have ๐‘‘โ‰ค๐‘, so ๐ด(๐‘‘)โ‰ค๐ด(๐‘).

Note that although we cannot guarantee that ๐‘ฅ๐‘› stays within ๐ฝ๐‘,we can guarantee that it stays in ๐ฝ2๐‘, if ๐‘๐ต(๐‘)2<1, by the same reasoning as Lemmaย 5.1.7.

TODO make this a bit nicer from lecture notes

Remark: We might find such an ๐‘ฅ0,๐‘ by finding a suitable bracket.

Theorem 5.1.9: There exists an ๐‘ฅ0,๐‘ such that ๐ฝ๐‘ is a basin of convergence if d๐‘“d๐‘ฅ(๐‘ฅโˆ—)โ‰ 0.

Proof: Given a bracket containing (๐‘ฅโˆ—โˆ’๐‘,๐‘ฅโˆ—+๐‘), we can shrink the interval down such that ๐ด(๐‘)โ†’๐‘“โ€ณ(๐‘ฅโˆ—)๐‘“โ€ฒ(๐‘ฅโˆ—). If ๐‘“โ€ฒ(๐‘ฅโˆ—)โ‰ 0, then this is finite and we can find small ๐‘ such that 12๐‘๐ด(๐‘)<1; the same is true for ๐ต(๐‘).

Remark: The convergence result doesnโ€™t work for double roots (it might still converge, but only linearly).

We can fix it by using the iteration ๐‘ฅ๐‘›+1=๐‘ฅ๐‘›โˆ’2๐‘“(๐‘ฅ๐‘›)๐‘“โ€ฒ(๐‘ฅ๐‘›), which will converge quadratically to double roots.

Definition 5.1.10: The secant method uses a linear interpolation to approximate ๐‘“.

๐‘ฅ๐‘›+2=๐‘ฅ๐‘›+1โˆ’๐‘“(๐‘ฅ๐‘›+1)(๐‘ฅ๐‘›+1โˆ’๐‘ฅ๐‘›)๐‘“(๐‘ฅ๐‘›+1)โˆ’๐‘“(๐‘ฅ๐‘›).
Remark: This is a โ€œquasi-Newton methodโ€, where we use an estimate for the derivative.
Remark: This only needs one evaluation of ๐‘“ at each iteration.
Remark: This can converge superlinearly, in fact order-๐œ™ in good cases. (proof: exercise)
Remark: In theory this can diverge or get stuck in a loop, but it is more stable than Newtonโ€™s method, because it relies on the previous 2 iterations.

TODO forward error (same as Newton)

Remark: We should be able to do two iterations of the secant method for no more than the cost of 1 iteration of Newtonโ€™s method, which would converge with order โ‰ˆ2.6. This is also nice because we just donโ€™t want to evaluate the derivative of ๐‘“.

Remark: Some other 1-dimensional root finding methods:

  • Halleyโ€™s method - higher order Taylor approximation. But difficult because we might end up with no roots or many roots. But cubic convergence in good cases.
  • Mullerโ€™s method - higher order polynomial interpolation - same problems as Halleyโ€™s method, but no derivatives needed and order โ‰ˆ1.84 when it works
  • Inverse quadratic interpolation, i.e. find ๐‘ฅ=๐‘Ž๐‘ฆ2+๐‘๐‘ฆ+๐‘, and the root is at ๐‘ (always!). Order โ‰ˆ1.84 convergence in good cases.

But the best method is Brentโ€™s method:

  • maintains a bracket
  • uses inverse quadratic interpolation unless iteration undefined or outside the bracket
  • uses the secant method as second choice
  • falls back to bisection if these do not sufficiently shrink the bracket (only happens at at most half of iterations)
  • derivative free
  • always converges, at order โ‰ˆ1.84 in good cases.

5.2. ๐‘‘-dimensional root finding

Definition 5.2.1: A root of ๐’‡:โ„๐‘‘โ†’โ„๐‘˜ is ๐‘ฟโˆ— with ๐’‡(๐‘ฟโˆ—)=๐ŸŽ.

If ๐‘˜<๐‘‘, the problem is underconstrained, so there are probably infinitely many solutions.

If ๐‘˜>๐‘‘, the problem is unconstrained, so there are probably no (exact) solutions.

We will consider ๐‘˜=๐‘‘.

Remark: There isnโ€™t really such a thing as a bracket in higher dimensions, because although we might have roots of components, we might not find simultaneous roots of these.

Remark: If instead we take a hyperrectangle with a bracket for components on opposite sides, then we can guarantee a simultaneous root.

TODO diagram

But this is not very useful, because we canโ€™t algorithmically prove tha a function is positive/negative all the way along a line.

Remark: For higher-dimensional iterative methods, the sensible termination conditions are the same as they were in one dimension, but with norms rather than absolute value, and a tolerance parameter should probably rely on ๐‘‘.

Definition 5.2.2: Newtonโ€™s method for ๐‘‘-dimensional root-finding can be derived as follows.

Given ๐’‡:โ„๐‘‘โ†’โ„๐‘‘,๐’‡(๐’™)=(๐‘“1(๐’™)โ€ฆ๐‘“๐‘‘(๐’™)), we approximate each component by its first-order Taylor polynomial:

๐‘“ฬ‚๐‘–(๐’™)=๐‘“๐‘–(๐’™๐ŸŽ)+(d๐‘“๐‘–d๐’™(๐’™๐ŸŽ))โŠค(๐’™โˆ’๐’™๐ŸŽ).

Then we want to find roots of all of these approximations:

0=๐‘“๐‘–(๐’™๐ŸŽ)+(d๐‘“๐‘–d๐’™(๐’™๐ŸŽ))โŠค(๐’™โˆ’๐’™๐ŸŽ)โŸน(d๐‘“๐‘–d๐’™(๐’™๐ŸŽ))โŠค(๐’™โˆ’๐’™๐ŸŽ)=โˆ’๐‘“๐‘–(๐’™๐ŸŽ).

We can put all of these together to get

๐‰(๐’‡)(๐’™๐ŸŽ)(๐’™โˆ’๐’™๐ŸŽ)=โˆ’๐’‡(๐’™๐ŸŽ).

So we get an iteration

๐’™๐‘›+1=๐’™๐‘›โˆ’๐‰(๐’‡)(๐’™๐‘›)โˆ’1๐’‡(๐’™๐‘›).

Each iteration, this requires 1 evaluation of ๐‘“, ๐‘‘2 derivative, and an inversion, which is ๐‘‚(๐‘‘3).

However note that actually just solving the first equation with the Jacobian, rather than inverting it, is a constant factor quicker.

Remark: This is not the curse of dimensionality; it only blows up polynomially with ๐‘‘, not exponentially.

Remark: We still have existence of a basin of quadratic convergence, if:

  • ๐’‡,๐‰(๐’‡),๐œ•2๐‘“๐‘–๐œ•๐‘ฅ๐‘—๐œ•๐‘ฅ๐‘˜ are continuous
  • ๐‰(๐’‡) is nonsingular at ๐’™โˆ—

Remark: In order to globalise Newtonโ€™s method so that it works everywhere, we should enforce that if โ€–๐’‡(๐’™๐‘›+1)โ€–<โ€–๐’‡(๐’™๐‘›)โ€–, we should backtrack by setting ๐’™๐’+๐Ÿ=๐’™๐’+๐œ†ฮ”๐’™, where ฮ”๐’™ is the (๐’™โˆ’๐’™๐ŸŽ) that is solved at each step, for some ๐œ†โˆˆ(0,1).

Suitably small ๐œ† guarantees linear convergence everywhere, and this is called a damped Newtonโ€™s method.

Definition 5.2.3: In ๐‘‘ dimensions, the equivalent to the secant method is Broydenโ€™s method. On each step we use an approximation for the Jacobian, ๐‰ฬ‚๐‘›.

We would like for ๐‘“(๐’™๐’)=๐‘“(๐’™๐’โˆ’๐Ÿ)+๐‰ฬ‚๐‘›(๐’™๐‘›โˆ’๐’™๐’+๐Ÿ), but we cannot solve for ๐‰ฬ‚๐‘› because it is an underdetermined system.

We can notice that our desired relation doesnโ€™t tell us anything about the relation between ๐‰ฬ‚๐‘› and vector ๐‘ง that is orthogonal to (๐’™๐’โˆ’๐’™๐’โˆ’๐Ÿ); we could therefore choose that consecutive ๐‰ฬ‚๐‘›s should behave in the same manner for such vectors, i.e.

๐‰ฬ‚๐‘›๐’›=๐‰ฬ‚๐‘›โˆ’1๐’›,for๐’›โŠค(๐’™๐’โˆ’๐’™๐’โˆ’๐Ÿ)=0.

We now have enough constraints to find ๐‰ฬ‚๐‘›, provided we have an initial ๐‰ฬ‚0, which we could either calculate as ๐‰(๐‘“)(๐’™๐ŸŽ), or set to โˆ’๐ˆ, or a multiple of.

Equivalently, we could aim to minimise the norm of the difference between consecutive Jacobian estimates, which makes sense because close to the root, they should be similar.

Then, writing ๐šซ๐’™=๐’™๐’โˆ’๐’™๐’โˆ’๐Ÿ,

๐‰ฬ‚๐‘›=๐‰ฬ‚๐‘›โˆ’1+(๐‘“(๐’™๐’)โˆ’๐‘“(๐’™๐’โˆ’๐Ÿ))โˆ’๐‰ฬ‚๐‘›๐šซ๐’™โ€–๐šซ๐’™โ€–2๐šซ๐’™โŠค.

This step has complexity ๐‘‚(๐‘‘2) because the most we do is matrix-vector multiplication.

Then the iteration is

๐’™๐’+๐Ÿ=๐’™๐’+๐šซ๐’™,where๐‰ฬ‚๐‘›๐šซ๐’™=โˆ’๐‘“(๐’™๐’).

This step still requires ๐‘‚(๐‘‘3) to solve the system, so overall each iteration is ๐‘‚(๐‘‘3).

The convergence is order ๐‘ž>1 in good cases.

Theorem 5.2.4:

(๐€+๐’–๐’—โŠค)โˆ’1=TODO
Proof: Exercise

Remark: This means that we can start from ๐‰ฬ‚0โˆ’1 and never need to calculate any inverses.

This gives ๐‘‚(๐‘‘2) for Broydenโ€™s method.

6. Algorithms for optimisation

6.1. 1-dimensional minimisation

Remark: If we can show that a function is convex, we can use a root finding algorithm to find the minimum. We can find a bracket for the minimum by finding a bracket for a root of the derivative (but for a minimum it;s got to be negative on the left and positive on the right).

Definition 6.1.1: We can find a bracket for a minimum without evaluating the derivative: if there is ๐‘Ž<๐‘ง<๐‘ s.t. ๐‘“(๐‘ง)<๐‘“(๐‘Ž),๐‘“(๐‘ง)<๐‘“(๐‘), then (๐‘Ž,๐‘) is a bracket containing the minimum.

We can make an algorithm for reducing the bracket, by keeping track of the middle value and testing at a new point ๐‘งโ€ฒ, and discarding one of the endpoints. This is called golden section search.

Letโ€™s ignore the case of a tie between the middle values, and suppose w.l.o.g. that we choose ๐‘งโ€ฒโˆˆ(๐‘ง,๐‘) (we want to choose from the larger side of the bracket so that we remove us much as possible, and the other case is symmetric).

The placement of ๐‘งโ€ฒ is quite important: we want ideally the same amount to be chopped off whether ๐‘งโ€ฒ>๐‘ง or not; therefore we say that ๐‘งโ€ฒโˆ’๐‘Ž=๐‘โˆ’๐‘ง.

We would also like the bracket to shrink by a constant factor each time, so we want ๐‘โˆ’๐‘งโ€ฒ=๐œ™(๐‘โˆ’๐‘ง), and also ๐‘โˆ’๐‘ง=๐œ™(๐‘โˆ’๐‘Ž).

Then

๐‘โˆ’๐‘Ž=๐‘โˆ’๐‘งโ€ฒ+๐‘งโ€ฒโˆ’๐‘ŽโŸน1๐œ™2(๐‘โˆ’๐‘งโ€ฒ)=(๐‘โˆ’๐‘งโ€ฒ)+(๐‘โˆ’๐‘ง)=(๐‘โˆ’๐‘ง)+1๐œ‘(๐‘โˆ’๐‘งโ€ฒ).

Therefore 1๐œ™2=1+1๐œ™โŸน๐œ™2+๐œ™โˆ’1=0; that is, ๐œ™ is the golden ratio, hence the name golden section search.

Proposition 6.1.2: This converges linearly.

Proof: TODO
Remark: Our termination condition should be |๐‘โˆ’๐‘Ž|โ‰ค๐‘ก๐‘œ๐‘™|๐‘ง|, where ๐‘ก๐‘œ๐‘™ should only be about ๐‘‚(๐œ€).

Definition 6.1.3: Successive parabolic interpolation carries out golden section search but by choosing ๐‘งโ€ฒ to be the minimum of the parabola passing through ๐‘Ž,๐‘ง,๐‘.

This is order โ‰ˆ1.32, but it can go wrong in many ways (exercise).

Remark: Finding a bracket isnโ€™t necessarily easy, but if the function is convex, we can use a geometrically expanding bracket to find a bracket. Even better, we can keep the golden ratio, with the geometrically expansion.

Definition 6.1.4: Brentโ€™s method for minimisation:

  • combines successive parabolic interpolation with golden section search, keeping track of 6 points
  • is derivative-free and superlinear in good cases.

6.2. ๐‘‘-dimensional minimisation

Given a position ๐’™๐’, choose direction ๐’…๐’ and step length ๐›ผ๐‘›, and set ๐’™๐’+๐Ÿ=๐’™๐’+๐›ผ๐‘›๐’…๐’.

Define ๐’ˆ๐’=d๐‘“d๐’™(๐’™๐’), with ๐’ˆ standing for gradient.

We would like ๐’…๐’ to be a descent direction:

d๐‘“(๐’™๐’+๐›ผ๐‘›๐’…๐’)d๐›ผ<0โŸน(d๐‘“d๐’™โˆ˜(๐›ผโ†ฆ๐’™๐’+๐›ผ๐’…๐’))โŠค๐‰๐›ผ(๐’™๐’+๐›ผ๐’…๐’)<0โŸนd๐‘“d๐’™(๐’™๐’+๐›ผ๐’…๐’)โŠค๐’…๐’<0โŸน๐’ˆ๐’โŠค๐’…๐’<0.

Weโ€™d also like consecutive directions shouldnโ€™t veer wildly, undoing work of previous steps; they should perhaps be roughly orthogonal, to explore the space efficiently.

๐›ผ๐‘› should loosely minimise ๐‘“(๐’™๐’+๐›ผ๐‘›๐’…๐’).

The โ€œinfinite travelโ€ condition should also be met, to avoid the process halting completely:

โˆ‘๐‘›=1โˆž๐›ผ๐‘›=โˆž.
Definition 6.2.1: Coordinate gradient descent chooses alternating basis vectors for the direction (with ๐›ผ๐‘› then chosen to be negative if it is in the wrong direction). It works, but itโ€™s not very good.

Definition 6.2.2: Gradient descent finds the steepest downhill direction:

min๐’…๐’โŠค๐’ˆ๐’s.t.1โˆ’โ€–๐’…๐‘›โ€–โ‰ฅ0.ฮ›(๐’…๐’,๐œ‡)=๐’…๐’โŠค๐’ˆ๐’โˆ’๐(1โˆ’๐’…๐’โŠค๐’…๐’)dฮ›d๐’…๐’=๐’ˆ๐’+2๐œ‡๐’…๐’=๐ŸŽโŸน๐’…=โˆ’๐’ˆ๐’2๐œ‡

So we choose ๐’…=โˆ’๐’ˆ๐’, as the scalar multiplication can be chosen by ๐›ผ๐‘›.

That is, we just go in the direction of the negative gradient; this makes sense.

To find a good step length, overshoot and backtrack (typically halving) until the step length is acceptable.

Our acceptable condition for when we can stop backtracking is

๐‘“(๐’™๐’+๐›ผ๐‘›๐’…๐’)<๐‘“(๐’™๐’)+๐œŽ๐›ผ๐‘›๐’ˆ๐’โŠค๐’…๐’.

This is called the Armijo rule. ๐œŽ is typically 0.1 to 0.0001. It says that we want the new value of the function to be below a line that is somewhere in between the 0th order and 1st order approximation to f at ๐‘ฅ๐‘›.

It can be proven that this always works if ๐œŽ<1.

We could take an initial guess for ๐›ผ๐‘› to be

๐›ผ๐‘›โˆ’1๐’ˆ๐’โˆ’๐ŸโŠค๐’…๐’โˆ’๐Ÿ๐’ˆ๐’โŠค๐’…๐’.

i.e. we suppose that an approximation for the amount of descent in this step will be the same as in the previous step. It is better to overestimate the initial ๐›ผ๐‘› than to underestimate, as backtracking is cheap.

We still need a large initial step length for step 0. We could even forward-track until we get something that doesnโ€™t meet the Armijo rule.

TODO overall iteration

TODO termination condition.

TODO complexity

TODO convergence

Definition 6.2.3: Conjugate gradient descent uses conjugate directions that satisfy ๐’…๐’๐‡๐’…๐’=0.

๐’…๐’=โˆ’๐’ˆ๐’+๐’…๐’โˆ’๐Ÿ(TODO)TODO

TODO justification, what does this mean?

Remark: Conjugate gradient descent isnโ€™t actually on the syllabus but itโ€™s useful and quite simple (only one line of code changed compared to gradient descent).

Remark: We can also use Newtonโ€™s method:

Approximate ๐‘“ by its second-order Taylor polynomial

๐‘“ฬ‚(๐’™)=๐‘“(๐’™๐ŸŽ)+(๐’™โˆ’๐’™๐ŸŽ)โŠค๐’ˆ๐ŸŽ+12(๐’™โˆ’๐’™๐ŸŽ)๐‡(๐‘“)(๐’™๐ŸŽ)(๐’™โˆ’๐’™๐ŸŽ).

Differentiating this gives

d๐‘“ฬ‚d๐’™=๐ŸŽ+๐’ˆ๐’โˆ’๐ŸŽ+๐‡0(๐’™โˆ’๐’™๐ŸŽ).

where ๐‡๐‘›=๐‡(๐‘“)(๐’™๐’).

Therefore ๐’™๐Ÿโˆ’๐’™๐ŸŽ=โˆ’๐‡0โˆ’1๐’ˆ๐ŸŽ. But remember that computing matrix inverses is slow, so better to say solve ๐‡0๐’…๐’=โˆ’๐’ˆ๐’ for ๐’…๐’.

This is like gradient descent, but with ๐’…๐’=โˆ’(๐‡(๐‘“)(๐’™๐’))โˆ’1๐’ˆ๐’ (we call this the Newton direction) and ๐›ผ๐‘›=1.

Note that this has problem-independent step length, which is nice.

However, the requirement for computing the Hessian at every iteration makes each step a lot more expensive than gradient descent.

Remark: Newtonโ€™s method doesnโ€™t always give a descent direction.

๐‘”๐‘›โŠค๐‘‘๐‘›=โˆ’๐‘”๐‘›โŠค๐ป๐‘›โˆ’1๐‘”๐‘›<0if๐ป๐‘›โˆ’1pos defโŸธ๐ป๐‘›pos def.

Therefore Newtonโ€™s method can converge to maxima or saddle points equally as much as minima.

TODO compare the two Newtonโ€™s methods (theyโ€™re the same)

Remark: We could use a quasi-Newton method whereby we use an approximation of the Hessian, e.g. by using Broydenโ€™s method on the derivative. However, this is bad because it doesnโ€™t necessarily give a symmetric approximation for the Hessian.

We want ๐‡ฬ‚๐‘›:

  • to satisfy secant equation TODO
  • to be symmetric
  • to be close to ๐‡ฬ‚๐‘›โˆ’1
  • to be positive definite.

Positive definiteness requires the curvature condition ฮ”๐’™โŠคฮ”๐’ˆ>0, which we canโ€™t always guarantee.

Definition 6.2.4: BFGS update is TODO (not in spec).

If the curvature condition fails, reset ๐‡ฬ‚๐‘›.

Best to start with ๐‡ฬ‚0=๐ˆ, and reset to the identity if the curvature condition fails. When the approximate Hessian is the identity, it is just gradient descent; so it does gradient descent until it gets to a convex section of the function, at which point it starts approximating the Hessian and goes a lot quicker.

TODO advantages

TODO disadvantages

Remark: There is a way to only update the inverse Hessians, like we did for Broydenโ€™s method. Itโ€™s a bit more complicated because this uses a rank-2 update rather than a rank-1 update.
Remark: We can make a rank-๐‘š approximation of the Hessians and get ๐‘‚(๐‘š๐‘‘) memory. We call this L-BFGS.