From a Geometric Question to a One-Variable Objective
A curve may pass near a target point without passing through it. To find the point on the curve that is nearest to the target, we need to compare distances from the target to all feasible points on the curve.
When the curve is the graph of a polynomial, every point on it is determined by its horizontal coordinate. This lets us express the distance using one variable and apply the methods of optimization to that objective.
Let the curve be \(y=p(x)\), where \(p\) is a polynomial, and let the target be \(T=(a,b)\). A point on the curve has coordinates \((x,p(x))\). Its squared distance from \(T\) is
The horizontal difference is \(x-a\), and the vertical difference is \(p(x)-b\). Both must be included: the target's vertical coordinate is \(b\), not necessarily zero.
Why Minimize Squared Distance?
The actual distance from \((x,p(x))\) to \(T\), by the distance formula, is
The square-root function is increasing on the nonnegative numbers. Therefore, if one candidate has a smaller value of \(D\) than another, it also has a smaller actual distance. Minimizing \(D\) and minimizing \(d\) give the same nearest point. But \(D\) is usually easier to differentiate because it has no square root.
By the sum rule and chain rule, the derivative of the squared-distance objective is
An interior point of the allowed domain can be a minimum only if \(D'(x)=0\). This condition identifies possible interior candidates; it does not by itself show that any candidate is the global nearest point. We must also respect the domain and compare the objective values.
Worked Example: Two Nearest Points on a Parabola
Worked Example: Two Nearest Points on a Parabola
Find the points on \(y=x^2\) nearest to \(T=(0,3)\), with no restriction on \(x\).
Here \(p(x)=x^2\), \(a=0\), and \(b=3\). The squared distance is
Expand and differentiate:
The critical-point equation is \(2x(2x^2-5)=0\). Thus \(x=0\), or \(x^2=5/2\), giving \(x=\pm\sqrt{5/2}\). Since the domain is all real numbers, all three values are admissible.
Evaluate the squared distance at each candidate:
At \(x=\pm\sqrt{5/2}\), we have \(x^2=5/2\), so
Because \(11/4<9\), the candidates with \(x=\pm\sqrt{5/2}\) are nearer than the candidate with \(x=0\). The corresponding curve points are \(\left(\sqrt{5/2},5/2\right)\) and \(\left(-\sqrt{5/2},5/2\right)\). Each has distance \(\sqrt{11/4}=\sqrt{11}/2\) from the target.
Check the critical-point condition: substituting \(x^2=5/2\) into \(D'(x)=2x(2x^2-5)\) gives \(D'(x)=2x(5-5)=0\). Substitution into the original distance expression gives \(11/4\) for both points, as computed above. The two equal minima reflect the symmetry of the parabola about the vertical axis through the target.
Which Candidates Must Be Compared?
On a closed, bounded interval \(I=[u,v]\), the continuous function \(D\) attains a minimum. Since \(D\) is a polynomial, it is continuous. Any minimum on the interval occurs either at an endpoint or at an interior critical point. Consequently, the full candidate list is:
- the left endpoint \(u\);
- the right endpoint \(v\);
- every solution of \(D'(x)=0\) that lies strictly between \(u\) and \(v\).
Critical points outside the allowed interval are not feasible and must not be included. For an unrestricted domain, endpoints are absent, but the existence of a global minimum still needs justification.
Here is why. Since \(D(x)\ge (x-a)^2\), and \((x-a)^2\) tends to infinity as \(|x|\) tends to infinity, \(D(x)\) also tends to infinity as \(|x|\) tends to infinity. Choose \(R>0\) large enough that \(D(x)>D(0)\) whenever \(|x|>R\). The continuous function \(D\) attains a minimum on the closed interval \([-R,R]\). Because \(0\) belongs to this interval, that minimum is no greater than \(D(0)\); outside the interval, all values are greater than \(D(0)\). Thus the minimum on \([-R,R]\) is also a global minimum on \(\mathbb R\). Finally, any global minimizer on \(\mathbb R\) is an interior point, so Fermat's theorem gives \(D'(x)=0\).
For a polynomial curve, \(D'\) is itself a polynomial. In these problems it is not identically zero: the term \((x-a)^2\) makes \(D(x)\) grow without bound, so \(D\) cannot be constant. A nonzero polynomial has finitely many roots. Thus, on the unrestricted real domain, solving \(D'(x)=0\) produces a finite set of candidates to compare.
Record \(y=p(x)\), \(T=(a,b)\), and the allowed domain.
Use \(D(x)=(x-a)^2+(p(x)-b)^2\).
Solve \(D'(x)=0\), retaining only solutions in the allowed domain.
For a closed interval, include both endpoints.
The candidate with the smallest \(D(x)\) gives the nearest curve point.
Worked Example: A Closed-Interval Domain
Worked Example: A Closed-Interval Domain
Find the point on \(y=x^2\), restricted to \(0\le x\le 2\), nearest to \(T=(3,0)\).
The squared-distance function is
Differentiate and factor:
The quadratic factor has discriminant \(2^2-4(2)(3)=4-24=-20<0\), and its leading coefficient is positive, so it has no real roots. The only critical point is \(x=1\), which is in the allowed interval. The candidates are \(x=0\), \(x=1\), and \(x=2\).
The smallest value is \(5\), so the nearest point is \((1,1)\), at distance \(\sqrt{5}\) from the target. Check the calculation: \(D'(1)=2(1-1)(2+2+3)=0\), and substitution into the original distance expression gives \((1-3)^2+(1-0)^2=4+1=5\). The endpoint values are larger, so this is the minimum on the entire allowed interval.
Worked Example: A Critical Point Outside the Domain
Worked Example: A Critical Point Outside the Domain
Find the point on \(y=2x+1\), restricted to \(0\le x\le 2\), nearest to \(T=(1,0)\).
The squared distance is
Differentiate and solve:
This critical point is outside \([0,2]\), so it is not a feasible candidate. The only candidates are the endpoints:
Therefore, the nearest point is the curve point at \(x=0\), namely \((0,1)\), and its distance from the target is \(\sqrt{2}\). Check by substituting into the original expression: \((0-1)^2+(1-0)^2=1+1=2\). The excluded critical point cannot be used, regardless of the value of the objective there, because it does not belong to the allowed domain.
A Common Mistake: Using the Wrong Vertical Difference
For a target \(T=(a,b)\), the vertical difference from the curve point \((x,p(x))\) is \(p(x)-b\). A frequent error is to use \(p(x)\) instead, which silently treats the target as if its vertical coordinate were zero.
For example, on \(y=x^2\) with target \((0,3)\), the incorrect expression \(x^2+(x^2)^2\) would give zero at \(x=0\). That would falsely suggest that the curve passes through the target. But at \(x=0\), the curve point is \((0,0)\), whose squared distance to \((0,3)\) is \(0^2+(0-3)^2=9\). The correct objective is \(x^2+(x^2-3)^2\), and its minimum is \(11/4\) at \(x=\pm\sqrt{5/2}\), as the first example showed.
Another common error is to stop after finding a critical point. A critical point may be outside the allowed domain, and even a feasible one must be compared with every other feasible critical point and every included endpoint. The derivative locates candidates; comparison determines the global answer.
Check Your Understanding
For each question, identify how the squared-distance objective or candidate comparison should be set up.
- Write the squared-distance function from \(T=(2,-1)\) to the polynomial curve \(y=x^3\).
- Why does minimizing squared distance give the same nearest point as minimizing distance?
- On a closed interval, which points must be compared in addition to the critical points in the interior?
- If solving \(D'(x)=0\) gives a value outside the allowed domain, should it be included in the comparison? Explain.
- For \(y=x^2\) and target \((0,3)\), what are the two nearest curve points and their squared distance?