# How to determine the distance from a point to a line

Consider the normed space $(\mathbb R^2, |\cdot|).$ Given a point $p\in\mathbb R^2$ and a subset $S\subset\mathbb R^2$, define the distance from $p$ to $S$ by $$d(p,S)=\inf\{|p-q|\colon q\in S\}.$$ Suppose $S$ is a line given by the equation $a\cdot x+b\cdot y+c=0$ (where $a,b,c\in\mathbb R$ are constant). How can I show that $$d(p,S)=\frac{|a\cdot x+b\cdot y+c|}{\sqrt{a^2+b^2}},$$ by using the definition of $d(p,S)$ (without using a linear algebra argument)?

-
The formula you wrote down does not evaluate to a real number, but is a function of $x$ and $y$. –  user20266 Jun 3 '12 at 15:21
You've made a mistake in your formula for $d(p,S)$. There should be $\sqrt{a^2+b^2}$ in the denominator –  Norbert Jun 3 '12 at 15:28
The line formula is for $\mathbb{R}^2$. So, you should replace the $n$ by $2$. –  copper.hat Jun 3 '12 at 16:01

A general point on that line can be written as $$\left(x\,,\,-\frac{a}{b}x-\frac{c}{b}\right)$$ (If $\,b=0\,$ then this is a vertical line and the distance is just the abolute value of the difference of the abscissas and we don't need all this).

Then you want to minimize the function $$f(x):=\sqrt{\left(\alpha-x\right)^2+\left(\beta-\left(-\frac{a}{b}x-\frac{c}{b}\right)\right)^2}\,\,,\,\,p=(\alpha,\beta)$$Of course, you don't have to work with this function if you don't want to: you can work with his square $\,g(x):=f(x)^2\,$ (why?) , so $$g'(x)=2(x-\alpha)+\frac{2a}{b^2}(ax+b\beta+c)=0\Longrightarrow x=\frac{b^2\alpha-ab\beta-ac}{a^2+b^2}...etc$$

-

We can assume that $a^2 + b^2 = 1$. Then the line can be written in parametric form:

$$x = -bt + ac$$ $$y = at + bc$$

The (squared) distance from the point $(x, y)$ to the generic point on the line is then:

$$d(x,y,t) = [x - (-bt +ac)]^2 + [y - (at +bc)]^2$$

This is a simple quadratic in t, so it's easy to find the place where it's a minimum (either by differentiation of by using well-known properties of quadratic functions).

-