Introduction
A nearest-point problem asks which point on a specified curve or surface is closest to a given point. The constraint describes the allowed locations; the objective measures the distance from the given point.
These problems are natural applications of Lagrange multipliers, but setting them up carefully matters. In particular, minimizing squared distance is simpler than minimizing distance itself, and solving the multiplier equations produces candidates that still need to be checked.
Formulating the Problem
Let \(\mathbf{a}\in\mathbb{R}^n\) be the fixed point, and let \(\mathbf{x}\in\mathbb{R}^n\) be a point on the curve or surface. For a single equality constraint, write the feasible set as \(g(\mathbf{x})=0\). The distance from \(\mathbf{x}\) to \(\mathbf{a}\) is \(\|\mathbf{x}-\mathbf{a}\|\), so the squared distance is
Because the square-root function is strictly increasing on nonnegative numbers, minimizing \(D(\mathbf{x})\) gives exactly the same nearest points as minimizing \(\|\mathbf{x}-\mathbf{a}\|\). Squared distance is also differentiable everywhere, including at \(\mathbf{x}=\mathbf{a}\).
For one equality constraint, the Lagrange equations for an extremum of \(D\) are
Since \(\nabla D(\mathbf{x})=2(\mathbf{x}-\mathbf{a})\), the equations become
These equations apply at a constrained local extremum where the constraint is regular, meaning \(\nabla g(\mathbf{x})\ne\mathbf{0}\). A singular feasible point, where \(\nabla g(\mathbf{x})=\mathbf{0}\), must be checked separately: the regular Lagrange condition does not guarantee that it will be found. Even at regular points, the equations give stationary candidates, not an automatic proof that a candidate is the global nearest point.
Why the Lagrange Condition Appears
At a regular point of the curve or surface, its tangent directions are perpendicular to \(\nabla g\). To see why a nearest point must satisfy the Lagrange condition, take any differentiable feasible path \(\boldsymbol{\gamma}(t)\) through a constrained local minimum \(\mathbf{x}_*=\boldsymbol{\gamma}(0)\). Since the path stays on the constraint, \(g(\boldsymbol{\gamma}(t))=0\), and differentiation at \(t=0\) gives
The squared distance also has a local minimum along this path. The chain rule therefore gives
Thus \(\nabla D(\mathbf{x}_*)\) is perpendicular to every tangent direction. At a regular point of a single constraint, the normal directions are the multiples of \(\nabla g(\mathbf{x}_*)\). Therefore \(\nabla D(\mathbf{x}_*)=\lambda\nabla g(\mathbf{x}_*)\) for some scalar \(\lambda\), as required. Geometrically, at a nearest point, the displacement from the fixed point to the constraint is normal to the constraint.
Worked Example: Nearest Point on a Line
Worked Example: Nearest Point on a Line
Find the point on \(3x+4y=10\) nearest to \((1,1)\), and verify that it is the global nearest point.
The squared distance from \((x,y)\) to \((1,1)\) is \(D(x,y)=(x-1)^2+(y-1)^2\). Write the constraint as \(g(x,y)=3x+4y-10=0\). Then \(\nabla D=(2(x-1),2(y-1))\) and \(\nabla g=(3,4)\). The Lagrange equations are
The first two equations give \(x=1+\frac{3}{2}\lambda\) and \(y=1+2\lambda\). Substituting into the constraint gives
Therefore \(x=1+\frac{9}{25}=\frac{34}{25}\) and \(y=1+\frac{12}{25}=\frac{37}{25}\). The candidate is \(\left(\frac{34}{25},\frac{37}{25}\right)\). It satisfies the line equation because
Its distance from \((1,1)\) is \(\sqrt{(9/25)^2+(12/25)^2}=\frac{15}{25}=\frac35\).
To verify it is globally nearest, let \(\mathbf{q}\) be this candidate and let \(\mathbf{z}\) be any other point on the line. The vector \(\mathbf{z}-\mathbf{q}\) is tangent to the line, so it is perpendicular to the normal vector \(\mathbf{q}-(1,1)\). Expanding the squared distance gives
Hence no other point on the line is closer, and equality holds only when \(\mathbf{z}=\mathbf{q}\).
Worked Example: Nearest Point on a Circle
Worked Example: Nearest Point on a Circle
Find the nearest point on the circle \(x^2+y^2=4\) to \((4,3)\). The circle constraint is \(g(x,y)=x^2+y^2-4=0\), and the squared distance is \(D(x,y)=(x-4)^2+(y-3)^2\). The Lagrange equations are
After dividing the first two equations by \(2\), they read \(x-4=\lambda x\) and \(y-3=\lambda y\). The value \(\lambda=1\) is impossible, since the first equation would imply \(-4=0\). Thus
Substitution into the circle gives \(\frac{25}{(1-\lambda)^2}=4\), so \(1-\lambda=\frac52\) or \(1-\lambda=-\frac52\). The two candidates are therefore \(\left(\frac85,\frac65\right)\) and \(\left(-\frac85,-\frac65\right)\).
At the first candidate, the squared distance is
Its distance is \(3\). At the second candidate, the squared distance is
Its distance is \(7\). The circle is compact, so the continuous distance function attains a minimum there. The Lagrange equations have produced both candidates, and comparing their distances shows that \(\left(\frac85,\frac65\right)\) is the nearest point.
Worked Example: Nearest Point on a Plane
Worked Example: Nearest Point on a Plane
Find the point on the plane \(x+2y+2z=9\) nearest to \((1,2,3)\). Set \(D=(x-1)^2+(y-2)^2+(z-3)^2\) and \(g=x+2y+2z-9\). Then the Lagrange equations are
The first three equations give \(x=1+\frac{\lambda}{2}\), \(y=2+\lambda\), and \(z=3+\lambda\). Substituting into the plane equation yields
Thus the candidate is \(\left(\frac79,\frac{14}{9},\frac{23}{9}\right)\). It is on the plane, since \(\frac79+2\left(\frac{14}{9}\right)+2\left(\frac{23}{9}\right)=\frac{81}{9}=9\). Its displacement from \((1,2,3)\) is \(\left(-\frac29,-\frac49,-\frac49\right)\), so its distance is
The displacement is parallel to the plane's normal vector \((1,2,2)\). For any other point on the plane, the displacement between that point and the candidate lies in the plane and is perpendicular to this normal. The same squared-distance expansion used for the line shows that moving within the plane adds a nonnegative squared length. Therefore this candidate is the global nearest point.
Checking Candidates and Avoiding a Sign Error
The circle example illustrates why solving the Lagrange equations is only part of a nearest-point problem: there can be multiple stationary candidates, and their objective values must be compared. If the feasible set is compact and the objective is continuous, a minimum exists; checking all relevant candidates then identifies it. For a noncompact set, verify that a nearest point exists or provide a direct global argument, as in the line and plane examples.
A frequent error in a line projection is using the wrong sign for the normal displacement. For the line and point in the first example, the residual at \((1,1)\) is \(3(1)+4(1)-10=-3\). Adding \(\frac{-3}{25}(3,4)\) gives \(\left(\frac{16}{25},\frac{13}{25}\right)\), but this point is not on the line:
The correction is to subtract the residual divided by the squared length of the normal, times the normal. Here that gives \((1,1)-\frac{-3}{25}(3,4)=\left(\frac{34}{25},\frac{37}{25}\right)\), which does satisfy the constraint. Substitution into the constraint is a simple but essential check.
Why These Problems Matter
Nearest-point calculations arise whenever a point must be adjusted to satisfy an exact condition while changing it as little as possible. The equality constraint might represent a geometric object or a required relationship among coordinates. The squared-distance objective expresses the size of the adjustment without introducing an unnecessary square root.
The reusable procedure is to define the squared distance, state the equality constraint, solve the Lagrange system at regular feasible points, and compare or otherwise verify the candidates. Keep track of singular feasible points as well, because they are not covered by the regular Lagrange condition.
Check Your Understanding
Use the squared-distance objective and the constraint equation to answer these questions.
- Why does minimizing squared distance give the same nearest points as minimizing distance?
- What regularity condition is needed to use the one-constraint Lagrange equation?
- For a nearest point on a regular curve or surface, how is the displacement from the fixed point oriented relative to the constraint?
- Why must the two candidates in the circle example be compared rather than selecting one as nearest immediately?
- For the line \(3x+4y=10\), check directly that \(\left(\frac{34}{25},\frac{37}{25}\right)\) is feasible and is at distance \(\frac35\) from \((1,1)\).