# Distance Between A Point And A Line

Any Hint on proving that the distance between the point $(x_{1},y_{1})$ and the line $Ax + By + C = 0$ is ,

$$\text{Distance} = \frac{\left | Ax_{1} + By_{1} + C\right |}{\sqrt{A^2 + B^2} }$$

What do i use to get started? All i know is the distance formula $\sqrt{(x_{2}-x_{1})^2+(y_{2}-y_{1})^2}$.

Kindly Help

-
Try to find the global minima of your distance formula when plugging in the line for $x_2,y_2$ – Listing Nov 26 '11 at 12:43
I have no idea how to find the global minima. – alok Nov 26 '11 at 12:55
A geometric way of looking at it: your problem is equivalent to finding the radius of a circle that is tangent to a given line and centered at a given point. Remember that tangency of a circle and a line corresponds to the resulting quadratic equation having a double root. – J. M. Nov 26 '11 at 13:49
@J.M. Assuming the OP knows the tangency condition (or in the worst case to get tangent replace $x^2$ by $xx'$ etc), this is the best way, IMHO. – Tapu Nov 26 '11 at 14:05

For what it's worth, here's the outline using the "derivative approach". Since you tagged this as analytic geometry, I would think the splendid answers by Americo and Didier would be the better approach.

Rewriting your equation of the line for $B\ne0$ gives: $$y={-Ax-C\over B}.$$ (If $B=0$, the line is vertical, and the problem is simple.)

If the point $(x, {-Ax-C\over B})$ is on the line, its distance to $(x_1,y_1)$ is $$\tag{1}D=\sqrt{ (x_1-x)^2 + {\Bigl(y_1- { \textstyle{-Ax-C\over B}}\Bigr)^2 }}.$$

You want to find the smallest value of $D$. This is equivalent to finding the smallest value of $$P(x)=D^2= (x_1-x)^2 + {\Bigl(y_1- { \textstyle{-Ax-C\over B}}\Bigr)^2 }$$

Now, it should be obvious that the distance from a point $p$ on the line to $(x_1,y_1)$ is big, if $p$ is "on an extreme end of the line". So, the minimum distance is attained at a point where $P'(x)=0$.

So, you need to find $P'(x)$, then solve $P'(x)=0$. I'll leave this for you...

You should only get one solution to $P'(x)=0$. The minimum of $P$, and hence the minimum of $D$, would then have to occur at this point . If you then plug this solution into (1), your formula will result after a bit of simplification.

-
Just doing it to buy time!!I see there are many methods to prove this.The elementary geometric derivation was the easiest for me,However I have considered all the solutions to be very usefull.Thanks to all of you. – alok Nov 26 '11 at 13:46
I thought I'd give this a go. I found $P'(x)$ and solved $P'(x) = 0$. Plugging that into (1) was where I had to give up though. I started to work through the formula and things got too complicated for me. Perhaps I'm missing a trick on how to simplify this expression by hand effectively. – PeteUK May 9 '13 at 10:18
Following up from my last comment, I asked a separate question about doing the algebraic simplification and got a good response. – PeteUK May 12 '13 at 15:47

The distance $d$ between the point $P_1(x_{1},y_{1})$ and the line $r$ whose equation is $Ax+By+C=0$ can be derived algebraically as follows:

i) Find the equation of the straight line $s$ passing through $P_1$ and which is orthogonal to $r$. Call $P_2$ the intersecting point of $r$ and $s$.

ii) Find the co-ordinates of $P_2(x_{2},y_{2})$.

iii) Find the distance from $P_1$ to $P_2$. This distance is $d$.

-
orthogonal means perpendicular right? If that's the case i know that $m_{1}m_{2} = -1$ or $m_{1} = \frac{-1}{m_{2}}$ where m is the slope.Still strugling to get started. – alok Nov 26 '11 at 13:35
It looks I have done all the exercises you prescribed for the OP :) – Tapu Nov 26 '11 at 14:10
@alok Yes. Let $A'x+B'y+C'=0$ be the equation of $s$. Compute the slopes $m=-A/B$ and $m'=-A'/B'$. Let $\theta$ be the angle between $r$ and $s$. From the condition $\tan \theta=0$, and since $P_1$ is a point of $s$ one can show that the equation of $s$ is $B(x-x_1)-A(y-y_1)=0$. – Américo Tavares Nov 26 '11 at 14:21
@Swapan: That's right. In my comment to OP I try to indicate how your equation $(2)$ may be derived using trigonometry. – Américo Tavares Nov 26 '11 at 14:29

Here is an elementary geometric derivation of the formula:

Any (st.)line perpendicular to the line $$Ax+By+C=0\qquad\text{(1)}$$ is given by $$Bx-Ay+C'=0\qquad\text{(2)}$$ Since (2) has to pass through the point $(x_1,y_1)$ (WHY?), we have $C'=Ay_1-Bx_1$. So, (2) becomes $$Bx-Ay+Ay_1-Bx_1=0\Rightarrow \frac{x-x_1}{A}=\frac{y-y_1}{B}=t\text{ (say)}\qquad(3)$$ From (3), $x=At+x_1$ and $y=Bt+y_1$. This is (called) the parametric equation of the line (2). Each $t$ correspond a point in it and vice-verse. Our next task is to determine the value of $t$ such that (1) and (2) meet at that point. To do so, substituting the value of $x$ and $y$ in (1), we get $t=-\frac{Ax_1+By_1+C}{A^2+B^2}$. Hence the required distance is $$\sqrt{(x-x_1)^2+(y-y_1)^2}=\sqrt{A^2t^2+B^2t^2}=|t|\sqrt{A^2+B^2}=\frac{|Ax_1+By_1+C|}{\sqrt{A^2+B^2}}.$$

-

Assume $(x_0,y_0)$ is on the line and $(x_1-x_0,y_1-y_0)$ is orthogonal to the line. Pythagore says the square of the distance from $(x_1,y_1)$ to any $(x,y)$ on the line is the sum of the squares of the distances from $(x_1,y_1)$ to $(x_0,y_0)$ and from $(x_0,y_0)$ to $(x,y)$. Hence this distance is minimal when $(x,y)=(x_0,y_0)$.

What is $(x_0,y_0)$? First, $(x_0,y_0)$ is on the line hence $Ax_0+By_0+C=0$. Second, the vector $(x_1-x_0,y_1-y_0)$ is orthogonal to the line hence it is proportional to $(A,B)$.

Thus $x_0=x_1-Az$ and $y_0=y_1-Bz$ for some $z$. Plugging this into the first condition yields $A(x_1-Az)+B(y_1-Bz)+C=0$, that is, $(A^2+B^2)z=Ax_1+By_1+C$.

Finally, the distance $D$ from $(x_0,y_0)$ to the line is simply the Euclidean norm of the vector $(Az,Bz)$, hence $D^2=(A^2+B^2)z^2$, and I will let you finish from here.

-

I am not solving but i'm giving steps for it. 1.draw a perpendicular on giving line from given point. 2.since we've line equation so we can find out its slope(m). 3.use the relation to find out slope of perpendicular line m1*m2=-1 (m1 and m2 are slopes of perpendicular lines).now we have slope of perpendicular line and 1 point from which it is passing by(given point(x1,y1)). 4.find out equation of perpend.line. 5.find out intersection point of bot line. 6.finally calculate distance between given point and intersection point.

-