# Distance Between Curves in First-Semester Calculus

In the optimization section of Calculus 1 a common problem is to find the minimum distance between a curve and a point. I'd like to extend this idea and be able to compute the minimum distance between two (smooth and non-intersecting) curves. However I can't seem to justify that it should occur when the slopes of the two curves are parallel. This fact is visually intuitive, but I'd like to establish it more algebraically.

Is there a Calculus-1-level justification that the minimum distance between curves occurs when the slopes are equal?

The justifications I've been able to find so far rely on Vector and/or Multivariable Calculus. And perhaps that's the true nature of this type of problem and so it just can't be done in Calculus 1.

Alternatively, feel free to solve the following problem using only Calculus 1 optimization techniques that would generalize to slightly more difficult curves (i.e. no tricks allowed that take advantage of the symmetry/simplicity of these specific curves):

Find the minimum distance between the curves $$xy=1$$ and $$y=-x$$.

(This, of course, has the solution of $$\sqrt{2}$$ between $$(0,0)$$ and $$(1,1)$$.)

• Should these curves be smooth and non-intersecting? Mar 12 at 18:31
• @NickC Yes. Edited to reflect this. Thanks! Mar 12 at 18:32
• Since this is presumably a first semester introductory calculus course (rather than a real analysis course in which theoretical subtleties receive a lot more attention), you could simply phrase the questions as follows: "Find the minimum of the distances between a point on xxx and a point on yyy. You may assume that the minimum occurs when zzz." Of course, make absolutely sure that this assumption holds for every such problem you give. As for what to tell the students (in class lectures) about this assumption, I suppose something based intuitively on @Joseph O'Rourke's answer would be fine. Mar 12 at 19:06
• Introduce a parameter "a", and minimize the distance between $(a,f(a))$ and the graph of $g$. This gives a function $M(a)$ which can be minimized. Mar 12 at 20:38
• @JosephO'Rourke: That's true, but the OP's hypothesis was that it occurred "when the slopes of the two curves are parallel". The analogy in 3D would be that the tangent vectors are parallel, which they aren't in my example. I think that your criterion (connecting segment is orthogonal to both lines) works in all dimensions, but it's only equivalent to "parallel tangent vectors" in 2D. Mar 13 at 15:52

How about this? Say the two curves are $$A$$ and $$B$$, with the min distance achieved at point $$a \in A$$ and $$b \in B$$. Let me assume both curves are smooth, or at least have 1st derivatives everywhere.

Claim: the segment $$ab$$ is orthogonal to $$A$$ at $$a$$ and to $$B$$ at $$b$$. Suppose to the contrary that $$ab$$ is not orthogonal to $$A$$ at $$a$$. Then one can move $$a$$ slightly $$\pm$$ on $$A$$ (toward the smaller angle formed by $$ab$$ and the tangent to $$A$$ at $$a$$) and shorten $$ab$$.

Because $$ab$$ is orthogonal to both curves, the slopes at $$a$$ and at $$b$$ must be parallel.

The figure illustrates local shortening by moving to the smaller-angle side. (But it does not illustrate the actual min distance, which is achieved elsewhere.)

• The problem I have with this is that it relies too much on the intuition that moving $a$ slightly actually shortens $ab$. Maybe that's good enough for most students, but I'd still like to see it come out of something like solving for a critical point. Mar 12 at 18:01
• If the curves are graphs $y=f(x_1)$ and $y=f(x_2)$ and you set up the function $L(x_1,x_2)=(x_1-x_2)^2+(f(x_1)-g(x_2))^2$ and use $\frac{\partial L}{\partial x_1}=0$ and $\frac{\partial L}{\partial x_2}=0$ you arrive at the condition that the tangent lines to the curves are perpendicular to the segment $ab$ in the figure. Mar 12 at 21:50
• @user52817 indeed, unfortunately, this question is asked in the context where such arguments are not allowed... your comment goes to show that this is one of those examples which is better left for the multivariate course. In contrast, if we ask for the point on a curve closest to a given point then one variable suffices. Mar 12 at 23:41
• @Aeryk The rigorous mathematical justification is vector calculus. On the other hand, you can find plenty of examples of the geometrical argument that you don't like in Euclid. Of course schools don't teach much geometry these days, so that might not help either, but the geometrical argument was considered "good enough" by everybody for more than 1000 years. Mar 13 at 3:37
• Would it help to observe that the line connecting the two points should be perpendicular to the tangent lines? Mar 13 at 4:58

I would be more careful with the phrasing of the question. Here are some points to explain why. The first point is an answer under certain conditions.

• When looking for the distance between a point and a curve (in two dimensions), do you prove that for a point $$P$$ not on the curve when $$B$$ is the closest point on the curve, then $$\overleftrightarrow{PB}$$ is normal to the curve, or do you accept an intuitive argument? If this can be assumed, then Joseph O'Rourke's answer extended with user2913's comment is a solution: If $$AB$$ is the shortest distance between the two curves, then $$A$$ is closest to $$B$$ (on curve 1), so the tangent at $$A$$ for curve 1 is perpendicular to $$\overleftrightarrow{AB}$$. Similarly, $$B$$ (on curve 2) is optimal for $$A$$, so the tangent at $$B$$ for curve 2 is perpendicular to $$\overleftrightarrow{AB}$$. Hence the two tangents must be parallel.
• However, the closest point that is assumed in the previous bullet only exists under certain conditions. Here is an example. The distance from the origin to the parametric spiral $$((1+1/t)\times\cos t,(1+1/t)\times\sin t)$$ is $$1$$, but there is no closest point on the spiral to the origin.
• As for two curves, here is an example. The distance between the graphs of $$y=1+1/(1+x^2)$$ and $$y=0$$ is $$1$$, yet there are no points on the curves with distance $$1.$$ On the graph of $$y=1+1/(1+x^2)$$ the point $$(0,2)$$ has the property that the tangent is parallel to the line $$y=0$$, but this still does not give the minimal distance.
• There are also examples on a bounded region: The distance between the spiral $$((1+1/t)\times\cos t,(1+1/t)\times\sin t)$$ and the circle $$x^2+y^2=0.25$$ is $$0.5$$, but there are no points on the two curves with distance $$0.5$$.

All in all, the point I am trying to make here is that the first intuitive assumption we make is that there are points realising the minimal distance (either between point and curve or between two curves). This assumption is not always true, but if there are such points, then the condition about parallel tangent lines can be proved within Calculus-1.

• I do not usually use the assumption about the normal. Usually to minimize distance from curve to point we just write an expression for distance squared, take a derivative, find critical points, and then do a candidates test. With regard to your third point, we would just minimize y coordinate on the curve. The critical point at (0,2) would be recognized as a local/global min. The endpoints at $\pm \infty$ would be considered and it would be seen that the point is not realized. Likewise for your other examples, except that (for better or worse) we don't cover parametric functions. Mar 15 at 16:04

[T]o justify that it should occur when the slopes of the two curves are parallel:

If $$ab$$ is a minimum, then the curve through $$b$$ has no points in the interior of the circle centered at $$a$$ with radius $$ab$$. (Any point inside is closer to $$a$$ than $$b$$.) Likewise, the curve through $$a$$ has no points in the interior of the circle centered at $$b$$ with radius $$ba$$.

Since it is presumed that the curves are smooth and have well defined tangents, the tangents to the curves at $$a$$ and $$b$$ must coincide with the tangents to the corresponding circles at the same points.* Therefore the tangents at $$a$$ and $$b$$ are perpendicular to the segment $$ab$$ and hence parallel.

*I've found students don't usually hold with Steiner's dictum, "Geometry stimulates, while calculating replaces, thinking" (per Dirk Struik), so you might feel obliged to haul out some $$f(x)$$'s. OTOH, students love the idea that things are tangent if they don't cross and touch at only one point. But if necessary, here goes: Let $$y = f(x)$$ be the equation of the curve through $$a$$ and $$y = g(x)$$ be the equation of the (semi)circle through $$a$$ and centered at $$b$$. Then $$f(x)-g(x)$$ is zero at $$a$$. If the derivative of $$f(x)-g(x)$$ is nonzero at $$a$$, then $$f(x)-g(x)$$ changes sign at $$a$$** and $$f(x)$$ enters the circle, contrary to hypothesis. Therefore $$f'(x)=g'(x)$$ at $$a$$, and the tangent lines have the same slope and pass through the same point, which is what needed to be shown.

**If this isn't obvious, one can prove, in the same way Fermat's Critical Point Theorem is proved, that if $$h(c)=0$$ and $$h'(c)\ne0$$, then $$h(x)$$ changes sign at $$c$$. Or one can prove it directly from the limit definition. If $$[h(x)-h(c)]/(x-c)=h(x)/(x-c)$$ approaches a nonzero value $$h'(c)$$ for $$x$$ close enough to $$c$$, then $$h(x)$$ must change sign when $$x-c$$ changes sign. Etc. This can also be proved geometrically using H.A. Thurston's definition of the tangent line.

So, you want to find the minimum distance between two curves in the most general form using calculus and optimization. The curves you are interested at this particular example are: $$$$xy=1 ~~and~~ y=-x \tag{01}$$$$ The very first step is to write them in parametric form. i.e, $$$$xy=1 \Rightarrow \begin{cases} x_1 &=t \\ y_1 &=\frac{1}{t} \end{cases} \tag{02}$$$$ Similarly,

$$$$y=-x \Rightarrow \begin{cases} x_2 &=s \\ y_2 &=-s \end{cases} \tag{03}$$$$ where $$t$$ and $$s$$ are the parameter. You can define their range based on the domain of defination of the curves. e.g, for first curve $$t$$ can take any value $$(-\infty,\infty)$$ except 0. Now our objective is to find the pair of $$(t,s)$$ for which the distance is minimum. Let's define the distance between any two points located on these two curves as $$D_{12}$$. i.e,

$$\begin{eqnarray} D_{12}^2 &=(x_1-x_2)^2+(y_1-y_2)^2 \\ &=(t-s)^2+(\frac{1}{t}+s)^2 \tag{06} \end{eqnarray}$$ We need to find the $$(t,s)$$ corresponding to the minimum value of the objective function $$D_{12}^2$$. Note that, since $$D_{12}$$ is a positive scalar-valued function, hence minimizer of $$D_{12}$$ will also be a minimizer of $$D_{12}^2$$.

For extremum value of the objective function, \begin{align} &\frac{d}{dt}{D_{12}^2} =0 \\ &\Rightarrow 2(t-s)+2(\frac{1}{t}+s)(-t^2)=0 \\ &\Rightarrow (t-s)-\frac{1}{t^2}(\frac{1}{t}+s)=0 \tag{09}\\ &\frac{d}{ds}{D_{12}^2} =0 \\ &\Rightarrow 2(t-s)(-1)+2(\frac{1}{t}+s)=0 \\ &\Rightarrow (t-s)=(\frac{1}{t}+s) \tag{10} \end{align}

Solve those two equations in a smart way. Substitute the second equation(\ref{10}) in the first one(\ref{09}) (sorry! equation \label-ing is not working). You will get,

\begin{align} & (\frac{1}{t}+s)-\frac{1}{t^2}(\frac{1}{t}+s)=0 \\ & (1-\frac{1}{t^2})(t-s)=0 \end{align}

Hence, either $$(1-\frac{1}{t^2})=0$$ or $$(t-s)=0$$. Now, $$(t-s)=0$$ is not possible. Because if you substitute this to the second equation(\ref{10}) you will end up having $${1+s^2}=0$$. Which is not possible as $$s$$ is a real valued parameter. Then, only option left is, $$\begin{eqnarray} (1-\frac{1}{t^2})=0 \\ t = \pm 1 \end{eqnarray}$$ Substitute $$t=1$$ in second equation to get $$s=0$$. Similarly $$t=-1$$ will give $$s=0$$. The closest point on parametric form are $$(t_1=1,s_1=0)$$ and $$(t_2=-1,s_2=0)$$. The corresponding pints on curves in cartesian co-ordinate are $$[(1,1),(0,0)]$$ and $$[(-1,-1),(0,0)]$$ on respective curves. The minimum distance is $$\sqrt(2)$$. See the image below:

See, even though you missed one solution, mathematics guided us to both the solutions.

To generalize this by stating that 'at minimum distance the slope is parallel', this might work for 2D but not in higher dimensions or between a curve and surface. Think of a 3D line and a parabola when both are not in the same plane. The concept of 'slope' is very vague when you go dimensions higher than 2D.

• Note the OP mentioned that "we don't cover parametric functions," which is I believe typical in US Calculus 1. Mar 17 at 11:50
• @ Joseph O'Rourke, I did not see that before. Parametric representation of curves is very useful though. Mar 17 at 22:33