Tutorials › Calculus I › Finding The Point On A Curve Nearest To A Target

Optimization and Newton's Method · Tutorial 873 of 1495

Finding The Point On A Curve Nearest To A Target

Translate the geometric distance into a one-variable objective, then identify and compare all candidates that can give the nearest point.

Advanced 10 min read

What You'll Learn

  • Express distance from a fixed target to a polynomial curve using one variable
  • Explain why minimizing squared distance gives the same point as minimizing distance
  • Find critical points by differentiating the squared-distance function
  • Include domain endpoints and discard critical points outside the feasible domain
  • Compare all candidates to determine the global nearest point
  • Recognize common errors involving the target coordinates and restricted domains

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

$$ D(x)=(x-a)^2+(p(x)-b)^2. $$

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.

Definition: For a polynomial curve \(y=p(x)\), target \(T=(a,b)\), and allowed domain \(I\), the squared-distance objective is \(D(x)=(x-a)^2+(p(x)-b)^2\) for \(x\in I\). A nearest point is a curve point \((x,p(x))\) whose squared distance is smallest among all \(x\in I\).

Why Minimize Squared Distance?

The actual distance from \((x,p(x))\) to \(T\), by the distance formula, is

$$ d(x)=\sqrt{(x-a)^2+(p(x)-b)^2}=\sqrt{D(x)}. $$

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

$$ D'(x)=2(x-a)+2(p(x)-b)p'(x) =2\bigl((x-a)+(p(x)-b)p'(x)\bigr). $$

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

$$ D(x)=(x-0)^2+(x^2-3)^2 =x^2+(x^2-3)^2. $$

Expand and differentiate:

$$ D(x)=x^2+x^4-6x^2+9=x^4-5x^2+9, $$
$$ D'(x)=4x^3-10x=2x(2x^2-5). $$

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:

$$ D(0)=0+(0-3)^2=9. $$

At \(x=\pm\sqrt{5/2}\), we have \(x^2=5/2\), so

$$ D\left(\pm\sqrt{\frac52}\right) =\frac52+\left(\frac52-3\right)^2 =\frac52+\left(-\frac12\right)^2 =\frac{10}{4}+\frac14 =\frac{11}{4}. $$

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.

Theorem: If \(p\) is a polynomial and \(T=(a,b)\), the squared-distance function \(D(x)=(x-a)^2+(p(x)-b)^2\) has a global minimum on \(\mathbb R\). Every global minimizer is a solution of \(D'(x)=0\).

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.

1
Write the curve and target.
Record \(y=p(x)\), \(T=(a,b)\), and the allowed domain.
2
Form squared distance.
Use \(D(x)=(x-a)^2+(p(x)-b)^2\).
3
Find feasible critical points.
Solve \(D'(x)=0\), retaining only solutions in the allowed domain.
4
Add the boundary candidates.
For a closed interval, include both endpoints.
5
Compare squared distances.
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

$$ D(x)=(x-3)^2+(x^2-0)^2 =(x-3)^2+x^4. $$

Differentiate and factor:

$$ D'(x)=2(x-3)+4x^3 =2(2x^3+x-3) =2(x-1)(2x^2+2x+3). $$

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

$$ D(0)=(0-3)^2+0^4=9, $$
$$ D(1)=(1-3)^2+1^4=4+1=5, $$
$$ D(2)=(2-3)^2+2^4=1+16=17. $$

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

$$ D(x)=(x-1)^2+(2x+1-0)^2 =(x-1)^2+(2x+1)^2 =5x^2+2x+2. $$

Differentiate and solve:

$$ D'(x)=10x+2, \qquad 10x+2=0 \quad\Longrightarrow\quad x=-\frac15. $$

This critical point is outside \([0,2]\), so it is not a feasible candidate. The only candidates are the endpoints:

$$ D(0)=5(0)^2+2(0)+2=2, \qquad D(2)=5(2)^2+2(2)+2=20+4+2=26. $$

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.

  1. Write the squared-distance function from \(T=(2,-1)\) to the polynomial curve \(y=x^3\).
  2. Why does minimizing squared distance give the same nearest point as minimizing distance?
  3. On a closed interval, which points must be compared in addition to the critical points in the interior?
  4. If solving \(D'(x)=0\) gives a value outside the allowed domain, should it be included in the comparison? Explain.
  5. For \(y=x^2\) and target \((0,3)\), what are the two nearest curve points and their squared distance?

Test yourself: Calculus I final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon