Throughout, f : R n → R f : \mathbb{R}^n \to \mathbb{R} f : R n → R .
First-Order Condition
For an extremum point x ∈ R n x \in \mathbb{R}^n x ∈ R n of a differentiable f f f ,
∇ x f ( x ) = 0 ⃗ , 0 ⃗ ∈ R n \nabla_x f(x) = \vec{0}, \quad \vec{0} \in \mathbb{R}^n ∇ x f ( x ) = 0 , 0 ∈ R n
Second-Order Condition
For a point x x x with ∇ x f ( x ) = 0 ⃗ \nabla_x f(x) = \vec{0} ∇ x f ( x ) = 0 ,
if ∇ x 2 f ( x ) \nabla_x^2 f(x) ∇ x 2 f ( x ) is positive definite, the function is locally convex at x x x → \to → local minimum,
if ∇ x 2 f ( x ) \nabla_x^2 f(x) ∇ x 2 f ( x ) is negative definite, the function is locally concave at x x x → \to → local maximum.
Note if f : R → R f : \mathbb{R} \to \mathbb{R} f : R → R , then ∇ f = f ′ \nabla f = f' ∇ f = f ′ and ∇ 2 f = f ′ ′ \nabla^2 f = f'' ∇ 2 f = f ′′ . Also only for f : R → R f : \mathbb{R} \to \mathbb{R} f : R → R , ∇ x 2 f \nabla_x^2 f ∇ x 2 f being positive definite means f ′ ′ ( x ) > 0 f''(x) > 0 f ′′ ( x ) > 0 , and negative definite means f ′ ′ ( x ) < 0 f''(x) < 0 f ′′ ( x ) < 0 .
Global Extrema
Not so simple, but
convex function ⟹ \implies ⟹ any local minimum is a global minimum,
concave function ⟹ \implies ⟹ any local maximum is a global maximum.
See convexity .
Lagrange Multipliers
Let
x ∈ R n x \in \mathbb{R}^n x ∈ R n (point),
f : R n → R f : \mathbb{R}^n \to \mathbb{R} f : R n → R (objective function),
g : R n → R m g : \mathbb{R}^n \to \mathbb{R}^m g : R n → R m (m m m many equality constraints),
λ ∈ R m \lambda \in \mathbb{R}^m λ ∈ R m (one Lagrange multiplier per constraint).
We want to solve
min (or max) f ( x ) s.t. g ( x ) = 0 \min \text{ (or max) } f(x) \quad \text{s.t.} \quad g(x) = 0 min (or max) f ( x ) s.t. g ( x ) = 0
or the same thing with scalar valued functions, g 1 ( x ) = 0 , … , g m ( x ) = 0 g_1(x) = 0, \ldots, g_m(x) = 0 g 1 ( x ) = 0 , … , g m ( x ) = 0 . Define the Lagrangian
L ( x , λ ) = f ( x ) + λ T g ( x ) = f ( x ) + ∑ i = 1 m λ i g i ( x ) \mathcal{L}(x, \lambda) = f(x) + \lambda^T g(x) = f(x) + \sum_{i=1}^{m} \lambda_i g_i(x) L ( x , λ ) = f ( x ) + λ T g ( x ) = f ( x ) + i = 1 ∑ m λ i g i ( x )
Then if x x x is an extremum (and the constraint gradients ∇ g i ( x ) \nabla g_i(x) ∇ g i ( x ) are linearly independent), there is a multiplier λ \lambda λ such that
∇ x L ( x , λ ) = ∇ x f ( x ) + ∇ x g ( x ) T λ = ∇ x f ( x ) + ∑ i = 1 m λ i ∇ x g i ( x ) = 0 \nabla_x \mathcal{L}(x, \lambda) = \nabla_x f(x) + \nabla_x g(x)^T \lambda = \nabla_x f(x) + \sum_{i=1}^{m} \lambda_i \nabla_x g_i(x) = 0 ∇ x L ( x , λ ) = ∇ x f ( x ) + ∇ x g ( x ) T λ = ∇ x f ( x ) + ∑ i = 1 m λ i ∇ x g i ( x ) = 0 (stationarity),
g ( x ) = 0 ⃗ g(x) = \vec{0} g ( x ) = 0 , i.e. g i ( x ) = 0 g_i(x) = 0 g i ( x ) = 0 for all i i i (feasibility).
KKT Conditions
Let
x ∈ R n x \in \mathbb{R}^n x ∈ R n (point),
f : R n → R f : \mathbb{R}^n \to \mathbb{R} f : R n → R (objective function),
g : R n → R m g : \mathbb{R}^n \to \mathbb{R}^m g : R n → R m (m m m many equality constraints),
h : R n → R p h : \mathbb{R}^n \to \mathbb{R}^p h : R n → R p (p p p many inequality constraints),
λ ∈ R m \lambda \in \mathbb{R}^m λ ∈ R m (one Lagrange multiplier per equality constraint),
μ ∈ R p \mu \in \mathbb{R}^p μ ∈ R p (one Lagrange multiplier per inequality constraint).
We want to solve
min f ( x ) s.t. g ( x ) = 0 , h ( x ) ≤ 0 \min f(x) \quad \text{s.t.} \quad g(x) = 0, \quad h(x) \le 0 min f ( x ) s.t. g ( x ) = 0 , h ( x ) ≤ 0
(to maximize, minimize − f -f − f ).
L ( x , λ , μ ) = f ( x ) + λ T g ( x ) + μ T h ( x ) = f ( x ) + ∑ i = 1 m λ i g i ( x ) + ∑ i = 1 p μ i h i ( x ) \mathcal{L}(x, \lambda, \mu) = f(x) + \lambda^T g(x) + \mu^T h(x) = f(x) + \sum_{i=1}^{m} \lambda_i g_i(x) + \sum_{i=1}^{p} \mu_i h_i(x) L ( x , λ , μ ) = f ( x ) + λ T g ( x ) + μ T h ( x ) = f ( x ) + i = 1 ∑ m λ i g i ( x ) + i = 1 ∑ p μ i h i ( x )
The following are the KKT conditions for a point x x x and multipliers λ , μ \lambda, \mu λ , μ :
∇ x L ( x , λ , μ ) = ∇ x f ( x ) + ∇ x g ( x ) T λ + ∇ x h ( x ) T μ = 0 \nabla_x \mathcal{L}(x, \lambda, \mu) = \nabla_x f(x) + \nabla_x g(x)^T \lambda + \nabla_x h(x)^T \mu = 0 ∇ x L ( x , λ , μ ) = ∇ x f ( x ) + ∇ x g ( x ) T λ + ∇ x h ( x ) T μ = 0 (stationarity), equivalently ∇ x f ( x ) + ∑ i = 1 m λ i ∇ x g i ( x ) + ∑ i = 1 p μ i ∇ x h i ( x ) = 0 \nabla_x f(x) + \sum_{i=1}^{m} \lambda_i \nabla_x g_i(x) + \sum_{i=1}^{p} \mu_i \nabla_x h_i(x) = 0 ∇ x f ( x ) + ∑ i = 1 m λ i ∇ x g i ( x ) + ∑ i = 1 p μ i ∇ x h i ( x ) = 0 ,
g ( x ) = 0 g(x) = 0 g ( x ) = 0 , h ( x ) ≤ 0 h(x) \le 0 h ( x ) ≤ 0 (primal feasibility),
μ ≥ 0 \mu \ge 0 μ ≥ 0 (dual feasibility),
μ T h ( x ) = 0 \mu^T h(x) = 0 μ T h ( x ) = 0 (complementary slackness).
Complementary slackness means for each i i i , either μ i = 0 \mu_i = 0 μ i = 0 , meaning the constraint is not active, or h i ( x ) = 0 h_i(x) = 0 h i ( x ) = 0 , meaning the constraint is active.
For a minimum x x x (under a constraint qualification, e.g. linearly independent gradients of the active constraints), there are λ , μ \lambda, \mu λ , μ such that the KKT conditions hold, i.e. x x x is an extremum only if the KKT conditions hold. If f f f and h h h are convex and g g g is affine, the KKT conditions are also sufficient .