# Max & min distance between two moving points

I am trying to find the minimal and maximum distance between two moving points with Mathematica in an interval.

For example,

p1 = (Sin(t), Cos(t))
p2 = (Cos(3t), Sin(2t))


Interval is $0≤t≤2\pi$.

Can I use the command EuclideanDistance or should I use FindMinimum, FindMaximum, NMinimize, Maximize; and how do I use these commands in an interval?

• Please, consider updating your question to include what you have tried and where you are getting stuck. That way, people on this site will know exactly what help you need.
– user9660
Commented Feb 25, 2016 at 18:55
• Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– user9660
Commented Feb 25, 2016 at 18:55

p1 = {Sin[t], Cos[t]}; p2 = {Cos[3 t], Sin[2 t]};

tAtMin = ArgMax[{EuclideanDistance[p1, p2]^2, 0 <= t <= 2 Pi}, t]
tAtMax = ArgMin[{EuclideanDistance[p1, p2]^2, 0 <= t <= 2 Pi}, t]

ParametricPlot[{p1, p2}, {t, 0, 2 Pi},
Epilog -> {PointSize[0.02],
Red, Thick, Dashed, Through[{Point, Line}[{p1, p2} /. t -> tAtMax]],
Darker@Green, Thick, Dashed, Through[{Point, Line}[{p1, p2} /. t -> tAtMin]]
}
]


Here's a way to visualize the evolution of the distance as $t$ varies:

Animate[
Show[{
ParametricPlot[{p1, p2}, {t, 0, 2 Pi},
Epilog -> {PointSize[0.02],
Red, Thick, Dashed,
Through[{Point, Line}[{p1, p2} /. t -> tAtMax]],
Darker@Green, Thick, Dashed, Through[{Point, Line}[{p1, p2} /. t -> tAtMin]]
}
],
Graphics[{
Thick, Gray, Dashed, PointSize[0.02],
Through[{Point, Line}[{{Sin[x], Cos[x]}, {Cos[3 x], Sin[2 x]}}]]
}]
}],
{x, 0, 2 Pi},
AnimationRate -> .05
]


• Wow, what an amazing answer! Commented Feb 25, 2016 at 18:38
• @C.Woods Thank you! Commented Feb 25, 2016 at 18:47
• Wow. Amazing, much more than I expected. Thank you very much!
– DCB
Commented Feb 26, 2016 at 0:02
• @DCB I'm very glad I could help Commented Feb 26, 2016 at 4:46
• The use of Through[{Point, Line}[{p1, p2} /. t -> tAtMax]] to create simultaneously the two points and the line joining them is particularly clever (sneaky?). A tip (trick?) well worth remembering! Commented Feb 26, 2016 at 15:31