This problem's question is What is the minimum distance between these two curves?
This time, the answer will not be given to you beforehand.
We will be working in Cartesian coordinates.
Curve 1: . This is an ellipse half.
Curve 2: , also an ellipse half, moved and rotated.
Just looking at the situation , one can see the answer is under 1.
Use calculus and the first and second derivatives of the Euclidean distance. I worked it out that way in the solution. We will be going directly for a numeric solution.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The red line segment shows the path of the shortest distance.
We want to avoid complex numbers. Therefore, we will constraint x and y to being between -2 and 2 inclusive. By restricting x and y in that way, absolute value functions do not need to surround the quantities being squared.
Here is a plot of the distance for varous values of x and y as restricted. Therefore, the distances are all real. The colors encode the relative distances from red being the furthest and violet being the closest. The white spot surrounds the minimum distance location on the distance surface.
dx = ∂ x ∂ expr ⇒ 2 1 6 1 ( − 6 4 − x 2 − 3 4 − y 2 + 2 3 y + 1 2 ) 2 + ( x + 4 3 3 4 − y 2 + 2 y − 5 ) 2 4 4 − x 2 3 x ( − 6 4 − x 2 − 3 4 − y 2 + 2 3 y + 1 2 ) + 2 ( x + 4 3 3 4 − y 2 + 2 y − 5 )
dy = ∂ y ∂ expr ⇒ 2 1 6 1 ( − 6 4 − x 2 − 3 4 − y 2 + 2 3 y + 1 2 ) 2 + ( x + 4 3 3 4 − y 2 + 2 y − 5 ) 2 8 1 ( 4 − y 2 3 y + 2 3 ) ( − 6 4 − x 2 − 3 4 − y 2 + 2 3 y + 1 2 ) + 2 ( 2 1 − 4 4 − y 2 3 3 y ) ( x + 4 3 3 4 − y 2 + 2 y − 5 )
The method of gradient descent can be used to find the minimum. If the derivatives are too complex to compute symbolically, then they also can be approximated by the δ x f ( x ) − f ( x + δ x ) method.
Solving dx = 0 ∧ dy = 0 result in only one real solution: x → 1 . 7 3 9 3 8 7 2 7 0 8 0 5 8 8 , y → 0 . 0 . 2 1 6 4 6 8 3 5 3 8 0 8 7 2 7 .
Substituting those values back into the original distance formula gives the minimum distance of 0.608971133764102.
Sometimes, it is easier to sketch graph the situation and estimate the minimum distance and the pick out the minimum from the saddle point and the maximum. In these problem, I avoided that need.