Turning Nearest-Point Questions into Optimization
A point on a curve can be close to a fixed point in more than one direction: both its horizontal and vertical coordinates matter. The distance formula combines those differences, and calculus can help locate the point or points with the smallest distance.
Suppose the curve is the graph \(y=f(x)\), with \(x\) restricted to a domain \(D\), and the fixed point is \(P=(a,b)\). The point on the graph corresponding to \(x\) is \((x,f(x))\). Its distance from \(P\) is
Rather than differentiate this square root, we can minimize its square. This makes the optimization simpler without changing which point is closest.
Why Squared Distance Gives the Same Answer
Distance is nonnegative, and the square-root function is strictly increasing on nonnegative numbers. Therefore, if one point has smaller squared distance than another, it also has smaller distance; conversely, smaller distance means smaller squared distance. The values of the minimum are different—the minimum distance is the square root of the minimum squared distance—but the minimizing point or points are the same.
If \(f\) is differentiable at an interior point \(x\) of the domain and \(S\) has a local minimum there, Fermat’s theorem says \(S'(x)=0\). Differentiating the squared-distance expression gives the equation used to find interior candidates:
Thus, at a differentiable interior minimum,
This equation identifies possible interior minima; it does not by itself prove that a candidate is the nearest point. Candidates must be compared, and the domain must be checked for boundaries or other places where a minimum could occur.
A Complete Candidate Check on a Closed Interval
If the allowed values of \(x\) form a closed interval \([u,v]\), and \(S\) is continuous there, the Extreme Value Theorem guarantees that \(S\) attains an absolute minimum on that interval. If \(S\) is differentiable in the interior, an absolute minimum can occur at an endpoint or at an interior point where \(S'(x)=0\). If there are interior points where \(S\) is not differentiable, those must also be checked.
Identify every value of \(x\) that corresponds to a point on the specified curve.
Write \(S(x)=(x-a)^2+(f(x)-b)^2\).
Solve \(S'(x)=0\) at differentiable interior points, and include any interior points where \(S'\) does not exist.
Include endpoints that belong to the domain. For a domain with an excluded boundary, investigate what happens near it, but do not count it as an attained candidate.
Evaluate \(S\) at all valid candidates. The smallest value gives the nearest point; take its square root to obtain the distance.
Worked Example: A Parabola and a Point Above It
Worked Example: A Parabola and a Point Above It
Find the point or points on \(y=x^2\) nearest to \(P=(0,3)\).
A point on the graph is \((x,x^2)\), where \(x\in\mathbb R\). The squared distance is
Differentiate using the chain rule:
Set the derivative equal to zero:
These are all the interior candidates. The domain is \(\mathbb R\), and \(S(x)\to\infty\) as \(|x|\to\infty\), so a minimum is attained; the candidates can be compared. At \(x=0\),
At either \(x=\sqrt{5/2}\) or \(x=-\sqrt{5/2}\), we have \(x^2=5/2\), so
Since \(11/4<9\), the nearest points are \((\sqrt{5/2},5/2)\) and \((-\sqrt{5/2},5/2)\). Each is at distance
Check: The squared distance from either listed point to \((0,3)\) is \(x^2+(x^2-3)^2=5/2+1/4=11/4\), as calculated. The two points are equally near because the graph and the fixed point are symmetric about the \(y\)-axis.
Why an Interior Candidate Must Have Zero Derivative
The candidate equation is a consequence of the ordinary local-extremum condition, not a special geometric assumption. Here is the justification. If \(x=c\) is an interior local minimum of a differentiable function \(S\), then for sufficiently small positive \(h\), \(S(c+h)-S(c)\geq 0\), while for sufficiently small negative \(h\), \(S(c+h)-S(c)\geq 0\) as well. Dividing by \(h\) reverses the inequality when \(h<0\). The right-hand difference quotients are therefore nonnegative and the left-hand ones nonpositive. If the derivative exists, the two one-sided limits agree, so their common value must be zero. Thus \(S'(c)=0\).
Applying this fact to squared distance and using the derivative already computed gives the interior candidate equation. The condition is necessary, not sufficient: a critical point could be a maximum or neither a maximum nor a minimum. That is why candidates must be compared or otherwise classified.
Worked Example: A Curve Restricted to a Segment
Worked Example: A Curve Restricted to a Segment
Find the point on the segment of \(y=2x+1\) with \(0\leq x\leq 2\) nearest to \(P=(3,0)\).
The squared distance is
Differentiate and solve for interior critical points:
The point \(1/5\) lies in the interval. Check it and both endpoints:
Since \(49/5<10\) and \(49/5<26\), the minimum occurs at \(x=1/5\). The point on the segment is \((1/5,7/5)\), and its distance from \(P\) is \(\sqrt{49/5}=7/\sqrt5\).
Check: The coordinate differences are \(-14/5\) horizontally and \(7/5\) vertically. Their squared sum is \(196/25+49/25=49/5\), so the distance is \(7/\sqrt5\), as stated.
Boundaries, Unbounded Domains, and Attainment
A domain boundary matters only if it is part of the allowed curve, but an excluded boundary can still affect whether a nearest point exists. On a closed interval, check both endpoints. On a half-line such as \([1,\infty)\), check the included endpoint and any interior critical points. On an open interval, a distance may approach an infimum near an excluded endpoint without ever attaining it.
For an unbounded domain, the fact that \(S(x)\) grows without bound at infinity can help ensure that a minimum exists, but it is not enough on its own. A sufficient condition is that the domain \(D\) be nonempty and closed, that \(S\) be continuous on \(D\), and that \(S(x)\to\infty\) as \(x\) moves without bound along \(D\). To see why, choose any \(x_0\in D\). Far enough from the origin, \(S(x)>S(x_0)\). The search for a minimum can then be restricted to \(D\cap[-R,R]\) for a sufficiently large \(R\). This set is nonempty, closed, and bounded, hence compact. Continuity guarantees that \(S\) attains a minimum on it, and values outside it are larger than \(S(x_0)\), so that minimum is also a minimum on all of \(D\).
Worked Example: An Included Endpoint Is the Nearest Point
Worked Example: An Included Endpoint Is the Nearest Point
Find the nearest point to \(P=(0,0)\) on the part of \(y=x^2\) where \(x\geq 1\).
Here \(D=[1,\infty)\), and
For every \(x\geq1\), its derivative is positive:
Thus \(S\) is increasing on the domain, so its smallest value occurs at the included endpoint \(x=1\). Direct evaluation gives \(S(1)=1+1=2\). The nearest point is \((1,1)\), and the minimum distance is \(\sqrt2\).
Check: The distance from \((1,1)\) to \((0,0)\) is \(\sqrt{1^2+1^2}=\sqrt2\). Since \(S\) increases for every allowed \(x\), no point with \(x>1\) has a smaller distance.
Common Mistake: Treating an Excluded Boundary as an Endpoint
Consider the curve \(y=0\) with domain \(x>0\), and the fixed point \(P=(0,0)\). The squared distance is \(S(x)=x^2\). It has no critical point in the domain because \(S'(x)=2x>0\) for \(x>0\). As \(x\to0^+\), \(S(x)\to0\), but \(x=0\) is not allowed. Every point on the curve has positive distance, so there is no nearest point; the distance has infimum \(0\), which is not attained.
A mistaken argument might say: “Since \(S(x)\to\infty\) as \(x\to\infty\), restrict to a large closed interval \([0,R]\); continuity then guarantees a minimum at \(x=0\).” This is wrong because the original domain is \(x>0\), not \([0,R]\). Adding \(x=0\) adds a point that is not on the specified curve. In particular, the condition \(S(x)\to\infty\) at infinity does not alone guarantee attainment when a finite boundary is excluded.
For a final check, verify the actual domain before applying an endpoint comparison or an existence argument. A boundary point can be tested as a candidate only when it belongs to the feasible domain.
Using the Method Reliably
Nearest-point problems are optimization problems with a geometric objective. The important work is not just solving a derivative equation: it is defining the exact domain, differentiating correctly, including all valid candidates, and establishing that the smallest value is actually attained. More than one nearest point is possible, as the symmetric parabola example shows.
Before finishing a solution, ask:
- Does the squared-distance formula include both coordinate differences?
- Did the derivative use the chain rule for \(f(x)-b\)?
- Have all interior critical points and nondifferentiable points been considered?
- Were included endpoints checked, and excluded boundaries kept out?
- Does the domain or a direct comparison guarantee that the claimed minimum is attained?
Check Your Understanding
Use the squared-distance method in each question, and state which domain points must be checked.
- Write the squared-distance function from \((a,b)\) to a point \((x,f(x))\) on a graph.
- For a differentiable graph, derive the equation satisfied by any interior nearest-point candidate.
- Why do minimizing distance and minimizing squared distance give the same point?
- On a closed interval, which types of candidates must be compared to locate an absolute minimum?
- Why does \(S(x)\to\infty\) at infinity fail, by itself, to guarantee a nearest point on every domain?