Finding the minimum distance between two curves

  • Context: Undergrad 
  • Thread starter Thread starter Charles Link
  • Start date Start date
Charles Link
Science Advisor
Homework Helper
Insights Author
Gold Member
2025 Award
Messages
5,989
Reaction score
3,133
TL;DR
The problem is to compute the minimum distance between the two curves y=4-x^2 and y=(x-3)^2 in two dimensions.
The other day a friend of mine gave me the above problem which I found rather interesting. I was able to get a numerical solution. I'll post how I solved it later in the thread. Others may want to try it and see what they come up with.
 
Physics news on Phys.org
Square of the distance is
$$L^2=(y_1-y_2)^2+(x_1-x_2)^2=(4-x_1^2-(x_2-3)^2)^2+(x_1-x_2)^2$$
The condition of minimum is
$$\frac{\partial L^2}{\partial x_1}=\frac{\partial L^2}{\partial x_2}=0$$
Intersection of these two curves would give an answer.
 
Last edited:
  • Like
Likes   Reactions: Charles Link
@anuttarasammyak That's one part of what I did to solve it. Those two partial derivative expressions are really too clumsy to solve exactly. I used them though by getting an approximate ## x ## for where the two ## x ## values occur by first solving for the ## x ## where the vertical distance is a minimum. That turns out to be at ## x=3/2 ##.

I then let ## x_1=3/2+ \Delta_1 ## and ## x_2=3/2+ \Delta_2 ## and solved for ## \Delta_ 1## and ## \Delta_2 ## to first order using the two partial derivative expressions.

Others may want to try the calculation and/or have alternative ways of solving it, so I'm leaving just a summary of the solution rather than showing all of the details.
 
Last edited:
continued from #2:
With the help of Wolfram I get one real solution. https://www.wolframalpha.com/input?i=Solve+(4-x^2-(y-3)^2)(-2x)+(x-y)=0+and++(4-x^2-(y-3)^2)2(y-3))+(x-y)=0.+

1774768297207.webp

where ##x=x_1,y=x_2## Let us confirm it.
It is easily observed that the two curve formula coincide when ##-x=y-3=-a## thus a should satisfy
$$4a^3-6a-3=0$$
which derives all the solutions. Using real ##a=2^{-1/3}+2^{-2/3}=1.42366...##.
The minimum distance is
$$L=\sqrt{4a^4-4a^2-12a+25}=\sqrt{-6a^2-9a+25}=\sqrt{19-12*2^{-1/3}-15*2^{-2/3}}=0.16182....$$
when ##x_1=a, x_2=3-a##

I hope I commit no more careless mistakes.

1774785518397.webp
 

Attachments

  • 1774768139106.webp
    1774768139106.webp
    11.4 KB · Views: 1
Last edited:
  • Love
Likes   Reactions: Charles Link
@anuttarasammyak We are going to need to look over your two partial derivative expressions carefully, because your solution is incorrect and not even in the right ballpark. I got, doing it all by hand with no computer that ## (x_1,y_1)=(1.43,1.96)##, and ##(x_2,y_2)=(1.57,2.04) ## for a minimum distance of ## L=0.16 ##. These are approximate coordinates, and only accurate to the two decimals.

Edit: and I looked over your partial derivative expressions=they look like they may be correct. The values for the real solution might also be correct, but I don't have a computer that can compute them. It looks like you did get ## x_1=1.42366 ## and ## x_2=1.57634 ## which is close enough to what I got that they are most likely correct and even exact in the form Wolfram has them. I think your error may be when you finished up.

Try computing ## L ## again, but use ## (x_1,y_1) ## and ## (x_2,y_2) ##. I don't know where your expression for ## L ## using ## a ## came from. Note: ## L=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} ##.

With that one correction, I think everything else you did may be correct. :)

and I see you have now edited your post and made the correction. Very good=excellent. :)
 
Last edited:
Charles Link said:
@anuttarasammyak We are going to need to look over your two partial derivative expressions carefully, because your solution is incorrect and not even in the right ballpark.
I am sorry for my careless mistakes on L. I corrected #4. It seems in good accord with your result.
 
  • Like
Likes   Reactions: Charles Link
anuttarasammyak said:
I am sorry for my careless mistakes on L. I corrected #4. It seems in good accord with your result.
@anuttarasammyak Thank you very much for your solution above. It is excellent. <3 <3
 
@anuttarasammyak Perhaps you also noticed this already, but I find it interesting that with your exact solution, the slopes of the curves are precisely parallel, as they should be, at ## x_1 ## and ## x_2##, with slopes of ## -2 x_1 =-2a ## and ## 2(x_2-3)=-2a ##.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 18 ·
Replies
18
Views
3K
Replies
5
Views
2K