Calculus – Shortest Distance Between Two General Curves Using MATLAB

calculus

Given two functions: $F(x)$ and $G(x)$ is there is a way to find out the shortest distance between $F(x)$ and $G(x)$ provided we know that they do not intersect. I tried to consider parametric points on the two curves and applied the distance formula.The obvious step was then to minimize the function. However there are two problems: one is that it is quite tedious to differentiate the distance function and the foremost problem is that the function does is not a single variable function. Given these issues could anyone provide some insight into this problem?

Best Answer

To answer, I assume $F(x)$ and $G(x)$ are continuous in $I \in \mathbb{R}, I = [a,b]$. For simplicity, let $F(x)=f, G(x) = g, H(x) = h = f-g$. By symmetry I can assume $f \ge g$. Now consider the function $h(x)$:

  • if $\exists x | h(x) = 0$, it means that there is a point $x$ such that $f(x) = g(x) \Rightarrow ||f(x) - g(x)|| = 0$ and so the minimum shortest distance between $f$ and $g$ is 0
  • else, find the minimum value of $h$ (by letting $h'=0$): let's call the minimum $m$. Let $P$ be the point found intersecating $f$ and the normal (i.e the tangent to the tangent to the curve) to $g$, and $N$ vice-versa (please, take a look at the image below). You need to fix a point $a$ on $f | P \le a \le f(m)$ and a point $b$ on $g| g(m) \le b \le N$, then the shortest distance is $\min[||a-b||]$. enter image description here
Related Question