Skip to content

Lesson 37: Conditions for Unconstrained Optimality

37.1 Learning Outcomes

By the end of this hour a student will be able to:

  1. State and apply the necessary and sufficient conditions for a single-variable optimum.
  2. Apply the higher-order derivative test when \(f''(x^{*})=0\).
  3. Find stationary points of a multivariable function by solving \(\nabla f=\mathbf{0}\).
  4. Classify them with the Hessian and the leading-principal-minor test.
  5. 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

\[\nabla f=\begin{pmatrix}\partial f/\partial x_1\\ \vdots\\ \partial f/\partial x_n\end{pmatrix}, \qquad \nabla^{2}f=H=\left[\frac{\partial^{2}f}{\partial x_i\partial x_j}\right]_{n\times n}\]

\(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.

\[\boxed{\text{convex} + \nabla f=\mathbf{0}\ \Longrightarrow\ \text{global minimum}}\]

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.

\[f'(x)=3x^{2}-3=0\ \Rightarrow\ x=\pm1\]

Step 2 — classify.

\[f''(x)=6x:\qquad f''(1)=6>0,\qquad f''(-1)=-6<0\]
\[\boxed{x=1\text{ is a local MINIMUM},\ f(1)=1-3+1=-1}\]
\[\boxed{x=-1\text{ is a local MAXIMUM},\ f(-1)=-1+3+1=3}\]

Step 3 — the global optimum on \([-3,3]\) requires the endpoints too.

\(x\) \(-3\) \(-1\) \(1\) \(3\)
\(f(x)\) \(-17\) \(3\) \(-1\) \(19\)
\[\text{Global minimum } f=-17\text{ at }x=-3;\qquad \text{global maximum } f=19\text{ at }x=3\]

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}\).

\[f'=4x^{3},\ f''=12x^{2},\ f'''=24x,\ f^{(4)}=24\]

At \(x=0\): \(f'=f''=f'''=0\) and \(f^{(4)}=24\ne0\). Here \(n=4\), even, and \(f^{(4)}>0\).

\[\boxed{\text{local (indeed global) MINIMUM}}\]

(b) \(g(x)=x^{5}\).

\[g'=5x^{4},\ g''=20x^{3},\ g'''=60x^{2},\ g^{(4)}=120x,\ g^{(5)}=120\]

First non-zero derivative at \(0\) is the 5th, which is odd.

\[\boxed{\text{INFLECTION — neither maximum nor minimum}}\]

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.

\[\boxed{\text{local (and global) MAXIMUM}}\]

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

\[f(x_1,x_2)=x_1^{2}+x_2^{2}+x_1x_2-6x_1-9x_2+20.\]

Solution.

Step 1 — gradient.

\[\nabla f=\begin{pmatrix}2x_1+x_2-6\\ x_1+2x_2-9\end{pmatrix}=\mathbf{0}\]

Step 2 — solve. From the first, \(x_2=6-2x_1\). Substituting:

\[x_1+2(6-2x_1)=9\ \Rightarrow\ x_1+12-4x_1=9\ \Rightarrow\ -3x_1=-3\ \Rightarrow\ x_1=1\]
\[x_2=6-2(1)=4\]
\[\mathbf{x}^{*}=(1,4)\]

Step 3 — Hessian.

\[H=\begin{pmatrix}2&1\\1&2\end{pmatrix},\qquad D_1=2>0,\qquad D_2=\det H=4-1=3>0\]

Positive definite (eigenvalues \(3\) and \(1\)).

\[\boxed{(1,4)\text{ is a strict local minimum}}\]

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.

\[f(1,4)=1+16+4-6-36+20=\mathbf{-1}\]

Check by an independent route — completing the square.

\[f=\left(x_1+\tfrac{x_2}{2}-3\right)^{2}+\tfrac34\left(x_2-4\right)^{2}-1\]

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

\[f(x_1,x_2)=x_1^{3}+x_2^{3}-3x_1x_2.\]

Solution.

Step 1 — gradient.

\[\nabla f=\begin{pmatrix}3x_1^{2}-3x_2\\ 3x_2^{2}-3x_1\end{pmatrix}=\mathbf{0} \ \Rightarrow\ x_2=x_1^{2}\ \text{ and }\ x_1=x_2^{2}\]

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\).

\[\mathbf{x}^{(1)}=(0,0),\qquad \mathbf{x}^{(2)}=(1,1)\]

Step 2 — Hessian.

\[H(\mathbf{x})=\begin{pmatrix}6x_1&-3\\-3&6x_2\end{pmatrix}\]

At \((0,0)\):

\[H=\begin{pmatrix}0&-3\\-3&0\end{pmatrix},\qquad \det H=0-9=-9<0\]

Indefinite (eigenvalues \(\pm3\)).

\[\boxed{(0,0)\text{ is a SADDLE POINT}}\]

At \((1,1)\):

\[H=\begin{pmatrix}6&-3\\-3&6\end{pmatrix},\qquad D_1=6>0,\qquad D_2=36-9=27>0\]

Positive definite (eigenvalues \(3\) and \(9\)).

\[\boxed{(1,1)\text{ is a strict local MINIMUM},\qquad f(1,1)=1+1-3=-1}\]

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

\[P(x_1,x_2)=100x_1+120x_2-2x_1^{2}-3x_2^{2}-2x_1x_2\quad(₹\text{ hundreds}).\]

Find the profit-maximising output and prove it is the global maximum. Interpret the cross-term.

Solution.

Step 1 — gradient.

\[\frac{\partial P}{\partial x_1}=100-4x_1-2x_2=0,\qquad \frac{\partial P}{\partial x_2}=120-6x_2-2x_1=0\]

Step 2 — solve.

\[2x_1+x_2=50 \tag{i}\]
\[x_1+3x_2=60 \tag{ii}\]

From (i), \(x_2=50-2x_1\). Substituting into (ii):

\[x_1+150-6x_1=60\ \Rightarrow\ -5x_1=-90\ \Rightarrow\ x_1=18,\qquad x_2=50-36=14\]
\[\boxed{x_1^{*}=18,\quad x_2^{*}=14}\]

Step 3 — Hessian.

\[H=\begin{pmatrix}-4&-2\\-2&-6\end{pmatrix},\qquad D_1=-4<0,\qquad D_2=24-4=20>0\]

Signs alternate starting negative \(\Rightarrow\) negative definite \(\Rightarrow\) \(P\) is strictly concave, and since \(H\) is constant this holds everywhere.

\[\boxed{(18,14)\text{ is the UNIQUE GLOBAL maximum}}\]

Step 4 — the profit.

\[P=100(18)+120(14)-2(324)-3(196)-2(18)(14)\]
\[=1800+1680-648-588-504=\mathbf{₹1740\text{ hundred}}=₹1{,}74{,}000\text{ per week}\]

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

\[P(25,20)=2500+2400-1250-1200-1000=₹1450\text{ hundred},\]

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

  1. 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\))
  2. 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\))
  3. 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\))
  4. 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\))
  5. 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.