# distance from point to a line

The distance^{} from a point P with coordinates $({x}_{p},{y}_{p})\in {\mathbb{R}}^{2}$ to the line with equation $ax+by+c=0$ is given by $|a{x}_{p}+b{y}_{p}+c|/\sqrt{{a}^{2}+{b}^{2}}$.

Proof Every point $x,y$ on the line is at some distance $\sqrt{{(x-{x}_{p})}^{2}+{(y-{y}_{p})}^{2}}$ from P. What we need to find is the minimum such distance. Our problem is

$$\mathrm{min}{(x-{x}_{p})}^{2}+{(y-{y}_{p})}^{2}$$ |

subject to

$$ax+by+c=0$$ |

This problem is solvable using the Lagrange multiplier method. We minimize

$${(x-{x}_{p})}^{2}+{(y-{y}_{p})}^{2}+\lambda (ax+by+c)$$ |

Calculating the derivatives with respect to $x,y$ and $\lambda $ and setting them to zero we get three equations:

$2x-2{x}_{p}+\lambda a=0$ | (1) | ||

$2y-2{y}_{p}+\lambda b=0$ | (2) | ||

$2ax+2by+2c=0$ | (3) |

Solving these leads to ${x}_{p}-x=a\frac{a{x}_{p}+b{y}_{p}+c}{{a}^{2}+{b}^{2}}$ and ${y}_{p}-y=b\frac{a{x}_{p}+b{y}_{p}+c}{{a}^{2}+{b}^{2}}$. We can now substitute these expressions into $\sqrt{{(x-{x}_{p})}^{2}+{(y-{y}_{p})}^{2}}$ and we get (after some simplification) the desired result.

Title | distance from point to a line |
---|---|

Canonical name | DistanceFromPointToALine |

Date of creation | 2013-03-22 15:24:30 |

Last modified on | 2013-03-22 15:24:30 |

Owner | acastaldo (8031) |

Last modified by | acastaldo (8031) |

Numerical id | 7 |

Author | acastaldo (8031) |

Entry type | Result |

Classification | msc 51N20 |

Related topic | DistanceOfNonParallelLines |

Related topic | DistanceBetweenTwoLinesInR3 |

Related topic | Envelope |

Related topic | AngleBisectorAsLocus |