# Dot Product - Distance between Point and a Line

The **distance between a point and a line,** is defined as the shortest distance between a fixed point and any point on the line. It is the length of the line segment that is perpendicular to the line and passes through the point.

The distance \(d\) from a point \(({ x }_{ 0 },{ y }_{ 0 })\) to the line \(ax+by+c=0\) is \[d=\frac { \left\lvert a({ x }_{ 0 })+b({ y }_{ 0 })+c \right\rvert }{ \sqrt { { a }^{ 2 }{ +b }^{ 2 } } } .\]

From the figure above let \(d\) be the perpendicular distance from the point \(Q({ x }_{ 0 },{ y }_{ 0 })\) to the line \(ax+by+c=0.\) We also let \(\vec{n}\) be a vector normal to the line that starts from point \(P({ x }_{ 1 },{ y }_{ 1 })\).

We can see from the figure above that the distance \(d\) is the orthogonal projection of the vector \(\vec{PQ}\). Thus we have from trigonometry:

\[d=\left\| \vec { PQ } \right\| \cos\theta .\]

Now, multiply both the numerator and the denominator of the right hand side of the equation by the magnitude of the normal vector \(\vec{n}:\)

\[d=\frac { \left\| \vec { PQ } \right\| \left\| \vec { n } \right\| \cos\theta }{ \left\| \vec { n } \right\| }.\]

We know from the definition of dot product that \( \left\| \vec { PQ } \right\| \left\| \vec { n } \right\| \cos\theta\) just means the dot product of the vector \(\vec{PQ}\) and the normal vector \(\vec{n}:\)

\[\begin{align} d&=\frac { \vec { PQ } \cdot \vec { n } }{ \left\| \vec { n } \right\| }\\ \vec{PQ}&=({ x }_{ 0 }-{ x }_{ 1 },{ y }_{ 0 }-{ y }_{ 1 }). \end{align}\]

So

\[\begin{align} \vec { PQ } \cdot \vec { n } &=({ x }_{ 0 }-{ x }_{ 1 },{ y }_{ 0 }-{ y }_{ 1 })\cdot (a,b)\\ &=a({ x }_{ 0 }-{ x }_{ 1 })+b({ y }_{ 0 }-{ y }_{ 1 }). \end{align}\]

And we also have \(\left\| \vec { n } \right\| =\sqrt { { a }^{ 2 }+{ b }^{ 2 } } ,\) thus

\[d=\frac { \left| a({ x }_{ 0 }-{ x }_{ 1 })+b({ y }_{ 0 }-{ y }_{ 1 }) \right| }{ \sqrt { { a }^{ 2 }{ +b }^{ 2 } } } =\frac { \left| a({ x }_{ 0 })-a({ x }_{ 1 })+b({ y }_{ 0 })-{ b(y }_{ 1 }) \right| }{ \sqrt { { a }^{ 2 }{ +b }^{ 2 } } }.\]

From the equation of the line we have \(c=-a(x_{1})-b(y_{1}),\) which implies

\[d=\frac { \left\lvert a({ x }_{ 0 })+b({ y }_{ 0 })+c \right\rvert }{ \sqrt { { a }^{ 2 }{ +b }^{ 2 } } } .\]

So given a line of the form \(ax+by+c\) and a point \((x_{0},y_{0}),\) the perpendicular distance can be found by the above formula.

## Find the distance between the line \(l=2x+4y-5\) and the point \(Q=(-3,2)\),

From the distance formula we have:

\[d=\frac { \left| 2(-3)+4(2)-5 \right| }{ \sqrt { 2^{ 2 }{ +4 }^{ 2 } } } =\frac { 3 }{ 2\sqrt { 5 } }.\]

## Find the distance between the line \(l=3x+4y-6=0\) and the point \((0,0)\).

The distance formula can be reduced to a simpler form if the point is at the origin as:

\[d=\frac { \left| a(0)+b(0)+c \right| }{ \sqrt { a^{ 2 }{ +b }^{ 2 } } } =\frac { \left| c \right| }{ \sqrt { { a }^{ 2 }{ +b }^{ 2 } } } .\]

So we have:

\[d=\frac { \left| -6 \right| }{ \sqrt { 3^{ 2 }{ +4 }^{ 2 } } } =\frac { 6 }{ 5 } .\]

**Cite as:**Dot Product - Distance between Point and a Line.

*Brilliant.org*. Retrieved from https://brilliant.org/wiki/dot-product-distance-between-point-and-a-line/