# [SOLVED]Shortest distance between line and point

#### karush

##### Well-known member
Show that the shortest distance from the point $\left(x_1,y_1\right)$ to a straight line
$$Ax_1+By_1+C=0$$ is
$$\frac{|Ax_1+By_1+C|}{\sqrt{A^2+B^2}}$$

ok, well a line from a point to a line is shortest if it is perpendicular to that line

obviously we are trying to find out a min value to this but taking a derivative of this without numbers is rather daunting and the question is asking for a proof

anyway not much of a start, but caught in the bushes already...

I did read the commentary on
"Finding the distance between a point and a line"

but this problem is under applications of differentiation which seem hard to set up

the book didn't give an answer to this... Last edited:

#### MarkFL

Staff member
Re: shortest distance between line and point

Given that this is a calculus exercise, I would say you should not assume the shortest distance is perpendicular, but rather you should define the distance function $D(x)$ and then optimize it.

I would let $$\displaystyle (x,y)=\left(x,-\frac{Ax+C}{B} \right)$$ be an arbitrary point on the line and then let$f$ represent the square of the distance function, since minimizing it will also minimize the distance function itself.

$$\displaystyle f(x)=D^2(x)=\left(x-x_1 \right)^2+\left(\frac{Ax+C}{B}+y_1 \right)^2$$

Now, differentiate with respect to $x$, and equate to zero to find the critical value.

#### Evgeny.Makarov

##### Well-known member
MHB Math Scholar
Re: shortest distance between line and point

I added another proof to the commentary thread, but it relies on the properties of dot product rather than calculus.

#### Opalg

##### MHB Oldtimer
Staff member
Another way to prove the distance formula by calculus is to use Lagrange multipliers. We want to minimise the square of the distance, $d^2 = (x-x_1)^2 + (y-y_1)^2$ subject to the constraint $Ax+By+C = 0.$ So we take the partial derivatives of $(x-x_1)^2 + (y-y_1)^2 - \lambda(Ax+By+C)$ with respect to $x$ and $y$, and put them equal to $0$: $$2(x-x_1) - \lambda A = 0,\qquad 2(y-y_1) - \lambda B = 0.$$ Thus $x = x_1 + \frac12\lambda A,\ y = y_1 + \frac12\lambda B$. Substitute those into the constraint equation to get $A\bigl(x_1 + \frac12\lambda A\bigr) + B\bigl(y_1 + \frac12\lambda B\bigr) + C = 0$, from which $\lambda = - \dfrac{2(Ax_1+By_1+C)}{A^2+B^2}.$ Then $$d^2 = (x-x_1)^2 + (y-y_1)^2 = \bigl(\tfrac12\lambda A\bigr)^2 + \bigl(\tfrac12\lambda B\bigr)^2 = \bigl(\tfrac12\lambda\bigr)^2(A^2+B^2) = \frac{(Ax_1+By_1+C)^2}{A^2 + B^2}.$$ Now take the square root to get $d = \dfrac{|Ax_1+By_1+C|}{\sqrt{A^2+B^2}}.$

#### karush

##### Well-known member
Re: shortest distance between line and point

$$\displaystyle f(x)=D^2(x)=\left(x-x_1 \right)^2+\left(\frac{Ax+C}{B}+y_1 \right)^2$$

Now, differentiate with respect to $x$, and equate to zero to find the critical value.
I got lost trying $d/dx$ this

#### MarkFL

Staff member
Re: shortest distance between line and point

I got lost trying $d/dx$ this
Okay, let's have a look see...

Using the power and chain rules, we obtain:

$$\displaystyle \frac{df}{dx}=2\left(x-x_1 \right)(1)+2\left(\frac{Ax+C}{B}+y_1 \right)\left(\frac{A}{B} \right)=0$$

Multiplying through by $$\displaystyle \frac{B^2}{2}$$, we may write:

$$\displaystyle B^2\left(x-x_1 \right)+A\left(Ax+C+By_1 \right)=0$$

Solving for $x$, there results:

$$\displaystyle x=\frac{B^2x_1-ABy_1-AC}{A^2+B^2}$$

Because $f$ is the sum of two squares, we know this critical value must be at the global minimum, but we could also use the argument that:

$$\displaystyle \frac{d^2f}{dx^2}=2+2\frac{A^2}{B^2}>0\,\forall (A,B)\in\mathbb{R}$$

#### MarkFL

Let $p$ be the perpendicular distance between the point and the line. we may then state:
$$\displaystyle d(\theta)=p\csc(\theta)$$
Now, minimize this function. 