# Show that the distance between the point (x, y) and the line Ax + By + C = 0 is: D = \frac{Ax +...

## Question:

Show that the distance between the point (x, y) and the line Ax + By + C = 0 is:

{eq}D = \frac{Ax + By + C}{\sqrt{A^2 + B^2}} {/eq}

## Distance Between a Point and a Line and Scalar Projection:

When we know the direction vector of a line and a point P outside the line we can set a normal vector to the line that goes from point P outside the line. Then we can calculate the scalar projection of any vector that goes from point P to any point on the line onto the normal vector, so we get the distance between P and the line.

{eq}\eqalign{ & {\text{We have that the equation of the line is }}\,Ax + By + C = 0.{\text{ Then its direction vector }} \cr & {\text{(vector parallel to the line) is }}\vec v = \left\langle {B, - A} \right\rangle \cr & {\text{So}}{\text{, two vector }}{\mkern 1mu} \vec v = \left\langle {{v_x},{v_y}} \right\rangle {\mkern 1mu} {\text{ and }}{\mkern 1mu} \vec n{\text{ are perpendicular if }}{\mkern 1mu} \vec n = \left\langle {{v_y}, - {v_x}} \right\rangle {\text{, thus the normal}} \cr & {\text{vector to the line is: }}\,\vec n = \left\langle {A,B} \right\rangle {\text{.}} \cr & {\text{Now we establish a vector between the point }}\,{P_0}\left( {{x_0},{y_0}} \right){\text{ outside the line and a }} \cr & {\text{point }}\,{P_1}\left( {x,y} \right){\text{ contained in the line:}} \cr & \,\,\,\overrightarrow {{P_0}{P_1}} = \left\langle {x - {x_0},y - {y_0}} \right\rangle \cr & {\text{Let's find the scalar projection of }}\,\overrightarrow {{P_0}{P_1}} = \left\langle {x - {x_0},y - {y_0}} \right\rangle \,{\text{ onto }}\,\vec n = \left\langle {A,B} \right\rangle {\text{, so}}{\text{, the }} \cr & {\text{scalar projection is given by:}} \cr & \,\,D = \,com{p_{\vec n}}\overrightarrow {{P_0}{P_1}} = \frac{{\vec n \cdot \overrightarrow {{P_0}{P_1}} }}{{\left| {\vec n} \right|}} = \frac{{\left\langle {A,B} \right\rangle \cdot \left\langle {x - {x_0},y - {y_0}} \right\rangle }}{{\left| {\left\langle {A,B} \right\rangle } \right|}} \cr & \,\,D = \frac{{A\left( {x - {x_0}} \right) + B\left( {y - {y_0}} \right)}}{{\sqrt {{A^2} + {B^2}} }} \cr & \,\,D = \frac{{Ax - A{x_0} + By - B{y_0}}}{{\sqrt {{A^2} + {B^2}} }} \cr & \,\,D = \frac{{ - A{x_0} - B{y_0} + Ax + By}}{{\sqrt {{A^2} + {B^2}} }} \cr & {\text{Simplifying using }}\,Ax + By + C = 0\,\,\, \Rightarrow - C = Ax + By{\text{:}} \cr & \,\,D = \frac{{ - A{x_0} - B{y_0} - C}}{{\sqrt {{A^2} + {B^2}} }} \cr & {\text{By definition the distance can only be positive:}} \cr & \,\,D = \frac{{\left| { - \left( {A{x_0} + B{y_0} + C} \right)} \right|}}{{\sqrt {{A^2} + {B^2}} }} \cr & \,\,D = \frac{{\left| {A{x_0} + B{y_0} + C} \right|}}{{\sqrt {{A^2} + {B^2}} }} \cr & {\text{Therefore:}} \cr & \,\,\boxed{D = \frac{{A{x_0} + B{y_0} + C}}{{\sqrt {{A^2} + {B^2}} }}} \cr} {/eq}