So I am given the problem where a line of the form $ax+by+c=0$ and point $(x_0,y_0)$ are given and I have to find the minimum distance between these two. I was able to do it with the projection of a vector normal to the line and found the answer to be $$\frac{|ax_0+by_0+c|}{\sqrt{a^2+b^2}}$$ but I am supposed to do it using minimization techniques (setting partials equal to 0, solving for critical points and using the Hessian to see whether it is a min) but I have no idea how to even start with this method? Any help at all would be greatly appreciated especially if they are hints rather than the actual answer. Thanks!!
$\endgroup$2 Answers
$\begingroup$Here might be a good place to start: $y=\frac{c-ax}{b}$. Then the distance function between the points on this line and $x_0,y_0$ looks like:
$D(x,y)=\frac{(c-ax)/b-y_0}{x-x_0}=\frac{c-ax-by}{b(x-x_0)}$. Since $x_0$ and $y_0$ are fixed, you are looking at the partials for $D$ with respect to $x$ and then $y$, setting them to zero, using the hessian test etc.
You are right that there are easier ways to do this though.
$\endgroup$ 2 $\begingroup$To find the minimum distance between a point $P(x_0,y_0)$ and a line $ax + by + c = 0$, we will use the distance formula $$f(x) = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$$
to create a function that represents the distance between $P(x_0,y_0)$ and the line $ax + by + c = 0$ as a function of $x$.
First, let's rewrite $ax + by + c = 0$ as $$y = \frac{-ax-c}{b} \tag{1}$$
So our distance function will calculate the distance between $(x_0,y_0)$ and $(x,y)$.
Let $d$ be the distance function between the point and the line:
$$d(x) = \sqrt{(x - x_0)^2 + (y - y_0)^2}\tag{2}$$
Substituting $(1)$ into $(2)$ we get $$d(x) = \sqrt{(x - x_0)^2 + \left(\frac{-ax-c}{b} - y_0\right)^2}\tag{3}$$
Now we need to go about calculating the absolute minimum of $(3)$ by calculating the derivative of $(3)$, equating it to zero, and then solving it for $x$ which will be the value at which $(3)$ has its minimum(shortest) value(distance).
To simplify the process somewhat, we will take the derivative of the square of the distance in order to get rid of the square root when we're calculating the derivative. Note that in doing so will not alter the solution.
So we let D be the function that represents the square of the distance, so that
$$D(x) = (x - x_0)^2 + \left(\frac{-ax-c}{b} - y_0\right)^2\tag{4}$$
So now we take the derivative of $(4)$,
$$D'(x) = \frac{2b^2x - 2b^2x_0 + 2a^2x+2ac + 2aby_0}{b^2}\tag{5}$$
Now we set $(5)$ equal to zero and solve for $x$, which is where the minimum occurs. We do this by setting the numerator of $(5)$ to zero
$$ 2b^2x - 2b^2x_0 + 2a^2x+2ac + 2aby_0 = 0 $$ so, $$ x = \frac{b^2x_0 - ac - aby_0}{a^2+b^2}\tag{6} $$
Plugging $(6)$ into $(3)$ we get $$ d(x) = \sqrt{\left(\frac{b^2x_0 - ac - aby_0}{a^2+b^2} - x_0\right)^2 + \left(\frac{-a\frac{b^2x_0 - ac - aby_0}{a^2+b^2}-c}{b} - y_0\right)^2} $$ $$ = \sqrt{\left(\frac{-a^2x_0-aby_0-ac}{a^2+b^2}\right)^2 + \left(\frac{-ab^2x_0-y_0b^3-b^2c}{b(a^2+b^2)}\right)^2} $$ $$ = \sqrt{\frac{(a^2)(ax_0 + by_0 + c)^2}{(a^2+b^2)^2} + \frac{(b^2)(ax_0 + by_0 + c)^2}{(a^2+b^2)^2}} $$
$$ =\bbox[5px,border:2px solid red] { \frac{\lvert ax_0 + by_0 + c \rvert}{\sqrt{a^2 + b^2}} } $$
$\endgroup$