# Distance between a line and a point

#### Amer

##### Active member
Find the distance between a line and a point using the extreme values
My work

Let the line
$ay - bx - c = 0$
$y = \frac{bx+c}{a}$
and the point $(s,t)$

$D(x)= \sqrt{(x - s)^2 + (y - t)^2 }$
minimize
$D ' (x) = \dfrac{x -s +y' (y - t)}{\sqrt{(x - s)^2 + (y - t)^2 }}$

$x -s +y' (y - t) = 0\\$
$x - s + \frac{b}{a}\left(\frac{bx+c}{a} - t \right)=0$
$ax - as + b\left(\frac{bx+c}{a} - t \right) = 0$
$$a^2x - a^2s + b^2x + bc - abt = 0$$
$$x (a^2+b^2) = a^2s - bc + abt$$
$$x = \dfrac{a^2s - bc +abt }{a^2+b^2}$$
and
$$y = \dfrac{b(a^2s - bc + abt) + c(a^2+b^2)}{a(a^2+b^2)}$$
The minmum D

$$D = \sqrt{\left(\dfrac{a^2s - bc +abt }{a^2+b^2} - s\right)^2 + \left(\dfrac{b(a^2s - bc + abt) + c(a^2+b^2)}{a(a^2+b^2)} - t\right)^2 }$$

Now i have to simplify just did i miss something ?

#### CaptainBlack

##### Well-known member
Find the distance between a line and a point using the extreme values
My work

Let the line
$ay - bx - c = 0$
$y = \frac{bx+c}{a}$
and the point $(s,t)$

$D(x)= \sqrt{(x - s)^2 + (y - t)^2 }$
minimize
$D ' (x) = \dfrac{x -s +y' (y - t)}{\sqrt{(x - s)^2 + (y - t)^2 }}$
You will make things easier for yourself if you minimise $$D^2$$ rather than $$D$$.

CB

#### Amer

##### Active member
You will make things easier for yourself if you minimise $$D^2$$ rather than $$D$$.

CB
Thanks very much I did not notice that