Lesson 37: Conditions for Unconstrained Optimality¶
37.1 Learning Outcomes¶
By the end of this hour a student will be able to:
- State and apply the necessary and sufficient conditions for a single-variable optimum.
- Apply the higher-order derivative test when \(f''(x^{*})=0\).
- Find stationary points of a multivariable function by solving \(\nabla f=\mathbf{0}\).
- Classify them with the Hessian and the leading-principal-minor test.
- Solve applied unconstrained optimisation problems and interpret the answers.
37.2 Single-Variable Optimality¶
Necessary condition¶
Theorem (first-order necessary condition). If \(f\) is differentiable and \(x^{*}\) is a local minimum or maximum in the interior of the domain, then \(f'(x^{*})=0\).
A point with \(f'(x^{*})=0\) is a stationary (or critical) point. The condition is necessary, not sufficient — it is also satisfied at maxima and at inflection points.
Two ways this can mislead. (i) \(f(x)=x^3\) has \(f'(0)=0\) but \(0\) is neither a max nor a min. (ii) \(f(x)=|x|\) has a minimum at \(0\) where \(f'\) does not exist. Non-differentiable points must be checked separately, as must the endpoints of a closed interval.
Sufficient condition¶
Theorem (second-order sufficient condition). If \(f'(x^{*})=0\) and $\(f''(x^{*})>0 \Rightarrow x^{*}\text{ is a strict local MINIMUM},\)$ $\(f''(x^{*})<0 \Rightarrow x^{*}\text{ is a strict local MAXIMUM}.\)$ If \(f''(x^{*})=0\) the test is inconclusive.
The higher-order test¶
When \(f''(x^{*})=0\), differentiate until a derivative is non-zero.
Theorem. Suppose \(f'(x^{*})=f''(x^{*})=\dots=f^{(n-1)}(x^{*})=0\) but \(f^{(n)}(x^{*})\ne0\). Then:
\(n\) \(f^{(n)}(x^{*})\) Conclusion even \(>0\) local minimum even \(<0\) local maximum odd any inflection — neither
Why. Taylor's theorem gives \(f(x^{*}+h)-f(x^{*})=\dfrac{f^{(n)}(x^{*})}{n!}h^{n}+o(h^{n})\). If \(n\) is even, \(h^{n}>0\) for both signs of \(h\), so the difference keeps one sign. If \(n\) is odd, \(h^{n}\) changes sign with \(h\), so \(f\) rises on one side and falls on the other.
37.3 Multivariable Optimality¶
The gradient and the Hessian¶
\(H\) is symmetric whenever the second partials are continuous (Young's theorem).
Necessary condition. \(\nabla f(\mathbf{x}^{*})=\mathbf{0}\).
Sufficient conditions. With \(\nabla f(\mathbf{x}^{*})=\mathbf{0}\),
\(H(\mathbf{x}^{*})\) Conclusion positive definite strict local minimum negative definite strict local maximum indefinite saddle point semi-definite (singular) inconclusive
Testing definiteness¶
Leading principal minors (Sylvester's criterion). Let \(D_k\) be the determinant of the top-left \(k\times k\) block.
- Positive definite \(\iff D_1>0,\ D_2>0,\ \dots,\ D_n>0\) — all positive.
- Negative definite \(\iff D_1<0,\ D_2>0,\ D_3<0,\dots\) — signs alternate, starting negative.
- Otherwise, if \(\det H\ne0\), the matrix is indefinite.
Eigenvalues give the same answer and are more informative: all \(\lambda_i>0\) (definite positive), all \(<0\) (definite negative), mixed signs (indefinite), some zero (semi-definite, inconclusive).
The convexity shortcut¶
If \(f\) is convex on the whole domain (Lesson 36), then \(\nabla f(\mathbf{x}^{*})=\mathbf{0}\) is both necessary and sufficient for a global minimum — no second-order test at the point is needed, and no other stationary point can be better.
37.4 Solved Problems¶
Problem 1 — The complete single-variable procedure¶
Find and classify all stationary points of \(f(x)=x^{3}-3x+1\), and find the global optimum on \([-3,3]\).
Solution.
Step 1 — stationary points.
Step 2 — classify.
Step 3 — the global optimum on \([-3,3]\) requires the endpoints too.
| \(x\) | \(-3\) | \(-1\) | \(1\) | \(3\) |
|---|---|---|---|---|
| \(f(x)\) | \(-17\) | \(3\) | \(-1\) | \(19\) |
Interpretation. Neither global optimum is at a stationary point. On a closed interval the optimum may sit at a boundary, where the derivative need not vanish. Forgetting the endpoints is the most common error in single-variable optimisation, and it is the reason Unit IV's constrained theory (Lessons 43–44) exists at all: a constraint is exactly a boundary that the derivative test cannot see.
Problem 2 — When the second derivative vanishes¶
Classify the stationary point at \(x=0\) for (a) \(f(x)=x^{4}\), (b) \(g(x)=x^{5}\), (c) \(h(x)=-x^{6}\).
Solution.
(a) \(f(x)=x^{4}\).
At \(x=0\): \(f'=f''=f'''=0\) and \(f^{(4)}=24\ne0\). Here \(n=4\), even, and \(f^{(4)}>0\).
(b) \(g(x)=x^{5}\).
First non-zero derivative at \(0\) is the 5th, which is odd.
Indeed \(g(-0.1)=-10^{-5}<0<10^{-5}=g(0.1)\): the function passes straight through.
(c) \(h(x)=-x^{6}\). First non-zero derivative is the 6th, \(h^{(6)}=-720<0\); \(n=6\) is even.
Interpretation. Note that in case (a) the minimum is perfectly genuine but completely invisible to the second-derivative test. Numerically this matters: near a "flat" minimum like \(x^4\), the gradient is tiny over a wide region, so gradient-based algorithms crawl. A vanishing second derivative signals a hard problem for an algorithm, not just for the classification.
Problem 3 — A two-variable minimum¶
Find and classify the stationary points of
Solution.
Step 1 — gradient.
Step 2 — solve. From the first, \(x_2=6-2x_1\). Substituting:
Step 3 — Hessian.
Positive definite (eigenvalues \(3\) and \(1\)).
Step 4 — is it global? \(H\) is constant and positive definite everywhere, so \(f\) is strictly convex on \(\mathbb{R}^{2}\). By Lesson 36's theorem the local minimum is the unique global minimum.
Check by an independent route — completing the square.
a sum of two non-negative terms minus \(1\), minimised at \(x_2=4\) and \(x_1+2-3=0\), i.e. \(x_1=1\), with value \(-1\) ✓. Completing the square is a reliable check on any two-variable quadratic.
Problem 4 — A saddle and a genuine maximum¶
Find and classify all stationary points of
Solution.
Step 1 — gradient.
Substituting: \(x_1=(x_1^{2})^{2}=x_1^{4}\), so \(x_1(x_1^{3}-1)=0\), giving \(x_1=0\) or \(x_1=1\).
Step 2 — Hessian.
At \((0,0)\):
Indefinite (eigenvalues \(\pm3\)).
At \((1,1)\):
Positive definite (eigenvalues \(3\) and \(9\)).
Step 3 — global? No. \(H\) depends on \(\mathbf{x}\) and is indefinite at the origin, so \(f\) is not convex and Lesson 36's theorem does not apply. Indeed along \(x_2=0\), \(f=x_1^{3}\to-\infty\) as \(x_1\to-\infty\): the function is unbounded below and has no global minimum at all.
Interpretation. This example carries the central warning of unconstrained optimisation. An algorithm started near \((1,1)\) converges there and reports \(\nabla f=\mathbf{0}\) with a positive-definite Hessian — a certificate of a local minimum. That certificate says nothing whatever about the rest of \(\mathbb{R}^{2}\), where the function falls without bound. Local optimality is all that gradient-based methods can ever deliver on a non-convex problem.
Problem 5 — An applied problem: profit maximisation¶
A firm makes two products. Selling \(x_1\) and \(x_2\) units per week yields a weekly profit
Find the profit-maximising output and prove it is the global maximum. Interpret the cross-term.
Solution.
Step 1 — gradient.
Step 2 — solve.
From (i), \(x_2=50-2x_1\). Substituting into (ii):
Step 3 — Hessian.
Signs alternate starting negative \(\Rightarrow\) negative definite \(\Rightarrow\) \(P\) is strictly concave, and since \(H\) is constant this holds everywhere.
Step 4 — the profit.
Interpretation of the cross-term. The \(-2x_1x_2\) term means the products compete: raising \(x_2\) lowers the marginal profit of \(x_1\) by \(2\) per unit, as they draw on the same market or the same capacity. Because of it the products cannot be planned separately. Ignoring the interaction — solving \(\partial P/\partial x_1=0\) with \(x_2\) treated as fixed at \(0\) — would give \(x_1=25\), \(x_2=20\) and a computed profit of
which is \(₹29{,}000\) a week worse than the true optimum. Interaction terms are precisely what single-variable reasoning cannot see, and they are why multivariable optimality conditions are needed rather than a sequence of one-variable ones.
37.5 Practice Problems¶
- Classify the stationary points of \(f(x)=2x^{3}-9x^{2}+12x-3\). (Answer: \(f'=6(x-1)(x-2)\); \(x=1\) local max \(f=2\); \(x=2\) local min \(f=1\))
- Classify \(x=0\) for \(f(x)=x^{6}-x^{4}\) — take care. (Answer: \(f'=6x^5-4x^3=2x^3(3x^2-2)\); at \(0\) the first non-zero derivative is \(f^{(4)}(0)=-24<0\), \(n=4\) even, so \(x=0\) is a local maximum; global minima at \(x=\pm\sqrt{2/3}\) with \(f=-4/27\))
- Find and classify the stationary point of \(f=3x_1^{2}+2x_2^{2}-4x_1x_2+6x_1-8x_2\). (Answer: \(\nabla f=0\) at \((1,3)\); \(H=\begin{pmatrix}6&-4\\-4&4\end{pmatrix}\), \(D_1=6>0\), \(D_2=8>0\) — strict global minimum, \(f=-9\))
- Show that \(f(x_1,x_2)=x_1^{2}-4x_1x_2+x_2^{2}\) has a saddle at the origin, and find two directions along which \(f\) increases and decreases. (Answer: \(D_2=1-4=-3<0\); \(f\) rises along \(x_2=0\) and falls along \(x_1=x_2\), where \(f=-2x_1^2\))
- An open-topped box is made from a \(12\times12\) cm sheet by cutting squares of side \(x\) from the corners. Maximise the volume. (Answer: \(V=x(12-2x)^2\), \(V'=(12-2x)(12-6x)\), so \(x=2\); \(V''(2)=-48<0\); \(V_{\max}=2(8)^2=128\) cm³)
37.6 Summary¶
- Necessary: \(f'(x^{*})=0\) in one variable, \(\nabla f(\mathbf{x}^{*})=\mathbf{0}\) in several. This is satisfied at maxima, minima, saddles and inflections alike.
- Sufficient (1-D): \(f''>0\) minimum, \(f''<0\) maximum. If \(f''=0\), use the higher-order test: first non-zero \(f^{(n)}\) with \(n\) even gives an extremum (sign of \(f^{(n)}\) decides which), \(n\) odd gives an inflection.
- Sufficient (\(n\)-D): \(H\) positive definite \(\Rightarrow\) minimum; negative definite \(\Rightarrow\) maximum; indefinite \(\Rightarrow\) saddle; singular \(\Rightarrow\) inconclusive.
- Sylvester's test: all leading minors positive \(\Rightarrow\) positive definite; alternating from negative \(\Rightarrow\) negative definite.
- If \(f\) is convex everywhere, \(\nabla f=\mathbf{0}\) alone certifies a global minimum. Check convexity first — it is the cheapest possible strengthening of a result.
- On a closed interval or bounded region, check the boundary: the global optimum is often there, where no derivative vanishes. This is the gap that Lessons 43–44 close.
- Cross-terms couple the variables. Optimising one variable at a time gives the wrong answer whenever \(\partial^{2}f/\partial x_1\partial x_2\ne0\).
Next lesson: L38 — One-dimensional minimisation: bracketing and elimination methods.
Practise now: unit4-nlp-search-lab.html → Stationary Point Finder: enter a function of one or
two variables, get its gradient, Hessian, eigenvalues and a classification of every stationary point,
plotted on a contour map.