Maxima, minima, and Lagrange multipliers

A single-variable function has only two kinds of turning point — a hump or a dip — but the moment a second variable enters, a third shape appears: the saddle point, where the surface rises in one direction and falls in another, like the seat of a horse's saddle. This capstone topic of MA10001's several-variables unit gives you two tools built on that idea. First, an unconstrained test: find where both partial derivatives vanish, then use a discriminant built from second derivatives to tell max from min from saddle. Second, a constrained tool: when a variable must obey an equation like g(x,y,z)=0g(x,y,z)=0, Lagrange's method turns the geometric fact that the extremum occurs where the level curves of ff and gg touch tangentially into a solvable algebraic system. Together they answer "where is the best point" whether or not there are rules attached.

The core insight

Unconstrained extrema of f(x,y)f(x,y) sit where fx=fy=0f_x=f_y=0 and are classified by the discriminant D=fxxfyy−fxy2D=f_{xx}f_{yy}-f_{xy}^2, while constrained extrema of ff subject to g=0g=0 occur where the gradients align, ∇f=λ∇g\nabla f=\lambda\nabla g.

The core idea

Unconstrained critical points. If f(x,y)f(x,y) has a local max or min at an interior point (a,b)(a,b) where ff is differentiable, both partial derivatives must vanish there:

fx(a,b)=0,fy(a,b)=0.f_x(a,b)=0, \qquad f_y(a,b)=0.

where: fx,fyf_x,f_y are the first partial derivatives of ff. Points satisfying this are critical points, but the condition is only necessary — a critical point can be a max, a min, or (new to several variables) a saddle.

Classifying with the discriminant. At a critical point (a,b)(a,b), define

D(a,b)=fxx(a,b) fyy(a,b)−[fxy(a,b)]2.D(a,b) = f_{xx}(a,b)\,f_{yy}(a,b) - \big[f_{xy}(a,b)\big]^2.

where: fxx,fyy,fxyf_{xx},f_{yy},f_{xy} are second partial derivatives evaluated at the critical point. If D>0D>0 and fxx>0f_{xx}>0, it is a local minimum; if D>0D>0 and fxx<0f_{xx}<0, a local maximum; if D<0D<0, a saddle point; if D=0D=0, the test is inconclusive. This test is really a compact restatement of the second-order Taylor expansion of ff near (a,b)(a,b): the quadratic terms 12[fxxh2+2fxyhk+fyyk2]\tfrac{1}{2}\big[f_{xx}h^2+2f_{xy}hk+f_{yy}k^2\big] (for a small step (h,k)(h,k) away from the critical point) keep a fixed sign in every direction exactly when D>0D>0, which is what makes the point a clean max or min; when D<0D<0 the quadratic form changes sign with direction, producing the mixed up-and-down curvature of a saddle. A quick illustration: for f(x,y)=x3−3xy+y3f(x,y)=x^3-3xy+y^3, solving fx=3x2−3y=0f_x=3x^2-3y=0 and fy=−3x+3y2=0f_y=-3x+3y^2=0 gives critical points (0,0)(0,0) and (1,1)(1,1). Since fxx=6xf_{xx}=6x, fyy=6yf_{yy}=6y, fxy=−3f_{xy}=-3, at (0,0)(0,0) we get D=(0)(0)−(−3)2=−9<0D=(0)(0)-(-3)^2=-9<0, a saddle point, while at (1,1)(1,1) we get D=(6)(6)−(−3)2=27>0D=(6)(6)-(-3)^2=27>0 with fxx=6>0f_{xx}=6>0, a local minimum of value f(1,1)=1−3+1=−1f(1,1)=1-3+1=-1.

Constrained extrema. To extremize f(x,y,z)f(x,y,z) subject to a single equality constraint g(x,y,z)=0g(x,y,z)=0, introduce a multiplier λ\lambda and solve

∇f=λ ∇g,g=0.\nabla f = \lambda\,\nabla g, \qquad g=0.

where: ∇f=(fx,fy,fz)\nabla f=(f_x,f_y,f_z) and ∇g=(gx,gy,gz)\nabla g=(g_x,g_y,g_z) are the gradients, and λ\lambda is the Lagrange multiplier — an unknown scalar solved for alongside x,y,zx,y,z. This is n+1n+1 equations in n+1n+1 unknowns for nn variables plus the constraint, and it handles only equality constraints; inequality-constrained (KKT) problems are beyond this course.

Figure
Concentric contour circles of f with a straight constraint line touching one circle at a single point where the gradient arrows of f and g point in the same direction
At the constrained extremum, the gradients of f and g are parallel level curves of f constraint g = 0 tangent point grad f grad g, parallel to grad f
Derivation AWhy the Lagrange condition grad f equals lambda grad g holds

The goal is to show, using only the geometric fact that a curve's tangent direction lies perpendicular to the curve's gradient, that at a point where ff restricted to the constraint surface g=0g=0 attains an extremum, the two gradients ∇f\nabla f and ∇g\nabla g must be parallel, which is exactly the Lagrange condition ∇f=λ∇g\nabla f=\lambda\nabla g used to set up and solve every constrained optimization problem in this course.

Step 1. Parametrize the constraint curve as r⃗(t)=(x(t),y(t),z(t))\vec{r}(t)=(x(t),y(t),z(t)), chosen so that g(r⃗(t))=0g(\vec{r}(t))=0 for every tt — the curve stays on the constraint surface. Differentiating this identity with respect to tt using the chain rule gives ∇g⋅r⃗ ′(t)=0\nabla g \cdot \vec{r}\,'(t) = 0: the gradient of gg is perpendicular to the curve's tangent vector r⃗ ′(t)\vec{r}\,'(t) at every point of the surface.

Step 2. Along the same curve, f(r⃗(t))f(\vec{r}(t)) is a single-variable function of tt. If r⃗(t0)\vec{r}(t_0) is where ff restricted to the constraint attains a local extremum, then by ordinary single-variable calculus its derivative there vanishes: ddtf(r⃗(t))∣t0=∇f⋅r⃗ ′(t0)=0\dfrac{d}{dt}f(\vec{r}(t))\Big|_{t_0} = \nabla f \cdot \vec{r}\,'(t_0) = 0.

Step 3. Compare the two results. Both ∇g\nabla g and ∇f\nabla f are perpendicular to the same tangent vector r⃗ ′(t0)\vec{r}\,'(t_0) at the extremum point. In three dimensions the set of vectors perpendicular to a given nonzero tangent direction, restricted to the constraint surface, is spanned by the normal direction to that surface — so ∇f\nabla f and ∇g\nabla g must both point along that one shared normal line, meaning they are parallel (or ∇g=0\nabla g = 0, an excluded degenerate case).

Step 4. Parallel vectors differ only by a scalar factor, so ∇f=λ ∇g\nabla f = \lambda\,\nabla g for some number λ\lambda — precisely the Lagrange multiplier equation. Combined with the constraint g=0g=0 itself, this gives the full system solved in every worked problem below: the multiplier λ\lambda is not extra physics, it is simply the proportionality constant forced by the tangency of the two gradients.

Worked example

Use Lagrange multipliers to find the point on the plane x+2y+3z=6x+2y+3z=6 closest to the origin, and hence the minimum distance.

Step 1. Minimizing distance is equivalent to (and algebraically easier via) minimizing the squared distance f(x,y,z)=x2+y2+z2f(x,y,z)=x^2+y^2+z^2, subject to g(x,y,z)=x+2y+3z−6=0g(x,y,z)=x+2y+3z-6=0.

Step 2. Form the Lagrange equations ∇f=λ∇g\nabla f=\lambda\nabla g component by component: fx=2x=λ(1)f_x=2x=\lambda(1), fy=2y=λ(2)f_y=2y=\lambda(2), fz=2z=λ(3)f_z=2z=\lambda(3).

Step 3. Solve for x,y,zx,y,z in terms of λ\lambda: x=λ2x=\dfrac{\lambda}{2}, y=λy=\lambda, z=3λ2z=\dfrac{3\lambda}{2}.

Step 4. Substitute into the constraint x+2y+3z=6x+2y+3z=6: λ2+2λ+9λ2=6\dfrac{\lambda}{2}+2\lambda+\dfrac{9\lambda}{2}=6, which collects to 7λ=67\lambda=6, so λ=67\lambda=\dfrac{6}{7}.

Step 5. Back-substitute to get the closest point: x=37x=\dfrac{3}{7}, y=67y=\dfrac{6}{7}, z=97z=\dfrac{9}{7}.

Step 6. Compute the distance. f(x,y,z)=949+3649+8149=12649=187f(x,y,z)=\dfrac{9}{49}+\dfrac{36}{49}+\dfrac{81}{49}=\dfrac{126}{49}=\dfrac{18}{7} is the minimum squared distance, so the minimum distance itself is

d=187=3147≈1.6036.d=\sqrt{\frac{18}{7}}=\frac{3\sqrt{14}}{7}\approx \mathbf{1.6036}.

Competitive stretch

Check the answer with the point-to-plane distance shortcut, d=∣Ax0+By0+Cz0−D∣A2+B2+C2d=\dfrac{|Ax_0+By_0+Cz_0-D|}{\sqrt{A^2+B^2+C^2}} for a plane Ax+By+Cz=DAx+By+Cz=D and point (x0,y0,z0)(x_0,y_0,z_0). Here (x0,y0,z0)=(0,0,0)(x_0,y_0,z_0)=(0,0,0), so d=∣0+0+0−6∣1+4+9=614=61414=3147d=\dfrac{|0+0+0-6|}{\sqrt{1+4+9}}=\dfrac{6}{\sqrt{14}}=\dfrac{6\sqrt{14}}{14}=\dfrac{3\sqrt{14}}{7}, matching Step 6 exactly and confirming that Lagrange's method reproduces the standard geometry formula.

Common traps

  • Forgetting the companion check on fxxf_{xx}. D>0D>0 alone only says "extremum," not which kind — the sign of fxxf_{xx} (equivalently fyyf_{yy}, which shares the same sign when D>0D>0) decides max versus min.
  • Reading D=0D=0 as "no extremum" instead of "inconclusive." The discriminant test is silent at D=0D=0; a direct check or higher-order terms is needed.
  • Dropping the final square root. Minimizing x2+y2+z2x^2+y^2+z^2 gives the same location as minimizing x2+y2+z2\sqrt{x^2+y^2+z^2}, but the minimized value is the squared distance — forgetting to take the square root at the end is a common slip.
  • Mixing up which gradient is scaled by λ\lambda. Each component equation fxi=λgxif_{x_i}=\lambda g_{x_i} must be set up consistently, and the constraint equation itself is always the extra equation needed to pin down λ\lambda.

Ask the tutor: if classifying a critical point with the discriminant, or solving a Lagrange-multiplier system, isn't clicking, ask the AI tutor to walk through a fresh example with you step by step.

Why does a two-variable function get a new kind of critical point that one-variable functions never have?

In one variable, a curve near a critical point can only bend one way, giving a max or a min. In two variables, the surface can curve upward along one direction and downward along a perpendicular direction at the same point — picture z=x2−y2z=x^2-y^2 at the origin. That mixed curvature is the saddle point, and the discriminant D=fxxfyy−fxy2D=f_{xx}f_{yy}-f_{xy}^2 exists precisely to detect this possibility, which has no single-variable analogue.

What does the Lagrange multiplier lambda actually mean, beyond being a solving trick?

Geometrically it is just the proportionality constant between two parallel gradient vectors at the tangency point, as the derivation shows. But it also has a useful interpretation: it measures roughly how much the optimal value of ff would change per unit change in the constraint's right-hand side. In this course you mainly need lambda to solve the system, but recognizing it is not an arbitrary symbol helps when interpreting results.

How do I know whether to use the discriminant test or Lagrange multipliers on a given problem?

Look at whether the variables are free or tied together by an equation. If you are told to extremize f(x,y)f(x,y) with no other conditions, find critical points and classify them with DD. If the problem says "subject to" or gives an equation like a plane, sphere, or budget constraint that x,y,zx,y,z must satisfy, that is a signal to set up ∇f=λ∇g\nabla f=\lambda\nabla g together with the constraint itself.

Before this

Where this leads