# Let l be a line described by equation ax+by+c=0 and let P(x,y) be a point not on l. Express the distance, d between l and P in terms of the coefficients a, b and c of the equation of line?

## Nov 14, 2016

$d = \frac{c + a {x}_{0} + b {y}_{0}}{\sqrt{{a}^{2} + {b}^{2}}}$

#### Explanation:

Let $l \to a x + b y + c = 0$ and ${p}_{0} = \left({x}_{0} , {y}_{0}\right)$ a point not on $l$.

Supposing that $b \ne 0$ and calling ${d}^{2} = {\left(x - {x}_{0}\right)}^{2} + {\left(y - {y}_{0}\right)}^{2}$ after substituting $y = - \frac{a x + c}{b}$ into ${d}^{2}$ we have

${d}^{2} = {\left(x - {x}_{0}\right)}^{2} + {\left(\frac{c + a x}{b} + {y}_{0}\right)}^{2}$. The next step is find the ${d}^{2}$ minimum regarding $x$ so we will find $x$ such that

$\frac{d}{\mathrm{dx}} \left({d}^{2}\right) = 2 \left(x - {x}_{0}\right) - \frac{2 a \left(\frac{c + a x}{b} + {y}_{0}\right)}{b} = 0$. This occours for

$x = \frac{{b}^{2} {x}_{0} - a b {y}_{0} - a c}{{a}^{2} + {b}^{2}}$ Now, substituting this value into ${d}^{2}$ we obtain

${d}^{2} = {\left(c + a {x}_{0} + b {y}_{0}\right)}^{2} / \left({a}^{2} + {b}^{2}\right)$ so

$d = \frac{c + a {x}_{0} + b {y}_{0}}{\sqrt{{a}^{2} + {b}^{2}}}$