Mathematics Reference SeriesFoundations for Machine Learning
Reference

Introduction to
Calculus

A structured mathematical reference covering limits, derivatives, integrals, sequences, series, multivariable calculus, differentials, matrix calculus, and Taylor's theorem — extended with machine learning essentials: convexity, gradient descent, backpropagation, automatic differentiation, proximal operators, and more.

StatusOpen Reference
Sections97 Sections
NumberingA2.1 — A2.97
DomainCalculus · Real Analysis · Matrix Calculus · Optimization
PrerequisitesPrecalculus · Linear Algebra
Light
CalculusDefinitions · Theorems · Proofs — Reference
Calculus is the mathematical study of continuous change. This reference builds from first principles — limits, derivatives, integrals, and series — then extends to multivariable functions, matrix calculus, and Taylor's theorem. Sections A2.43–A2.60 cover the calculus concepts most critical to machine learning: convexity, gradient descent, backpropagation, Lagrange multipliers, automatic differentiation, and more. All formulas are rendered with MathJax.
A2.1

Limit of a Function (ε–δ Definition)

Let f : D → ℝ be a function defined on a set D ⊆ ℝ, and let a be a limit point of D. The limit of f(x) as x approaches a is L, written

\[ \lim_{x\to a} f(x) = L, \]

if for every ε > 0 there exists δ > 0 such that whenever 0 < |x − a| < δ and x ∈ D, we have |f(x) − L| < ε.

  • $\lim_{x\to a}f(x)$the limit of f at a; the value L that f(x) approaches as x → a.
  • $\varepsilon$an arbitrarily small positive tolerance on the output.
  • $\delta$a positive radius around a ensuring the output stays within ε of L.
A2.2

One-Sided Limits

The right-hand limit of f(x) as x approaches a from the right is denoted $\lim_{x\to a^+} f(x)$ and defined by restricting the ε–δ condition to x > a. Similarly, the left-hand limit $\lim_{x\to a^-} f(x)$ restricts to x < a. The two-sided limit exists if and only if both one-sided limits exist and are equal:

\[ \lim_{x\to a} f(x) = L \quad\Longleftrightarrow\quad \lim_{x\to a^-} f(x) = \lim_{x\to a^+} f(x) = L. \]
  • $\lim_{x\to a^+} f(x)$right-hand limit; x approaches a from above.
  • $\lim_{x\to a^-} f(x)$left-hand limit; x approaches a from below.
A2.3

Continuity

A function f : D → ℝ is continuous at a point a ∈ D if

\[ \lim_{x\to a} f(x) = f(a). \]

Equivalently, for every ε > 0 there exists δ > 0 such that |x − a| < δ and x ∈ D implies |f(x) − f(a)| < ε. A function is continuous on an interval if it is continuous at every point of that interval.

  • $f \in C^0(D)$the set of all continuous functions on D.
A2.4

Intermediate Value Theorem

Let f : [a, b] → ℝ be continuous on the closed interval [a, b]. If y₀ is any number between f(a) and f(b) (inclusive), then there exists at least one c ∈ [a, b] such that

\[ f(c) = y_0. \]
  • $[a, b]$a closed interval; includes both endpoints.
  • $y_0$any value between f(a) and f(b).
A2.5

Extreme Value Theorem

If f : [a, b] → ℝ is continuous on a closed and bounded interval [a, b], then f attains both a maximum and a minimum value on [a, b]. That is, there exist c, d ∈ [a, b] such that

\[ f(c) \le f(x) \le f(d) \quad\text{for all } x\in[a,b]. \]
  • $f(c)$the global minimum value of f on [a, b].
  • $f(d)$the global maximum value of f on [a, b].
A2.6

The Derivative

The derivative of a function f at a point a in its domain is the limit (if it exists):

\[ f'(a) = \lim_{h\to 0} \frac{f(a+h)-f(a)}{h}. \]

Geometrically, f'(a) is the slope of the tangent line to the graph of f at x = a.

  • $f'(a)$the derivative of f at a; also written $\frac{df}{dx}\big|_{x=a}$ or $Df(a)$.
  • $h$an infinitesimal increment; the difference quotient approaches the derivative as h → 0.
A2.7

Differentiability Implies Continuity

If f is differentiable at a, then f is continuous at a. The converse is false: continuity does not guarantee differentiability (e.g., f(x) = |x| at x = 0).

\[ f'(a)\text{ exists} \;\Longrightarrow\; \lim_{x\to a} f(x) = f(a). \]
A2.8

Basic Differentiation Rules

For differentiable functions f, g and constant c ∈ ℝ:

\[ (c f)' = c f' \qquad (f+g)' = f' + g' \qquad (f g)' = f' g + f g' \qquad \left(\frac{f}{g}\right)' = \frac{f' g - f g'}{g^2} \]
A2.9

The Chain Rule

If g is differentiable at x and f is differentiable at g(x), then h = f ∘ g is differentiable at x and

\[ h'(x) = f'(g(x)) \cdot g'(x). \]

In Leibniz notation: $\frac{dy}{dx} = \frac{dy}{du}\cdot \frac{du}{dx}$.

A2.10

Mean Value Theorem

Let f : [a, b] → ℝ be continuous on [a, b] and differentiable on (a, b). Then there exists at least one c ∈ (a, b) such that

\[ f'(c) = \frac{f(b)-f(a)}{b-a}. \]
A2.11

L'Hôpital's Rule

If $\lim_{x\to a} f(x) = \lim_{x\to a} g(x) = 0$ or both limits are ±∞, then

\[ \lim_{x\to a} \frac{f(x)}{g(x)} = \lim_{x\to a} \frac{f'(x)}{g'(x)}, \]

provided the limit on the right exists.

A2.12

Higher-Order Derivatives

The n-th derivative $f^{(n)}(x)$ is defined recursively:

\[ f^{(n)}(x) = \frac{d}{dx}\left[f^{(n-1)}(x)\right],\qquad f^{(0)}(x) = f(x). \]
  • $f \in C^n$f is n-times continuously differentiable.
  • $C^\infty$smooth functions; infinitely differentiable.
A2.13

Taylor Polynomials

The Taylor polynomial of degree n for f centred at a is

\[ T_n(x) = \sum_{k=0}^n \frac{f^{(k)}(a)}{k!}(x-a)^k. \]
  • $R_n(x)$remainder: $f(x) - T_n(x) = O(|x-a|^{n+1})$.
A2.14

The Riemann Integral

For a partition $P = \{x_0,\dots,x_n\}$ of [a, b], the Riemann sum is

\[ S(P,f) = \sum_{i=1}^{n} f(t_i) \Delta x_i,\qquad t_i \in [x_{i-1}, x_i]. \]

The Riemann integral is the limit as $\|P\| \to 0$.

A2.15

Fundamental Theorem of Calculus (Part I)

Define $F(x) = \int_a^x f(t)\,dt$. If f is continuous at c, then F is differentiable at c and

\[ F'(c) = f(c). \]
A2.16

Fundamental Theorem of Calculus (Part II)

If F is any antiderivative of f on [a, b], then

\[ \int_a^b f(x)\,dx = F(b) - F(a). \]
A2.17

Integration by Substitution

\[ \int_a^b f(g(x))\,g'(x)\,dx = \int_{g(a)}^{g(b)} f(u)\,du. \]
A2.18

Integration by Parts

\[ \int_a^b u(x) v'(x)\,dx = \big[u(x)v(x)\big]_a^b - \int_a^b u'(x) v(x)\,dx. \]
A2.19

Improper Integrals

\[ \int_a^\infty f(x)\,dx = \lim_{b\to\infty} \int_a^b f(x)\,dx. \]
A2.20

Sequences and Convergence

A sequence $(a_n)$ converges to L if

\[ \forall \varepsilon > 0,\; \exists N \in \mathbb{N}\colon n \ge N \Rightarrow |a_n - L| < \varepsilon. \]
A2.21

Infinite Series

The series $\sum_{n=1}^\infty a_n$ converges to S if $\lim_{N\to\infty} S_N = S$, where $S_N = \sum_{n=1}^N a_n$.

A2.22

Convergence Tests for Series

  • Comparison Test: $0 \le a_n \le b_n$ and $\sum b_n$ converges ⇒ $\sum a_n$ converges.
  • Ratio Test: $\rho = \lim |a_{n+1}/a_n|$; converges if $\rho < 1$, diverges if $\rho > 1$.
  • Integral Test: $\sum a_n$ converges iff $\int_1^\infty f(x)\,dx$ converges (when $f(n)=a_n$, f positive, decreasing).
A2.23

Power Series

\[ \sum_{n=0}^\infty a_n (x-c)^n,\qquad R = \frac{1}{\limsup_{n\to\infty} |a_n|^{1/n}}. \]

Converges absolutely for $|x-c| < R$, diverges for $|x-c| > R$.

A2.24

Taylor and Maclaurin Series

\[ f(x) = \sum_{n=0}^\infty \frac{f^{(n)}(c)}{n!} (x-c)^n. \]
\[ e^x = \sum_{n=0}^\infty \frac{x^n}{n!},\qquad \sin x = \sum_{n=0}^\infty \frac{(-1)^n x^{2n+1}}{(2n+1)!},\qquad \frac{1}{1-x} = \sum_{n=0}^\infty x^n \;(|x|<1). \]
A2.25

Functions of Several Variables

A function $f : \mathbb{R}^n \to \mathbb{R}$ assigns a real number to each point $x = (x_1,\dots,x_n)$. The limit $\lim_{x\to a}f(x)=L$ requires $0 < \|x-a\| < \delta \Rightarrow |f(x)-L|<\varepsilon$.

A2.26

Partial Derivatives

\[ \frac{\partial f}{\partial x_i}(a) = \lim_{h\to 0} \frac{f(a_1,\dots,a_i+h,\dots,a_n) - f(a)}{h}. \]
A2.27

Gradient and Directional Derivatives

\[ \nabla f(a) = \left( \frac{\partial f}{\partial x_1}(a),\dots,\frac{\partial f}{\partial x_n}(a) \right)^T. \]
\[ D_v f(a) = \nabla f(a) \cdot v \qquad (\|v\|=1). \]
A2.28

Multiple Integrals and Fubini's Theorem

\[ \iint_R f(x,y)\,dA = \int_a^b \left( \int_c^d f(x,y)\,dy \right) dx = \int_c^d \left( \int_a^b f(x,y)\,dx \right) dy. \]
A2.29

Segment Notation

\[ [x, y] = \{ (1-t)x + t y : 0 \le t \le 1 \}. \]
A2.30

Differential of a Vector‑Valued Function (Jacobian)

For $f : U \to \mathbb{R}^m$, the differential at x is the $m \times d$ matrix

\[ df(x) = \big[ \partial_1 f(x), \dots, \partial_d f(x) \big]. \]
A2.31

Product Rule for Differentials

\[ d(fg)(x) = f(x)\,dg(x) + g(x)\,df(x). \]
A2.32

Chain Rule for Multivariable Functions

\[ d(f \circ g)(x) = df(g(x)) \cdot dg(x). \]
A2.33

Divergence

\[ \nabla \cdot f(x) = \operatorname{trace}(df(x)) = \sum_{i=1}^d \partial_i f^{(i)}(x). \]
A2.34

Gradient with Respect to a Matrix Field

\[ \nabla_A f(x) = A(x)^{-1} df(x)^T. \]
A2.35

Differential of the Determinant

\[ d(\det)(A) H = \operatorname{trace}(\operatorname{cof}(A)^T H). \]
A2.36

Differential of Matrix Inversion

\[ dI(A) H = -A^{-1} H A^{-1}. \]
A2.37

Higher‑Order Partial Derivatives

If all partials up to order k exist and are continuous, f is $C^k$ and the order of differentiation is irrelevant: $\partial_1\partial_2\partial_1 f = \partial_1^2 \partial_2 f$.

A2.38

k‑th Differential (Multilinear Map)

\[ d^k f(x)(h_1,\dots,h_k) = \sum_{i_1,\dots,i_k=1}^d h_1^{(i_1)} \cdots h_k^{(i_k)} \partial_{i_k}\cdots\partial_{i_1} f(x). \]
A2.39

Hessian Matrix

\[ \nabla^2 f(x) = \big( \partial_i \partial_j f(x) \big)_{i,j=1,\dots,d}. \]
  • $\nabla^2 f(x)$symmetric $d\times d$ matrix; $h_1^T \nabla^2 f(x) h_2 = d^2 f(x)(h_1, h_2)$.
A2.40

Laplacian

\[ \Delta f(x) = \operatorname{trace}(\nabla^2 f(x)) = \sum_{i=1}^d \partial_i^2 f(x). \]
A2.41

Taylor's Theorem (Multivariable, Integral Form)

Let $f \in C^k$ and $[x, x+h] \subset U$. Then

\[ f(x+h) = \sum_{j=0}^{k-1} \frac{1}{j!} d^{j}f(x)(h,\dots,h) + \frac{1}{(k-1)!} \int_{0}^{1} (1-t)^{k-1} d^{k}f(x+th)(h,\dots,h)\, dt. \]

In big-O form: $f(x+h) = \sum_{j=0}^{k} \frac{1}{j!} d^{j}f(x)(h,\dots,h) + o(\|h\|^k)$.

A2.42

Summary of Differential and Integral Formulas

Differentiation Rules

  • Constant multiple: $(c f)' = c f'$
  • Sum: $(f+g)' = f' + g'$
  • Product: $(fg)' = f'g + fg'$
  • Quotient: $(f/g)' = (f'g - fg')/g^2$
  • Chain: $(f\circ g)' = f'(g)\cdot g'$

Elementary Derivatives

  • $\frac{d}{dx}x^n = nx^{n-1}$
  • $\frac{d}{dx}e^x = e^x$, $\frac{d}{dx}\ln x = 1/x$
  • $\frac{d}{dx}\sin x = \cos x$, $\frac{d}{dx}\cos x = -\sin x$
  • $\frac{d}{dx}\arctan x = 1/(1+x^2)$

Integration Rules

  • Linearity: $\int(c_1 f+c_2 g) = c_1\int f + c_2\int g$
  • Parts: $\int u\,dv = uv - \int v\,du$
  • FTC II: $\int_a^b f = F(b)-F(a)$

Multivariable Formulas

  • Gradient: $\nabla f = (\partial_1 f,\dots,\partial_d f)^T$
  • Divergence: $\nabla\cdot F = \sum \partial_i F_i$
  • Laplacian: $\Delta f = \sum \partial_i^2 f$
  • Det differential: $d(\det)(A)H = \operatorname{trace}(\operatorname{cof}(A)^TH)$
  • Inverse differential: $d(A^{-1})H = -A^{-1}HA^{-1}$
Machine Learning Extensions · A2.43–A2.60
A2.43

Convex Functions ML

A function $f : C \to \mathbb{R}$ on a convex set $C \subseteq \mathbb{R}^d$ is convex if for all $x, y \in C$ and $t \in [0, 1]$,

\[ f\!\bigl((1-t)x + ty\bigr) \le (1-t)f(x) + t f(y). \]

Geometrically, the chord connecting any two points on the graph lies above (or on) the graph. If the inequality is strict for $x \neq y$ and $t \in (0,1)$, f is strictly convex.

For a $C^2$ function, convexity is equivalent to the Hessian being positive semi-definite everywhere:

\[ f \text{ is convex} \iff \nabla^2 f(x) \succeq 0 \quad \forall\, x \in C. \]

Convex functions have a crucial property: every local minimum is a global minimum. This makes convexity the central structural assumption in optimization for machine learning.

  • $A \succeq 0$positive semi-definite; all eigenvalues are non-negative.
  • $A \succ 0$strictly positive definite; all eigenvalues are strictly positive.
A2.44

First-Order Optimality Conditions ML

Let $f : \mathbb{R}^d \to \mathbb{R}$ be differentiable. A necessary condition for $x^*$ to be a local minimum is that the gradient vanishes:

\[ \nabla f(x^*) = 0. \]

Such a point is called a critical point. If f is convex, this condition is also sufficient for a global minimum. For constrained minimization $\min_{x \in C} f(x)$ over a convex set C, the first-order condition becomes the variational inequality:

\[ \nabla f(x^*)^T (y - x^*) \ge 0 \quad \forall\, y \in C. \]
  • $x^*$an optimal point (minimizer); satisfies the stationarity condition.
A2.45

Second-Order Conditions and Saddle Points ML

Let $f \in C^2$ and $\nabla f(x^*) = 0$. Let $H = \nabla^2 f(x^*)$:

\[ H \succ 0 \;\Rightarrow\; \text{strict local min},\quad H \prec 0 \;\Rightarrow\; \text{strict local max},\quad H \text{ indefinite} \;\Rightarrow\; \text{saddle point.} \]

A saddle point is a critical point that is neither local min nor max. In neural network training, the loss landscape is typically non-convex and riddled with saddle points; their proliferation in high dimensions is a key challenge for gradient-based optimizers.

  • saddle pointa critical point where H is indefinite; a min in some directions, max in others.
A2.46

Gradient Descent ML

Gradient descent is the canonical first-order algorithm for minimizing a differentiable function. Starting from $x_0$, the update rule is

\[ x_{k+1} = x_k - \eta \,\nabla f(x_k), \]

where $\eta > 0$ is the learning rate. For a convex, L-smooth function with step size $\eta = 1/L$, the convergence rate is

\[ f(x_k) - f(x^*) \le \frac{L\|x_0 - x^*\|^2}{2k}. \]
  • $\eta$learning rate; controls the step size in the negative gradient direction.
  • $L$Lipschitz constant of $\nabla f$; governs the maximum stable step size.
A2.47

Stochastic Gradient Descent ML

For an objective that is a sum over n training samples, $f(x) = \frac{1}{n}\sum_{i=1}^n \ell_i(x)$, SGD approximates the gradient with a mini-batch $\mathcal{B}$:

\[ x_{k+1} = x_k - \eta_k \,g_k, \qquad g_k = \frac{1}{|\mathcal{B}|}\sum_{i\in\mathcal{B}} \nabla \ell_i(x_k). \]

The estimator is unbiased: $\mathbb{E}[g_k] = \nabla f(x_k)$. Convergence requires a diminishing step-size schedule or adaptive methods (Adam, RMSProp). SGD is the workhorse of deep learning.

  • $g_k$stochastic gradient; an unbiased estimate of $\nabla f(x_k)$.
  • $\mathcal{B}$mini-batch; a random subset of training indices.
A2.48

Lagrange Multipliers and Constrained Optimization ML

To minimize $f(x)$ subject to $g_i(x) = 0$, form the Lagrangian:

\[ \mathcal{L}(x, \lambda) = f(x) + \sum_{i=1}^m \lambda_i\, g_i(x). \]

At an optimum, the KKT stationarity condition requires

\[ \nabla_x \mathcal{L}(x^*, \lambda^*) = \nabla f(x^*) + \sum_{i=1}^m \lambda_i^* \nabla g_i(x^*) = 0. \]

For inequality constraints $h_j(x) \le 0$, KKT requires $\mu_j \ge 0$ and complementary slackness $\mu_j h_j(x^*) = 0$. These conditions underpin SVMs, duality theory, and constrained neural network training.

  • $\mathcal{L}$Lagrangian; a penalized objective combining f and constraint violations.
  • $\lambda_i, \mu_j$Lagrange / KKT multipliers for equality and inequality constraints.
A2.49

Backpropagation and the Computational Graph ML

Backpropagation is a systematic application of the chain rule on a computational graph to compute the gradient of a scalar loss $\mathcal{L}$ with respect to all parameters. For a network computing $z^{(l)} = \sigma(W^{(l)} z^{(l-1)} + b^{(l)})$, define the error signal $\delta^{(l)} = \partial \mathcal{L}/\partial z^{(l)}$. The recurrence is

\[ \delta^{(l)} = \bigl(W^{(l+1)}\bigr)^T \delta^{(l+1)} \odot \sigma'\!\bigl(W^{(l)} z^{(l-1)} + b^{(l)}\bigr), \]

and the weight gradients are

\[ \frac{\partial \mathcal{L}}{\partial W^{(l)}} = \delta^{(l)} \bigl(z^{(l-1)}\bigr)^T. \]

One forward pass (cache activations) plus one backward pass (propagate errors) gives all gradients in $O(\text{parameters})$ time.

  • $\delta^{(l)}$error signal at layer l; gradient of the loss w.r.t. layer outputs.
  • $\odot$element-wise (Hadamard) product.
A2.50

Jacobian–Vector and Vector–Jacobian Products ML

For $f : \mathbb{R}^d \to \mathbb{R}^m$ with Jacobian $J = df(x) \in \mathbb{R}^{m\times d}$:

\[ \text{JVP}(v) = J v \;\in \mathbb{R}^m \quad\text{(forward-mode autodiff)}, \]
\[ \text{VJP}(u) = J^T u \;\in \mathbb{R}^d \quad\text{(reverse-mode autodiff / backprop)}. \]

For scalar losses (m = 1), one VJP with $u = 1$ recovers the full gradient $\nabla f(x)$ in a single pass — this is why reverse-mode is preferred when d (number of parameters) vastly exceeds m.

  • JVPJacobian–vector product; directional derivative of f in direction v.
  • VJPvector–Jacobian product; gives gradients in one reverse pass.
A2.51

Lipschitz Continuity and Gradient Smoothness ML

A function is Lipschitz continuous with constant $K$ if $\|f(x)-f(y)\| \le K\|x-y\|$. A differentiable scalar function is L-smooth if

\[ \|\nabla f(x) - \nabla f(y)\| \le L\,\|x - y\|. \]

The descent lemma (key convergence tool) follows from L-smoothness:

\[ f(y) \le f(x) + \nabla f(x)^T(y-x) + \frac{L}{2}\|y-x\|^2. \]

This quadratic upper bound justifies the step size $\eta \le 1/L$ in gradient descent.

  • $L$smoothness constant; bounds the curvature; governs stable step sizes.
A2.52

Strong Convexity ML

A differentiable function $f$ is μ-strongly convex if for all $x, y$,

\[ f(y) \ge f(x) + \nabla f(x)^T(y-x) + \frac{\mu}{2}\|y-x\|^2. \]

This ensures a unique global minimum and linear convergence. For an L-smooth, μ-strongly convex function, gradient descent converges as

\[ \|x_k - x^*\|^2 \le \left(1 - \frac{\mu}{L}\right)^k \|x_0 - x^*\|^2. \]
  • $\mu$strong convexity modulus; minimum curvature.
  • $\kappa = L/\mu$condition number; large κ means slow convergence.
A2.53

Change of Variables for Probability Densities ML

Let $g : \mathbb{R}^d \to \mathbb{R}^d$ be a diffeomorphism and $Y = g(X)$ where $X$ has density $p_X$. Then

\[ p_Y(y) = \frac{p_X(x)}{|\det\, dg(x)|}\bigg|_{x=g^{-1}(y)}. \]

The absolute Jacobian determinant $|\det\, dg(x)|$ accounts for local volume distortion. This formula is fundamental to normalizing flows, the reparameterization trick in VAEs, and latent variable models.

  • $|\det\, dg|$absolute Jacobian determinant; local volume scaling of the transformation.
A2.54

Convex Conjugate (Legendre–Fenchel Transform) ML

The convex conjugate (Fenchel conjugate) of $f$ is

\[ f^*(y) = \sup_{x \in \mathbb{R}^d} \bigl\{ y^T x - f(x) \bigr\}. \]

The function $f^*$ is always convex. For a convex, closed, proper f, the biconjugate satisfies $f^{**} = f$. The Fenchel–Young inequality states

\[ f(x) + f^*(y) \ge x^T y. \]

Conjugates appear in dual SVM formulations, mirror descent, and the derivation of softmax from the log-partition function.

  • $f^*(y)$conjugate of f; always convex regardless of f.
A2.55

Subgradients and Subgradient Methods ML

For a convex but possibly non-smooth $f$, a vector $s$ is a subgradient at x if

\[ f(y) \ge f(x) + s^T(y - x) \quad \forall\, y. \]

The subdifferential $\partial f(x)$ is the set of all subgradients. Optimality: $0 \in \partial f(x^*)$. The subgradient method is

\[ x_{k+1} = x_k - \eta_k\, s_k, \quad s_k \in \partial f(x_k). \]

Lasso regression, hinge loss, and ReLU activations all require subgradient reasoning. For $f(x)=|x|$ at $x=0$: $\partial f(0) = [-1,1]$.

  • $\partial f(x)$subdifferential; set of all subgradients at x.
A2.56

Automatic Differentiation ML

Automatic differentiation (AD) computes exact derivatives of programs via the chain rule on a computational graph — neither symbolic math nor finite differences.

  • Forward mode (JVP): propagates tangents $\dot{v}_i = \partial v_i/\partial x_j$ alongside values; cost = O(d) passes for d inputs.
  • Reverse mode (VJP): propagates adjoints $\bar{v}_i = \partial\mathcal{L}/\partial v_i$ backwards; cost = O(1) forward + backward for any number of inputs.

The fundamental update at each node in reverse mode:

\[ \bar{v}_{j} \mathrel{+}= \bar{v}_i \cdot \frac{\partial v_i}{\partial v_j}. \]
  • $\dot{v}_i$forward tangent of node i.
  • $\bar{v}_i$reverse adjoint of node i; gradient of loss w.r.t. intermediate value.
A2.57

Multivariate Gaussian and Calculus of Quadratic Forms ML

The multivariate Gaussian density with mean $\mu$ and covariance $\Sigma \succ 0$:

\[ p(x;\mu,\Sigma) = \frac{1}{(2\pi)^{d/2}|\det\Sigma|^{1/2}} \exp\!\left(-\tfrac{1}{2}(x-\mu)^T\Sigma^{-1}(x-\mu)\right). \]

Key matrix calculus identities for quadratic forms (constant symmetric A):

\[ \nabla_x(x^T A x) = 2Ax, \qquad \nabla_x(a^T x) = a, \qquad \frac{\partial}{\partial A}(x^T A x) = x x^T. \]

The log-determinant gradient (needed for MLE of $\Sigma$):

\[ \nabla_\Sigma \log\det\Sigma = \Sigma^{-1} \quad (\Sigma \text{ symmetric}). \]
  • $x^T A x$quadratic form; appears in Gaussian exponent and regularization.
  • $\log\det\Sigma$log-determinant; in Gaussian log-likelihood and KL divergence.
A2.58

Differentiation Under the Integral Sign (Leibniz Rule) ML

Under dominated convergence, differentiation and integration may be exchanged:

\[ \frac{d}{d\theta} \int f(x,\theta)\, dx = \int \frac{\partial f}{\partial\theta}(x,\theta)\, dx. \]

For expectations over a fixed distribution: $\nabla_\theta\,\mathbb{E}_{p(x)}[f(x,\theta)] = \mathbb{E}_{p(x)}[\nabla_\theta f(x,\theta)]$.

When the distribution also depends on $\theta$, the log-derivative (REINFORCE) trick gives

\[ \nabla_\theta\, \mathbb{E}_{p(x;\theta)}[f(x)] = \mathbb{E}_{p(x;\theta)}\!\bigl[f(x)\,\nabla_\theta \log p(x;\theta)\bigr]. \]

These identities underpin the reparameterization trick in VAEs and the policy gradient theorem in reinforcement learning.

  • $\nabla_\theta \log p$score function; its expectation under $p(\cdot;\theta)$ equals zero.
A2.59

Integral Transforms: Fourier and Laplace ML

The Fourier transform of $f \in L^1(\mathbb{R}^d)$:

\[ \hat{f}(\xi) = \int_{\mathbb{R}^d} f(x)\, e^{-2\pi i\, \xi^T x}\, dx. \]

Differentiation becomes multiplication in frequency space: $\widehat{\partial_j f}(\xi) = 2\pi i\,\xi_j\,\hat{f}(\xi)$. This is central to understanding neural network expressivity, kernel methods (Bochner's theorem), and spectral analysis.

The Laplace transform:

\[ \mathcal{L}\{f\}(s) = \int_0^\infty f(t)\, e^{-st}\, dt. \]
  • $\hat{f}(\xi)$Fourier transform at frequency $\xi$; turns derivatives into multiplications.
A2.60

Proximal Operators and Proximal Gradient Method ML

For a convex function $g$ and step size $\eta > 0$, the proximal operator is

\[ \operatorname{prox}_{\eta g}(v) = \arg\min_{x} \left\{ g(x) + \frac{1}{2\eta}\|x - v\|^2 \right\}. \]

The proximal gradient method minimizes composite objectives $f(x)+g(x)$ (smooth f, non-smooth g):

\[ x_{k+1} = \operatorname{prox}_{\eta g}\!\bigl(x_k - \eta \nabla f(x_k)\bigr). \]

For $g(x)=\lambda\|x\|_1$ (Lasso), the proximal operator is soft-thresholding:

\[ \bigl(\operatorname{prox}_{\eta g}(v)\bigr)_i = \operatorname{sign}(v_i)\max(|v_i| - \eta\lambda,\, 0). \]

Proximal methods underlie ADMM, sparse representation, and many deep learning regularizers.

  • $\operatorname{prox}_{\eta g}$proximal operator; balances proximity to v with minimizing g.
A2.61

Global Minimizers and Maximizers

A point $x \in \Omega$ is a global minimizer (resp. maximizer) of $F$ on $\Omega$ if $F(y) \ge F(x)$ (resp. $F(y) \le F(x)$) for all $y \in \Omega$. Equivalently,

\[ x \in \operatorname{argmin}_{\Omega} F \;\Longleftrightarrow\; F(x) = \min_{\Omega} F, \qquad x \in \operatorname{argmax}_{\Omega} F \;\Longleftrightarrow\; F(x) = \max_{\Omega} F. \]

The set of all minimizers is denoted $\operatorname{argmin}_{\Omega} F$ (respectively $\operatorname{argmax}_{\Omega} F$). Minimizers need not be unique.

  • $\operatorname{argmin}_{\Omega} F$the (possibly empty) set of global minimizers of $F$ on $\Omega$.
  • $\operatorname{argmax}_{\Omega} F$the set of global maximizers.
A2.62

Local Minimizers and Maximizers

A point $x \in \Omega$ is a local minimizer (resp. maximizer) of $F$ on $\Omega$ if there exists an open ball $B \subset \mathbb{R}^d$ containing $x$ such that

\[ F(x) = \min_{\Omega \cap B} F \quad \big(\text{resp. } F(x) = \max_{\Omega \cap B} F\big). \]

Thus a local extremum is only required to be optimal within some neighbourhood.

  • local minimizera point that minimizes $F$ in a small neighbourhood intersected with $\Omega$.
A2.63

Existence of Minimizers and Lower Semicontinuity

An optimization problem consists of finding a minimizer (or maximizer) of an objective function $F$ on a set $\Omega$. We focus on minimization; maximization is symmetric.

The sublevel sets of $F$ are defined as $[F \le u]_{\Omega} = \{ x \in \Omega : F(x) \le u \}$. Note that

\[ \operatorname{argmin}_{\Omega} F = \bigcap_{u > \inf F} [F \le u]_{\Omega}. \]

$F$ is called lower semicontinuous (l.s.c.) on $\Omega$ if its sublevel sets are closed in $\mathbb{R}^d$. This means: if a sequence $(x_n) \subset \Omega$ satisfies $F(x_n) \le u$ and converges to $x$, then $x \in \Omega$ and $F(x) \le u$. If, in addition, the sublevel sets are bounded for $u$ sufficiently close to $\inf F$, then $\operatorname{argmin}_{\Omega} F$ is an intersection of nested compact sets and therefore non‑empty — i.e., a minimizer exists.

  • $[F \le u]_{\Omega}$sublevel set of $F$ at level $u$.
  • l.s.c.lower semicontinuous; sublevel sets are closed.
A2.64

Classification of Optimization Problems

Different assumptions on $F$ and $\Omega$ lead to distinct problem classes:

  1. Unconstrained smooth optimization: $F$ is $C^1$ (or smoother) and $\Omega = \mathbb{R}^d$.
  2. Constrained smooth optimization: $\Omega = \{ x \in \mathbb{R}^d : \gamma_i(x) \le 0,\; i=1,\dots,q \}$ with $F$ and all $\gamma_i$ of class $C^1$.
  3. Convex optimization: $\Omega$ is convex (i.e., $x,y\in\Omega \Rightarrow [x,y]\subset\Omega$) and $F$ is convex ($F((1-t)x+ty) \le (1-t)F(x)+tF(y)$ for $x,y\in\Omega$).
  4. Non‑smooth optimization: $F$ (or the constraints) lack differentiability; often arise in data science.
  5. Linear programming: $F$ and all $\gamma_i$ are affine ($F(x) = b^T x + \beta$, $\gamma_i(x) = a_i^T x + c_i$).
  6. Quadratic programming: $F$ is quadratic ($F(x) = \frac12 x^T A x - b^T x$) and the $\gamma_i$ are affine.
  7. Combinatorial optimization: $\Omega$ is a discrete or finite set (e.g., $\mathbb{Z}^d$ or $\{0,1\}^d$).
  • Convex seta set $\Omega$ such that the segment joining any two points in $\Omega$ is fully contained in $\Omega$.
  • Convex functiona function satisfying $F((1-t)x+ty) \le (1-t)F(x) + t F(y)$ for all $x,y$ and $t\in[0,1]$.
  • Affine functiona mapping of the form $x \mapsto b^T x + \beta$.
A2.65

Optimality Conditions for Unconstrained Problems

Let $\Omega \subset \mathbb{R}^d$ be open and $F : \Omega \to \mathbb{R}$ differentiable. Consider the problem $\min_{x\in\Omega} F(x)$.

Theorem 3.1 (Necessary conditions). If $x^*$ is a local minimum, then $\nabla F(x^*) = 0$. If $F$ is $C^2$, then $\nabla^2 F(x^*)$ is positive semidefinite.

Sufficient conditions. If $F$ is $C^2$, $\nabla F(x^*) = 0$, and $\nabla^2 F(x^*) \succ 0$, then $x^*$ is a local minimum.

For maximization, replace “positive semidefinite” by “negative semidefinite” (and similarly for definite).

\[ \text{local min } \Rightarrow \nabla F(x^*) = 0, \quad \nabla^2 F(x^*) \succeq 0. \] \[ \nabla F(x^*) = 0,\; \nabla^2 F(x^*) \succ 0 \Rightarrow \text{ strict local min}. \]
A2.66

Convex Sets and Functions

Definition 3.2. A set $\Omega \subset \mathbb{R}^d$ is convex if $\forall x,y\in\Omega$, the segment $[x,y]\subset\Omega$. A function $F:\mathbb{R}^d \to (-\infty,+\infty]$ is convex if for all $x,y\in\mathbb{R}^d$, $\lambda\in[0,1]$,

\[ F((1-\lambda)x + \lambda y) \le (1-\lambda)F(x) + \lambda F(y). \tag{3.2} \]

If the inequality is strict for $\lambda\in(0,1)$ when finite, $F$ is strictly convex. The domain of $F$ is $\operatorname{dom}(F) = \{x : F(x) < \infty\}$; $F$ is proper if $\operatorname{dom}(F) \neq \emptyset$.

Proposition 3.5. For convex $F$, the function $\lambda \mapsto \frac{1}{\lambda}(F((1-\lambda)x+\lambda y)-F(x))$ is non‑decreasing (increasing if strictly convex).

Corollary 3.6. Any local minimum of a convex function is a global minimum.

  • $\operatorname{dom}(F)$the effective domain of $F$ (points where $F$ is finite).
A2.67

Relative Interior

For a convex set $\Omega$, the affine hull $\operatorname{aff}(\Omega)$ is the smallest affine subspace containing $\Omega$. The relative interior is

\[ \operatorname{relint}(\Omega) = \{x\in\Omega : \exists \epsilon>0,\; \operatorname{aff}(\Omega)\cap B(x,\epsilon)\subset\Omega\}. \]

Proposition 3.8. $\operatorname{relint}(\Omega)$ is non‑empty and convex. If $x\in\operatorname{relint}(\Omega)$, $y\in\Omega$, then $(1-\lambda)x+\lambda y \in \operatorname{relint}(\Omega)$ for all $\lambda\in[0,1)$.

Proposition 3.9. $x\in\operatorname{relint}(\Omega)$ iff for every $y\in\Omega$ there exists $\epsilon>0$ such that $x-\epsilon(y-x)\in\Omega$.

  • $\operatorname{relint}(\Omega)$relative interior; always non‑empty for a non‑empty convex set.
A2.68

Derivatives of Convex Functions and Optimality

Theorem 3.11. Let $F$ be convex and differentiable at $x\in\operatorname{int}(\operatorname{dom}(F))$. Then for all $y$,

\[ \nabla F(x)^T (y-x) \le F(y) - F(x). \tag{3.5} \]

Hence $\nabla F(x)=0$ implies $x$ is a global minimizer (unique if strictly convex). Conversely, if $F$ is $C^1$ on an open convex set and satisfies (3.5), then $F$ is convex.

Proposition 3.12. If $F$ is $C^2$ on an open convex domain, $F$ is convex iff $\nabla^2 F(x) \succeq 0$ for all $x$; strict convexity follows if $\nabla^2 F(x) \succ 0$.

Definition 3.13. A $C^1$ function $F$ is strongly convex (with modulus $m>0$) if

\[ F(y) - F(x) - \nabla F(x)^T(y-x) \ge \frac{m}{2}\|y-x\|^2. \tag{3.6} \]

Proposition 3.14. A strongly convex function is strictly convex; if $\operatorname{dom}(F)=\mathbb{R}^d$, then $\operatorname{argmin} F$ is a single point. Moreover, (3.6) implies the quadratic growth condition (3.9).

Definition 3.15. $F$ is $L$-$C^k$ if it is $C^k$ and $\|d^k F(x) - d^k F(y)\| \le L\|x-y\|$. If $F$ is $L$-$C^1$ and strongly convex, one has the double inequality (3.8).

  • $m$-strongly convexsatisfies (3.6); implies uniqueness of minimizer and quadratic growth.
  • $L$-$C^k$$k$‑times differentiable with $L$‑Lipschitz $k$‑th differential.
A2.69

Direction of Descent and Steepest Descent

Definition 3.17. A non‑zero vector $h$ is a direction of descent for $F$ at $x$ if $F(x+\epsilon h) < F(x)$ for small enough $\epsilon>0$.

Proposition 3.18. For $C^1$ $F$, if $h^T\nabla F(x) < 0$ then $h$ is a descent direction; conversely, any descent direction satisfies $h^T\nabla F(x) \le 0$.

The steepest descent direction for the Euclidean norm is $h = -\nabla F(x)$. More generally, given a positive definite matrix $A$, the steepest descent direction with respect to the norm $\|h\|_A = \sqrt{h^T A h}$ is $-\nabla_A F(x) = -A^{-1}\nabla F(x)$. Newton’s method uses $A = \nabla^2 F(x)$ (when positive definite).

  • $-\nabla F(x)$steepest descent direction (Euclidean norm).
  • $-\nabla_A F(x)$steepest descent for the norm induced by $A$.
A2.70

Convergence of Descent Algorithms

Consider the iteration $x_{t+1} = x_t + \alpha_t h_t$ with $h_t$ a descent direction satisfying

\[ -h_t^T \nabla F(x_t) \ge \epsilon \|h_t\| \|\nabla F(x_t)\|, \qquad \gamma_1 \|\nabla F(x_t)\| \le \|h_t\| \le \gamma_2 \|\nabla F(x_t)\|. \tag{3.12} \]

Proposition 3.19. If $F$ is $L$-$C^1$ and (3.12) holds, then for sufficiently small $\alpha_t$,

\[ F(x_{t+1}) - F(x_t) \le -C \alpha_t \|\nabla F(x_t)\|^2. \tag{3.13} \]

Thus, if $F$ is bounded below, $\min_{t\le T} \|\nabla F(x_t)\|^2 = O(1/T)$.

Theorem 3.20 (convex case). If $F$ is convex and (3.14) holds ($F(x_{t+1})-F(x_t) \le -C\|\nabla F(x_t)\|^2$), then

\[ F(x_t) - F(x^*) \le \frac{R^2}{C(t+1)}, \quad R = \max\{\|x-x^*\| : F(x)\le F(x_0)\}. \]

Proposition 3.21 (strongly convex case). If $F$ is strongly convex with modulus $m$ and (3.14) holds, then

\[ F(x_t) - F(x^*) \le (1-2Cm)^t (F(x_0)-F(x^*)). \]
  • linear convergenceachieved under strong convexity; the error decays geometrically.
A2.71

Line Search: Armijo Rule and Wolfe Conditions

A line search determines a step size $\alpha$ along a descent direction $h$. Let $f_h(\alpha) = F(x+\alpha h)$. The Armijo condition requires (with $c_1\in(0,1)$)

\[ f_h(\alpha) \le f_h(0) + c_1 \alpha h^T \nabla F(x). \tag{3.15} \]

Backtracking: start with $\alpha = \alpha_{\max}$ and repeatedly multiply by $\rho\in(0,1)$ until (3.15) holds.

The weak Wolfe conditions add

\[ h^T \nabla F(x+\alpha h) \ge c_2 h^T \nabla F(x), \quad c_1 < c_2 < 1. \tag{3.16a} \]

The strong Wolfe conditions require $|h^T \nabla F(x+\alpha h)| \le c_2 |h^T \nabla F(x)|$.

Proposition 3.22. If $F$ is $L$-$C^1$ and (3.12), (3.15), (3.16a) hold, then there exists $C>0$ such that $F(x+\alpha h) \le F(x) - C\|\nabla F(x)\|^2$.

Proposition 3.23 / 3.24. Finite algorithms exist to find a step size satisfying the weak or strong Wolfe conditions, provided $F$ is $C^1$ and bounded below.

  • $c_1$Armijo constant (typically small, e.g., $10^{-4}$).
  • $c_2$Wolfe curvature constant (e.g., 0.9 for strong Wolfe).
A2.72

Stochastic Gradient Descent (SGD)

When the gradient $\nabla F$ is too costly to compute exactly, a stochastic approximation can be used. The Robbins‑Monro type stochastic gradient descent (SGD) updates a parameter $x \in \mathbb{R}^d$ using random iterations:

\[ \xi_{t+1} \sim \pi_{X_t}, \qquad X_{t+1} = X_t + \alpha_{t+1} H(X_t, \xi_{t+1}), \tag{3.17} \]

where $\pi_x$ is a probability distribution on a set $S$ (which may depend on $x$), $H: \mathbb{R}^d \times S \to \mathbb{R}^d$ is an easily computable update direction, and $\alpha_{t+1}$ is the step size. The conditional distribution of $\xi_{t+1}$ given the past $U_t = (\xi_1,X_1,\dots,\xi_t,X_t)$ depends only on $X_t$ and is given by $\pi_{X_t}$.

  • $\pi_x$probability distribution used to generate the stochastic update at $x$.
  • $H(x,\xi)$a noisy estimate of the (negative) gradient direction.
A2.73

Deterministic Approximation and Convergence

Define the average direction

\[ \bar{H}(x) = \mathbb{E}_{\pi_x}[H(x,\cdot)]. \]

Write $X_{t+1} = X_t + \alpha_{t+1}\bar{H}(X_t) + \alpha_{t+1}\eta_{t+1}$ with $\eta_{t+1} = H(X_t,\xi_{t+1}) - \bar{H}(X_t)$. Then $\mathbb{E}[\eta_{t+1}\mid U_t] = 0$, making $M_T = \sum_{t=0}^T \alpha_{t+1}\eta_{t+1}$ a martingale.

Consider the following typical assumptions:

  • (H1) There exists $C$ such that $\mathbb{E}_{\pi_x}[|H(x,\cdot)|^2] \le C(1+|x|^2)$.
  • (H2) There exist $x^* \in \mathbb{R}^d$ and $\mu > 0$ such that $(x-x^*)^T\bar{H}(x) \le -\mu|x-x^*|^2$.
  • (H3) $\sum_{k=1}^\infty \alpha_k = \infty$ and $\sum_{k=1}^\infty \alpha_k^2 < \infty$.

Under (H1)–(H3), the sequence $X_t$ converges in $L^2$ to $x^*$; in fact, almost‑sure convergence holds as well.

Lemma 3.25. If a non‑negative sequence $a_t$ satisfies $a_{t+1} \le (1-\delta_t)a_t + \epsilon_t$ with $0\le \delta_t\le 1$, let $v_{k,t} = \prod_{j=k+1}^t (1-\delta_j)$. Then

\[ a_t \le a_0 v_{0,t} + \sum_{k=1}^t \epsilon_k v_{k,t}. \tag{3.22} \]

Lemma 3.26. Let $w_{st}$ ($s\le t$) be bounded with $\lim_{t\to\infty} w_{st}=0$ for each $s$, and $\sum_t |\beta_t| < \infty$. Then $\lim_{t\to\infty} \sum_{s=1}^t \beta_s w_{st} = 0$.

Using Lemma 3.25 with $\delta_t = 2\alpha_{t+1}\mu - C\alpha_{t+1}^2$ and $\epsilon_t = \tilde C \alpha_{t+1}^2$, one shows that $\mathbb{E}[|X_t-x^*|^2] \to 0$. In the constant step‑size case $\alpha_t = \alpha$, the mean‑square error satisfies $\limsup \mathbb{E}[|X_t-x^*|^2] = O(\alpha)$.

  • $\bar{H}(x)$expected update direction; the deterministic flow follows $\dot{\bar{x}} = \bar{H}(\bar{x})$.
  • $M_T$martingale noise term; its variance is controlled by the step‑size schedule.
A2.74

ODE Method for Stochastic Approximation

Define the continuous‑time interpolation $X^\ell(\rho)$ by

\[ \tau_0 = 0,\; \tau_t = \tau_{t-1} + \alpha_t,\quad X^\ell(\rho) = X_t + \frac{\rho-\tau_t}{\alpha_{t+1}}(X_{t+1}-X_t),\; \rho\in[\tau_t,\tau_{t+1}). \]

The deterministic part of the algorithm is an Euler discretisation of the ordinary differential equation (ODE)

\[ \partial_\rho \bar{x} = \bar{H}(\bar{x}). \tag{3.24} \]

Proposition 3.27 (Benaïm). Assume $\bar{H}$ is Lipschitz and bounded. Then, for any $T>0$, there exists $C(T)$ such that for all $\rho\ge 0$,

\[ \sup_{h\in[0,T]} \big| X^\ell(\rho+h) - \phi(h, X^\ell(\rho)) \big| \le C(T) \Big( \Delta(\rho-1,T+1) + \max_{s\in[\rho,\rho+T]} \alpha^c(s) \Big), \]

where $\phi(\cdot,\omega)$ is the solution of (3.24) with $\bar{x}(0)=\omega$, and $\Delta(\rho,T)$ controls the cumulative martingale noise.

Using martingale inequalities (Doob’s inequality), one can show that $\Delta(\rho,T)$ is small with high probability, so the stochastic process stays close to the ODE solution over finite intervals.

Proposition 3.28. If $\bar{H} = -\nabla E$ is a gradient field with finitely many critical points and $X_t$ remains bounded, then $X_t$ converges to a critical point of $E$.

Theorem 3.29 (Lyapunov stability). Assume there exists a $C^2$ function $U$ with bounded second derivatives and $K_0>0$ such that for $|x|\ge K_0$, $\nabla U(x)^T \bar{H}(x) \le 0$ and $U(x) \ge \gamma|x|^2$, $\gamma>0$. Then the interpolated trajectories $X^\ell(\rho)$ are almost surely bounded. Hypothesis (H2) provides such a Lyapunov function ($U(x)=|x-x^*|^2$).

A2.75

ADAM Algorithm

ADAM (Adaptive Moment Estimation) is a widely used variant of SGD that adapts the step sizes per coordinate using running averages of the first and second moments of the stochastic gradients.

Algorithm 3.30 (ADAM). Given parameters $\alpha$ (step size, e.g., 0.001), $\beta_1,\beta_2\in[0,1)$ (moment decay rates, e.g., 0.9 and 0.999), $\epsilon>0$ (small constant, e.g., $10^{-8}$), and initial state $X_0$, $m_0=0$, $v_0=0$:

  1. At step $t$, obtain stochastic gradient $g_{t+1} = H(X_t, \xi_{t+1})$.
  2. Update biased first moment: $m_{t+1} = \beta_1 m_t + (1-\beta_1) g_{t+1}$.
  3. Update biased second moment: $v_{t+1} = \beta_2 v_t + (1-\beta_2) g_{t+1}^{\odot 2}$ (element‑wise square).
  4. Compute bias‑corrected estimates:
    \[ \hat{m}_{t+1} = \frac{m_{t+1}}{1-\beta_1^{t+1}}, \qquad \hat{v}_{t+1} = \frac{v_{t+1}}{1-\beta_2^{t+1}}. \]
  5. Update parameter:
    \[ X_{t+1} = X_t - \alpha \frac{\hat{m}_{t+1}}{\sqrt{\hat{v}_{t+1}} + \epsilon}, \]
    where all operations on vectors are element‑wise.

The bias correction accounts for the initialisation at zero, ensuring unbiased estimates of the moments. ADAM can be seen as a diagonal approximation of a natural gradient method.

  • $\hat{m}_{t+1}$bias‑corrected moving average of the gradient (first moment).
  • $\hat{v}_{t+1}$bias‑corrected moving average of the squared gradient (second moment).
A2.76

Stochastic Gradient Descent (SGD)

When the exact gradient $\nabla F$ is too costly to compute, a stochastic approximation can be used. The Robbins–Monro type stochastic gradient descent (SGD) iterates

\[ \xi_{t+1} \sim \pi_{X_t}, \qquad X_{t+1} = X_t + \alpha_{t+1} H(X_t, \xi_{t+1}), \tag{3.17} \]

where $\pi_x$ is a probability distribution on a set $S$ (which may depend on $x$), $H:\mathbb{R}^d\times S\to\mathbb{R}^d$ is an easy‑to‑compute update, and $\alpha_{t+1}$ is the step size. The distribution of $\xi_{t+1}$ given the past $U_t=(\xi_1,X_1,\dots,\xi_t,X_t)$ depends only on $X_t$ and is given by $\pi_{X_t}$. Often $\pi_x$ can be taken independent of $x$ without loss of generality.

A2.77

Deterministic Approximation and Convergence

Define $\bar{H}(x) = \mathbb{E}_{\pi_x}[H(x,\cdot)]$. Then

\[ X_{t+1} = X_t + \alpha_{t+1}\bar{H}(X_t) + \alpha_{t+1}\eta_{t+1}, \quad \eta_{t+1}=H(X_t,\xi_{t+1})-\bar{H}(X_t). \]

$\mathbb{E}[\eta_{t+1}\mid U_t]=0$, so $M_T = \sum_{t=0}^T \alpha_{t+1}\eta_{t+1}$ is a martingale. Typical assumptions are:

  • (H1) $\mathbb{E}_{\pi_x}[|H(x,\cdot)|^2] \le C(1+|x|^2)$.
  • (H2) There exist $x^*\in\mathbb{R}^d$ and $\mu>0$ such that $(x-x^*)^T\bar{H}(x) \le -\mu|x-x^*|^2$.
  • (H3) $\sum_{k=1}^\infty \alpha_k = \infty$ and $\sum_{k=1}^\infty \alpha_k^2 < \infty$.

Under (H1)–(H3) the sequence $X_t$ converges in $L^2$ (and almost surely) to $x^*$. With constant step size $\alpha_t=\alpha$, the mean‑square error satisfies $\limsup \mathbb{E}[|X_t-x^*|^2] = O(\alpha)$.

A2.78

ODE Method for Stochastic Approximation

Define the continuous‑time interpolation $X^\ell(\rho)$ by $\tau_0=0$, $\tau_t=\tau_{t-1}+\alpha_t$,

\[ X^\ell(\rho) = X_t + \frac{\rho-\tau_t}{\alpha_{t+1}}(X_{t+1}-X_t), \quad \rho\in[\tau_t,\tau_{t+1}). \]

The deterministic part follows the ODE $\partial_\rho \bar{x} = \bar{H}(\bar{x})$. Under Lipschitz and boundedness assumptions on $\bar{H}$, the process stays close to the ODE solution over finite intervals (Proposition 3.27). If $\bar{H}=-\nabla E$ is a gradient field with finitely many critical points and $X_t$ remains bounded, $X_t$ converges to a critical point of $E$ (Proposition 3.28). A Lyapunov function (e.g., $|x-x^*|^2$ under (H2)) guarantees boundedness (Theorem 3.29).

A2.79

ADAM Algorithm

ADAM (Adaptive Moment Estimation) adapts step sizes per coordinate using running averages of the first and second moments of the stochastic gradient.

Algorithm 3.30 (ADAM). Given $\alpha$, $\beta_1,\beta_2\in[0,1)$, $\epsilon>0$, initial $X_0$, $m_0=0$, $v_0=0$:

  1. Obtain stochastic gradient $g_{t+1} = H(X_t,\xi_{t+1})$.
  2. $m_{t+1} = \beta_1 m_t + (1-\beta_1)g_{t+1}$.
  3. $v_{t+1} = \beta_2 v_t + (1-\beta_2)g_{t+1}^{\odot 2}$ (element‑wise square).
  4. Bias‑corrected estimates: $\hat{m}_{t+1} = m_{t+1}/(1-\beta_1^{t+1})$, $\hat{v}_{t+1} = v_{t+1}/(1-\beta_2^{t+1})$.
  5. $X_{t+1} = X_t - \alpha\, \hat{m}_{t+1}/(\sqrt{\hat{v}_{t+1}}+\epsilon)$ (element‑wise).
A2.80

Lagrange Multipliers and KKT Conditions

Minimize a $C^1$ function $F$ over $\Omega = \{x\in\mathbb{R}^d : \gamma_i(x)=0,\; i\in E,\; \gamma_i(x)\le 0,\; i\in I\}$, where $E\cap I=\emptyset$. The active set at $x\in\Omega$ is $\mathcal{A}(x)=\{i\in\mathcal{C} : \gamma_i(x)=0\}$. Define the Lagrangian

\[ \mathcal{L}(x,\lambda) = F(x) + \sum_{i\in\mathcal{C}} \lambda_i \gamma_i(x). \]

Under the Mangasarian‑Fromovitz constraint qualification (MF‑CQ) – e.g., linear independence of $\{\nabla\gamma_i(x),\, i\in\mathcal{A}(x)\}$ – a minimizer $x^*$ satisfies the Karush–Kuhn–Tucker (KKT) conditions:

\[ \partial_x \mathcal{L}(x^*,\lambda) = 0,\qquad \lambda_i \ge 0\;(i\in I),\quad \lambda_i=0\;\text{if } i\notin\mathcal{A}(x^*). \]

If all constraints are affine, the KKT conditions hold without any qualification (Theorem 3.33).

A2.81

Convex Constraints and the Normal Cone

For a closed convex set $\Omega\subset\mathbb{R}^d$, the normal cone at $x\in\Omega$ is

\[ N_\Omega(x) = \{ h\in\mathbb{R}^d : h^T(y-x)\le 0 \;\forall y\in\Omega \}. \]

If $F$ is $C^1$, a necessary condition for $x^*\in\operatorname{argmin}_\Omega F$ is $-\nabla F(x^*) \in N_\Omega(x^*)$. If $F$ is convex, this condition is also sufficient (Theorem 3.37). For convex constraints $\Omega$ defined by affine equalities and convex inequalities, the KKT conditions are equivalent to $-\nabla F(x^*) \in N_\Omega(x^*)$ (Farkas’ lemma).

A2.82

Minimization over Positive Semidefinite Matrices

Let $\Omega = \mathbb{S}_+^n$, the cone of positive semidefinite matrices. For a minimizer $A^*$ of a convex $F$ over $\Omega$, the normal cone yields: $-\nabla F(A^*)_s \in \mathbb{S}_+^n$ and $A^*\nabla F(A^*)_s = 0$ (Proposition 3.38). For example, with $F(A)=\frac12\operatorname{trace}(A^2)-\operatorname{trace}(BA)$ and $B$ diagonalised as $U^T D U$, the solution is $A^* = U^T D_+ U$, where $D_+$ replaces negative entries of $D$ by zero.

A2.83

Projection onto a Closed Convex Set

The projection of $x_0$ onto a closed convex $\Omega$ is the unique minimizer of $F(x)=\frac12|x-x_0|^2$ over $\Omega$, denoted $\operatorname{proj}_\Omega(x_0)$. It is characterized by

\[ \operatorname{proj}_\Omega(x_0)\in\Omega,\qquad (x_0-\operatorname{proj}_\Omega(x_0))^T(y-\operatorname{proj}_\Omega(x_0))\le 0 \;\forall y\in\Omega. \]

Examples: affine subspace (orthogonal projection), unit ball ($\operatorname{proj}_{\bar B(0,1)}(x_0)=x_0/|x_0|$ for $|x_0|\ge1$), positive semidefinite cone (set negative eigenvalues to zero). The projection is 1‑Lipschitz (Proposition 3.39).

A2.84

Projected Gradient Descent

To minimize $F$ over a closed convex $\Omega$, the projected gradient descent iterates

\[ x_{t+1} = \operatorname{proj}_\Omega\big( x_t - \alpha_t \nabla F(x_t) \big). \tag{3.38} \]

Equivalently, $x_{t+1} = \operatorname{argmin}_{y\in\Omega}\big( F(x_t) + \nabla F(x_t)^T(y-x_t) + \frac{1}{2\alpha_t}|y-x_t|^2 \big)$. Convergence properties are discussed in the proximal gradient framework (A2.88).

A2.85

Epigraphs and Closed Convex Functions

The epigraph of a convex function $F$ is $\operatorname{epi}(F) = \{(x,a)\in\mathbb{R}^d\times\mathbb{R} : F(x)\le a\}$. It is always convex. $F$ is closed if $\operatorname{epi}(F)$ is closed, equivalently, all sub‑level sets $\{x:F(x)\le a\}$ are closed (Proposition 3.41). Continuous convex functions are closed. The indicator function $\sigma_\Omega$ of a closed convex $\Omega$ is closed.

A2.86

Subgradients and the Subdifferential

For a convex function $F$ and $x\in\operatorname{dom}(F)$, a vector $g\in\mathbb{R}^d$ is a subgradient if

\[ F(y) \ge F(x) + g^T(y-x) \quad \forall y\in\mathbb{R}^d. \]

The set of all subgradients, subdifferential $\partial F(x)$, is closed convex. If $F$ is differentiable at $x$, $\partial F(x)=\{\nabla F(x)\}$. At a relative interior point, $\partial F(x)\neq\emptyset$ and its projection onto the affine hull is compact (Proposition 3.45). Subdifferentials are additive under mild conditions (Theorem 3.46) and respect affine composition (Theorem 3.47).

The normal cone is the subdifferential of the indicator function: $\partial\sigma_\Omega(x)=N_\Omega(x)$ for $x\in\Omega$.

A2.87

Directional Derivatives

The directional derivative of a convex $F$ at $x\in\operatorname{dom}(F)$ in direction $h$ is

\[ dF(x,h) = \lim_{t\downarrow 0} \frac{F(x+th)-F(x)}{t} \in [-\infty,\infty]. \]

It is positively homogeneous and subadditive in $h$ (hence convex). $x^*$ is a minimizer iff $dF(x^*,h)\ge 0$ for all $h$. For $x\in\operatorname{ri}(\operatorname{dom}(F))$, $dF(x,h) = \max\{g^T h : g\in\partial F(x)\}$ (Proposition 3.52).

A2.88

Subgradient Descent

When $F$ is non‑differentiable, the direction $h = -\operatorname{argmin}\{|g| : g\in\partial F(x)\}$ (the minimal‑norm subgradient) is a descent direction. The subgradient descent iteration $x_{t+1}=x_t - \alpha_t g_t$ with $g_t\in\partial F(x_t)$ can be combined with averaging: define $\bar{x}_t = (\sum_{j=1}^t \alpha_j x_j)/(\sum_{j=1}^t \alpha_j)$, which converges to a minimizer under convexity and suitable step sizes.

A2.89

Proximal Operator

For a closed convex function $F$, the proximal operator is

\[ \operatorname{prox}_F(x) = \operatorname{argmin}_{v\in\mathbb{R}^d}\left( F(v) + \frac12 |x-v|^2 \right). \]

It satisfies $x \in x' + \partial F(x')$ iff $x' = \operatorname{prox}_F(x)$. Thus minimizers of $F$ are fixed points of $\operatorname{prox}_{\alpha F}$. The proximal operator is 1‑Lipschitz (Proposition 3.56). Example: $F(x)=\lambda|x|$ yields the soft‑thresholding operator $\operatorname{prox}_{\lambda|\cdot|}(x) = \operatorname{sign}(x)\max(|x|-\lambda,0)$. For $F=\sigma_\Omega$, $\operatorname{prox}_{\sigma_\Omega} = \operatorname{proj}_\Omega$.

A2.90

Proximal Gradient Descent

Minimize $F = G + H$ with $G$ $C^1$ and $H$ closed convex. The proximal gradient descent iteration is

\[ x_{t+1} = \operatorname{prox}_{\alpha_t H}\big( x_t - \alpha_t \nabla G(x_t) \big). \tag{3.49} \]

If $G$ is $L$$C^1$ and $\alpha_t \le 2/L$, the objective decreases. A stationary point satisfies $-\nabla G(x)\in\partial H(x)$, which is the optimality condition.

A2.91

Convergence of Proximal Gradient Descent

Theorem 3.57 (convex case). If $G$ is $L$$C^1$ and convex, $H$ closed convex, and a minimizer $x^*$ exists, then with constant step $\alpha \le 1/L$,

\[ F(x_T) - F(x^*) \le \frac{|x_0-x^*|^2}{2\alpha T}. \]

Theorem 3.58 (strongly convex case). If, in addition, $G$ is $C^2$ with eigenvalues of $\nabla^2 G$ in $[m,L]$, $m>0$, then with constant step $\alpha < 1/L$,

\[ |x_t - x^*| \le (1-\alpha m)^t |x_0 - x^*|. \]

These results include projected gradient descent as a special case ($H=\sigma_\Omega$).

A2.92

Proximal Point Algorithm

When $G=0$, the scheme reduces to the proximal point algorithm:

\[ x_{t+1} = \operatorname{prox}_{\alpha F}(x_t). \]

It converges to a minimizer for any $\alpha>0$ if $F$ is closed convex (a consequence of Theorem 3.57).

A2.93

Generalized KKT Conditions (Non‑smooth Convex Case)

Consider minimizing a closed convex function $F$ over a closed convex set $\Omega \subset \operatorname{ri}(\operatorname{dom}(F))$. For a minimizer $x^*$, the optimality condition generalizes to

\[ 0 \in \partial F(x^*) + N_\Omega(x^*), \]

where $N_\Omega(x)$ is the normal cone. This follows because the indicator $\sigma_\Omega$ is closed convex and $\partial\sigma_\Omega(x)=N_\Omega(x)$. The condition is both necessary and sufficient (Theorem 3.59).

Now specialise to $\Omega = \{x\in\mathbb{R}^d : \gamma_i(x)=0,\;i\in E,\; \gamma_i(x)\le 0,\;i\in I\}$ with $\gamma_i$ affine for $i\in E$ and closed convex for $i\in I$. For $x\in\Omega$ with active set $\mathcal{A}(x)=\{i\in\mathcal{C}:\gamma_i(x)=0\}$, define

\[ N'_\gamma(x) = \Big\{ \sum_{i\in\mathcal{A}(x)} \lambda_i s_i : s_i\in\partial\gamma_i(x),\; \lambda_i\ge 0 \text{ if } i\in I \Big\}. \]

The KKT conditions in the non‑smooth case read $0 \in \partial F(x^*) + N'_\gamma(x^*)$, which holds provided $N_\Omega(x^*) = N'_\gamma(x^*)$. The Slater constraint qualification (Sl‑CQ) ensures this equality:

  • (Sl 1) The vectors $\{b_i : i\in E\}$ (gradients of affine equalities) are linearly independent.
  • (Sl 2) There exists $x$ such that $\gamma_i(x)=0$ for $i\in E$ and $\gamma_i(x) < 0$ for all $i\in I$.

Sl‑CQ is weaker than the Mangasarian‑Fromovitz CQ when the $\gamma_i$ are $C^1$, but is equivalent under differentiability (Proposition 3.61). Theorem 3.62 states that under Sl‑CQ, if $x^*$ is a minimizer, then there exist $s_0\in\partial F(x^*)$, $s_i\in\partial\gamma_i(x^*)$ for $i\in\mathcal{A}(x^*)$, and multipliers $\lambda_i\ge 0$ (with $\lambda_i=0$ for inactive constraints) such that $s_0 + \sum \lambda_i s_i = 0$.

A2.94

Dual Problem and Saddle Points

Define the Lagrangian $\mathcal{L}(x,\lambda) = F(x) + \sum_{i\in\mathcal{C}} \lambda_i \gamma_i(x)$, with $\lambda\in D = \{\lambda : \lambda_i\ge 0,\; i\in I\}$. For any $x\in\Omega$, $\lambda\in D$, we have $\mathcal{L}(x,\lambda) \le F(x)$. Let

\[ \mathcal{L}^*(\lambda) = \inf_{x\in\mathbb{R}^d} \mathcal{L}(x,\lambda), \]

so that $\mathcal{L}^*(\lambda) \le F(x)$ for all $x\in\Omega$. The dual problem is $\hat d = \sup_{\lambda\in D} \mathcal{L}^*(\lambda)$ and the primal problem is $\hat p = \inf_{x\in\Omega} F(x)$. Always $\hat d \le \hat p$ (weak duality).

Under the Slater conditions, the duality gap vanishes: $\hat d = \hat p$. Moreover, any solution $\lambda^*$ of the dual provides multipliers satisfying the KKT conditions, and conversely (Theorem 3.63). The pair $(x^*,\lambda^*)\in\Omega\times D$ satisfies the KKT conditions iff it is a saddle point of $\mathcal{L}$:

\[ \mathcal{L}(x^*,\lambda) \le \mathcal{L}(x^*,\lambda^*) \le \mathcal{L}(x,\lambda^*) \quad \forall x\in\mathbb{R}^d,\; \forall \lambda\in D. \]

Thus, under constraint qualifications, solving the primal is equivalent to finding a saddle point of $\mathcal{L}$, and the dual optimum equals the primal optimum.

A2.95

Example: Quadratic Programming (SVM Dual)

Consider the quadratic program (support vector machine formulation) with variables $x\in\mathbb{R}^d$, $x_0\in\mathbb{R}$, $\xi\in\mathbb{R}^N$, parameter $\gamma>0$:

\[ \min \frac12 \|x\|^2 + \gamma \sum_{k=1}^N \xi^{(k)} \quad \text{s.t. } \xi^{(k)}\ge 0,\; b_k(x_0 + x^T a_k) + \xi^{(k)} \ge 1, \]

where $b_k\in\{-1,1\}$, $a_k\in\mathbb{R}^n$. Introduce multipliers $\alpha_k\ge 0$ (for the second constraint) and $\eta_k\ge 0$ (for $\xi^{(k)}\ge 0$). The Lagrangian is

\[ \mathcal{L}(x,x_0,\xi,\alpha,\eta) = \frac12\|x\|^2 + \gamma\sum\xi^{(k)} - \sum\eta_k\xi^{(k)} - \sum\alpha_k\big(b_k(x_0+x^T a_k)+\xi^{(k)}-1\big). \]

Minimizing over the primal variables yields $\sum\alpha_k b_k = 0$, $x = \sum\alpha_k b_k a_k$, and $\gamma - \eta_k - \alpha_k = 0$ with $\eta_k\ge 0 \Rightarrow 0\le\alpha_k\le\gamma$. Substituting back gives the dual problem

\[ \max_{0\le\alpha_k\le\gamma,\; \sum\alpha_k b_k = 0} \left( -\frac12 \sum_{k,l=1}^N \alpha_k\alpha_l b_k b_l a_k^T a_l + \sum_{k=1}^N \alpha_k \right). \]

The dual is a quadratic program with simple box constraints and one linear equality constraint, and its solution $\alpha^*$ yields the primal minimizer $x^* = \sum \alpha_k^* b_k a_k$.

A2.96

Proximal Iterations and Augmented Lagrangian

The dual function $\mathcal{L}^*$ is concave; maximizing it is equivalent to minimizing $-\mathcal{L}^*$. The proximal point algorithm applied to $-\mathcal{L}^*$ yields

\[ \lambda(t+1) = \operatorname{prox}_{-\alpha_t \mathcal{L}^*}(\lambda(t)) = \operatorname{argmax}_{\mu\in D}\left( \mathcal{L}^*(\mu) - \frac{1}{2\alpha_t}\|\mu-\lambda(t)\|^2 \right). \]

Define the augmented Lagrangian function $\phi(x,\mu) = F(x) + \sum_{i\in\mathcal{C}} \mu_i \gamma_i(x) - \frac{1}{2\alpha_t}\|\mu-\lambda(t)\|^2$. Under appropriate conditions (e.g., compact sub‑level sets of $F$ on $\Omega$), minimax equality holds:

\[ \max_{\mu\in D}\inf_{x\in\mathbb{R}^d} \phi(x,\mu) = \inf_{x\in\mathbb{R}^d}\sup_{\mu\in D} \phi(x,\mu). \]

The inner maximization over $\mu$ can be solved in closed form: for $i\in E$, $\mu_i = \lambda_i(t) + \alpha_t \gamma_i(x)$; for $i\in I$, $\mu_i = \max(0, \lambda_i(t) + \alpha_t \gamma_i(x))$. Substituting back gives the augmented Lagrangian algorithm:

\[ \begin{cases} x(t) = \operatorname{argmin}_{x\in\mathbb{R}^d} \Big( F(x) + \frac{1}{2\alpha_t}\sum_{i\in E} (\lambda_i(t)+\alpha_t\gamma_i(x))^2 + \frac{1}{2\alpha_t}\sum_{i\in I} \max(0,\lambda_i(t)+\alpha_t\gamma_i(x))^2 \Big), \\ \lambda_i(t+1) = \lambda_i(t) + \alpha_t \gamma_i(x(t)), \quad i\in E, \\ \lambda_i(t+1) = \max(0,\; \lambda_i(t) + \alpha_t \gamma_i(x(t))), \quad i\in I. \end{cases} \]

Starting from $\lambda(0)$, the iterates $\lambda(t)$ converge to a solution of the dual problem, and cluster points of $x(t)$ (if they exist) are primal minimizers. The method works for convex problems; with small $\alpha_t$ it can also be applied to non‑convex settings.

A2.97

Alternative Direction Method of Multipliers (ADMM)

Consider the problem $\min_{x,z} \{ G(x) + H(z) : Ax + Bz = c \}$ with $G,H$ closed convex. The augmented Lagrangian method (with equality constraints) would jointly minimize over $(x,z)$. ADMM splits this into two easier subproblems. With fixed step size $\alpha>0$ and scaled multiplier $u = \lambda/\alpha$, the iterations are (after removing constants):

\[ \begin{cases} x_t = \operatorname{argmin}_{x} \big( G(x) + \frac{\alpha}{2}\| u_{t-1} + Ax + Bz_{t-1} - c \|^2 \big), \\ z_t = \operatorname{argmin}_{z} \big( H(z) + \frac{\alpha}{2}\| u_{t-1} + Ax_t + Bz - c \|^2 \big), \\ u_t = u_{t-1} + Ax_t + Bz_t - c. \end{cases} \]

This is the Alternative Direction Method of Multipliers (ADMM), also known as Douglas‑Rachford splitting. Under the assumptions that $G$ and $H$ are closed convex and the Lagrangian $\mathcal{L}(x,z,\lambda)=G(x)+H(z)+\lambda^T(Ax+Bz-c)$ has a saddle point, the iterates converge: $x_t, z_t$ to a primal solution, and $u_t$ (or $\lambda_t$) to a dual solution. ADMM is particularly efficient when the proximal operators of $G$ and $H$ are easy to compute.