Gradient and Hessian
For f : R n → R f : \mathbb{R}^n \to \mathbb{R} f : R n → R ,
∇ x f = [ ∂ f ∂ x 1 ⋮ ∂ f ∂ x n ] ∈ R n , ∇ x 2 f = [ ∂ 2 f ∂ x 1 2 ⋯ ∂ 2 f ∂ x 1 ∂ x n ⋮ ⋱ ⋮ ∂ 2 f ∂ x n ∂ x 1 ⋯ ∂ 2 f ∂ x n 2 ] ∈ R n × n \nabla_x f = \begin{bmatrix} \frac{\partial f}{\partial x_1} \\ \vdots \\ \frac{\partial f}{\partial x_n} \end{bmatrix} \in \mathbb{R}^n, \qquad \nabla_x^2 f = \begin{bmatrix} \frac{\partial^2 f}{\partial x_1^2} & \cdots & \frac{\partial^2 f}{\partial x_1 \partial x_n} \\ \vdots & \ddots & \vdots \\ \frac{\partial^2 f}{\partial x_n \partial x_1} & \cdots & \frac{\partial^2 f}{\partial x_n^2} \end{bmatrix} \in \mathbb{R}^{n \times n} ∇ x f = ∂ x 1 ∂ f ⋮ ∂ x n ∂ f ∈ R n , ∇ x 2 f = ∂ x 1 2 ∂ 2 f ⋮ ∂ x n ∂ x 1 ∂ 2 f ⋯ ⋱ ⋯ ∂ x 1 ∂ x n ∂ 2 f ⋮ ∂ x n 2 ∂ 2 f ∈ R n × n
Jacobian
For g : R n → R m g : \mathbb{R}^n \to \mathbb{R}^m g : R n → R m ,
g ( x 1 , … , x n ) = [ g 1 ( x 1 , … , x n ) ⋮ g m ( x 1 , … , x n ) ] g(x_1, \ldots, x_n) = \begin{bmatrix} g_1(x_1, \ldots, x_n) \\ \vdots \\ g_m(x_1, \ldots, x_n) \end{bmatrix} g ( x 1 , … , x n ) = g 1 ( x 1 , … , x n ) ⋮ g m ( x 1 , … , x n )
for each g i : R n → R g_i : \mathbb{R}^n \to \mathbb{R} g i : R n → R . Then the analogue of a derivative is the Jacobian matrix
J g ( x ) = ∇ x g ( x ) = [ ∇ g 1 ( x ) T ⋮ ∇ g m ( x ) T ] = [ ∂ g 1 ∂ x 1 ⋯ ∂ g 1 ∂ x n ⋮ ⋱ ⋮ ∂ g m ∂ x 1 ⋯ ∂ g m ∂ x n ] ∈ R m × n J_g(x) = \nabla_x g(x) = \begin{bmatrix} \nabla g_1(x)^T \\ \vdots \\ \nabla g_m(x)^T \end{bmatrix} = \begin{bmatrix} \frac{\partial g_1}{\partial x_1} & \cdots & \frac{\partial g_1}{\partial x_n} \\ \vdots & \ddots & \vdots \\ \frac{\partial g_m}{\partial x_1} & \cdots & \frac{\partial g_m}{\partial x_n} \end{bmatrix} \in \mathbb{R}^{m \times n} J g ( x ) = ∇ x g ( x ) = ∇ g 1 ( x ) T ⋮ ∇ g m ( x ) T = ∂ x 1 ∂ g 1 ⋮ ∂ x 1 ∂ g m ⋯ ⋱ ⋯ ∂ x n ∂ g 1 ⋮ ∂ x n ∂ g m ∈ R m × n
Integrals
The standard notation for an integral over x ⃗ ∈ R n \vec{x} \in \mathbb{R}^n x ∈ R n is
∫ f ( … ) d x ⃗ = ∫ ∫ ⋯ ∫ f ( … ) d x 1 d x 2 … d x n \int f(\ldots) \, d\vec{x} = \int \int \cdots \int f(\ldots) \, dx_1 \, dx_2 \ldots dx_n ∫ f ( … ) d x = ∫∫ ⋯ ∫ f ( … ) d x 1 d x 2 … d x n
Supremum and Infimum
For f : V → F f : V \to \mathbb{F} f : V → F with an ordering on F \mathbb{F} F , sup f ( x ) = x sup \sup f(x) = x_{\sup} sup f ( x ) = x s u p such that
x sup ≥ f ( x ) x_{\sup} \ge f(x) x s u p ≥ f ( x ) for all x ∈ V x \in V x ∈ V , i.e. x sup x_{\sup} x s u p is an upper bound,
x sup ≤ u x_{\sup} \le u x s u p ≤ u for every upper bound u u u .
Note x sup ∈ F x_{\sup} \in \mathbb{F} x s u p ∈ F but it is not necessarily in the range of f f f . If f f f has a max, it is the supremum. In R \mathbb{R} R , this is the concept of least upper bound .
And inf f ( x ) = x inf \inf f(x) = x_{\inf} inf f ( x ) = x i n f such that x inf ≤ f ( x ) x_{\inf} \le f(x) x i n f ≤ f ( x ) for all x x x , and x inf ≥ ℓ x_{\inf} \ge \ell x i n f ≥ ℓ for every lower bound ℓ \ell ℓ . In R \mathbb{R} R this is the greatest lower bound . If a min exists, it is the infimum.
Taylor Expansions
For f : R n → R f : \mathbb{R}^n \to \mathbb{R} f : R n → R , we can approximate around a point x 0 x_0 x 0 using its Taylor series.
First-order approximation:
f ( x ) ≈ f ( x 0 ) + ∇ x f ( x 0 ) T ( x − x 0 ) f(x) \approx f(x_0) + \nabla_x f(x_0)^T (x - x_0) f ( x ) ≈ f ( x 0 ) + ∇ x f ( x 0 ) T ( x − x 0 )
Second-order approximation:
f ( x ) ≈ f ( x 0 ) + ∇ x f ( x 0 ) T ( x − x 0 ) + 1 2 ( x − x 0 ) T ∇ 2 f ( x 0 ) ( x − x 0 ) f(x) \approx f(x_0) + \nabla_x f(x_0)^T (x - x_0) + \frac{1}{2}(x - x_0)^T \nabla^2 f(x_0)(x - x_0) f ( x ) ≈ f ( x 0 ) + ∇ x f ( x 0 ) T ( x − x 0 ) + 2 1 ( x − x 0 ) T ∇ 2 f ( x 0 ) ( x − x 0 )
The notation O ( h n ) O(h^n) O ( h n ) is used to account for the dropped terms in the infinite Taylor series. E.g. let h = x − x 0 h = x - x_0 h = x − x 0 ,
f ( x 0 + h ) = f ( x 0 ) + ∇ f ( x 0 ) T h + O ( ∥ h ∥ 2 ) f(x_0 + h) = f(x_0) + \nabla f(x_0)^T h + O(\|h\|^2) f ( x 0 + h ) = f ( x 0 ) + ∇ f ( x 0 ) T h + O ( ∥ h ∥ 2 )
the error term (dropped terms) shrinks as fast as ∥ h ∥ 2 \|h\|^2 ∥ h ∥ 2 .
Calculus with Matrices
Linear form For a , x ∈ R n a, x \in \mathbb{R}^n a , x ∈ R n , f ( x ) = a T x f(x) = a^T x f ( x ) = a T x ,
∇ x f = a , ∇ x 2 f = 0 , ∇ x ( x ) = I n \nabla_x f = a, \qquad \nabla_x^2 f = 0, \qquad \nabla_x(x) = I_n ∇ x f = a , ∇ x 2 f = 0 , ∇ x ( x ) = I n
Quadratic form For x ∈ R n x \in \mathbb{R}^n x ∈ R n , A ∈ R n × n A \in \mathbb{R}^{n \times n} A ∈ R n × n , f ( x ) = x T A x f(x) = x^T A x f ( x ) = x T A x ,
∇ x f = ( A + A T ) x , ∇ x 2 f = A + A T \nabla_x f = (A + A^T)x, \qquad \nabla_x^2 f = A + A^T ∇ x f = ( A + A T ) x , ∇ x 2 f = A + A T
Euclidean norm f ( x ) = ∥ x ∥ 2 2 = x T x f(x) = \|x\|_2^2 = x^T x f ( x ) = ∥ x ∥ 2 2 = x T x ,
∇ x f = 2 x , ∇ x 2 f = 2 I n \nabla_x f = 2x, \qquad \nabla_x^2 f = 2I_n ∇ x f = 2 x , ∇ x 2 f = 2 I n
Least squares For A ∈ R m × n A \in \mathbb{R}^{m \times n} A ∈ R m × n , x ∈ R n x \in \mathbb{R}^n x ∈ R n , b ∈ R m b \in \mathbb{R}^m b ∈ R m ,
f ( x ) = ∥ A x − b ∥ 2 2 = ( A x − b ) T ( A x − b ) = x T A T A x − 2 b T A x + b T b f(x) = \|Ax - b\|_2^2 = (Ax - b)^T(Ax - b) = x^T A^T A x - 2b^T A x + b^T b f ( x ) = ∥ A x − b ∥ 2 2 = ( A x − b ) T ( A x − b ) = x T A T A x − 2 b T A x + b T b
∇ x f = 2 A T ( A x − b ) , ∇ x 2 f = 2 A T A \nabla_x f = 2A^T(Ax - b), \qquad \nabla_x^2 f = 2A^T A ∇ x f = 2 A T ( A x − b ) , ∇ x 2 f = 2 A T A
Convexity
A function f : R n → R f : \mathbb{R}^n \to \mathbb{R} f : R n → R is convex if
f ( λ x + ( 1 − λ ) y ) ≤ λ f ( x ) + ( 1 − λ ) f ( y ) , ∀ x , y ∈ R n , ∀ λ ∈ [ 0 , 1 ] f(\lambda x + (1 - \lambda)y) \le \lambda f(x) + (1 - \lambda) f(y), \quad \forall x, y \in \mathbb{R}^n,\ \forall \lambda \in [0,1] f ( λ x + ( 1 − λ ) y ) ≤ λ f ( x ) + ( 1 − λ ) f ( y ) , ∀ x , y ∈ R n , ∀ λ ∈ [ 0 , 1 ]
Intuitively, the line segment between any 2 points on the graph of f f f lies above or on the graph. Concavity is the reverse, where the segment lies below.
For twice differentiable f f f , an equivalent statement is
f f f is convex iff ∇ 2 f \nabla^2 f ∇ 2 f is positive semidefinite everywhere,
f f f is concave iff ∇ 2 f \nabla^2 f ∇ 2 f is negative semidefinite everywhere.