If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Distance between point & line

The distance from a point to a line is the shortest distance between the point and any point on the line. This can be done with a variety of tools like slope-intercept form and the Pythagorean Theorem. Created by Sal Khan.

Want to join the conversation?

  • female robot grace style avatar for user Darren Laberee
    How do i find a point on the line that is NOT the Y intercept. I can see the answer if I graph it, but how do I glean the point on the intercepted line with math. The problem I was working was distance between the point (-6,-5) and the line y=-3x+7. I have the y intercept as -3, but how do I get the intercept on the other line?
    (18 votes)
    Default Khan Academy avatar avatar for user
  • leaf green style avatar for user Brittany
    Isn't there a formula for this? Can someone explain to me the formula of:
    |Ax+By+C| / sqrt(A^2+B^2)
    I found it online but it is very vague and doesn't help me. Thanks!
    (11 votes)
    Default Khan Academy avatar avatar for user
  • aqualine ultimate style avatar for user UltimateUniverse
    Could you make a video of how to find the distance between 2 parallel lines?
    (9 votes)
    Default Khan Academy avatar avatar for user
  • aqualine ultimate style avatar for user Maryam Shamsi
    Can't you just use the Pythagorean theorem instead?
    (0 votes)
    Default Khan Academy avatar avatar for user
    • hopper happy style avatar for user Rashel
      Sal does mention ( I forgot which video) that the distance formula is just an application of the Pythagorean Theorem. When you are finding the distance between 2 points, you are essentially trying to find the hypotenuse of those points. Hypotenuse =distance. The change in y over the change in x are the other 2 sides of the triangle.

      I like to draw a right triangle and label the side of the 90 degree angle with the change in y (rise) (ex: 3) and the base of the triangle I write down the change in x (run) (ex:2)

      Then I just use the Pythagorean Theorem. 3^2 +2^2=c^2
      9+4=13
      Take the square of 13, can't be simplified. So the distance is square root 13. I like it better that way, cause it's easier to visualize when I draw the triangle.
      (8 votes)
  • purple pi purple style avatar for user Nikki
    Why does making the equations equal create the x coordinate? I'm kind of lost :/
    (3 votes)
    Default Khan Academy avatar avatar for user
    • spunky sam blue style avatar for user adelacosta1
      It's because when you set them equal to one another you can solve for the variable x. In order to find x you need to have just the variable x and a constant (a number without a variable) in each of the equations and set them equal to one another.
      (2 votes)
  • blobby green style avatar for user sd120
    Wait then can't you use like a graph to find it? Like the f(x) graph since we are trying to find if x equals something y is what? Or am I confusing the 2 together?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • hopper jumping style avatar for user zayaz2016
    At , the distance formula is mentioned. what is the distance formula? And why is it the same thing as the Pythagorean Theorem? I thought they were two completely different formulas.
    (1 vote)
    Default Khan Academy avatar avatar for user
    • mr pink red style avatar for user andrewp18
      The distance formula is a formula you can use to find the shortest distance between any 2 points on the coordinate plane. You are correct that the distance formula and Pythagorean theorem are 2 different things but the distance formula is derived from the Pythagorean theorem. The distance formula is:
      d = √[(({x_1} - {x_2})^(2)) + (({y_1} - {y_2})^(2))]
      (4 votes)
  • female robot amelia style avatar for user poorvabakshi21
    Why is the slope of the perpendicular line the negative inverse of the slope of the other line?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • aqualine tree style avatar for user Judith Gibson
      Here's what I think --- and it will definitely help to draw a graph to illustrate what I say.
      1. So draw an original line through the origin that has very little incline (this is just to emphasise what follows). Also sketch its perpendicular, again going through the origin.
      2. The slope of the perpendicular line is the opposite sign of the original line because it is going in the opposite direction from the original line (one goes through quadrants 1 and 3, the other through quadrants 2 and 4).
      3. The slope of the original line is "change in y" / "change in x". For our purposes, let's denote this as "y original change" / "x original change". Mark it clearly on your graph.
      4. The perpendicular line has been formed by rotating the original line by 90 degrees.
      Notice that the length of "y perpendicular change" is now the length of "x original change", and similarly, the length of "x perpendicular change" is now the length of "y original change". So the slope of the perpendicular line in now "x original change" / "y original change".
      That's why we need to use an inverse for the perpendicular line's slope.
      Hope you find this useful!
      (2 votes)
  • blobby green style avatar for user hinton_gracie
    I put the points (0,2) and (-2,-6) into the distance formula and I did not get the square root of 40, instead I got the square root of 68?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • leafers ultimate style avatar for user Robert  Pereddo
    Find the distance between the point (−1,5) and the line y=1/2x−7.

    for this equation can someone please tell me how to get the coordinates of when the line intercepts with the other line.

    The equation of the perpendicular line is y=−2x+3.

    and also how i would find the 4,-5 without looking in on the graph whats the equation? for something like this?

    We can see from the graph (or by setting the equations equal to one another) that the two lines intersect at the point (4,−5). Thus, the distance we're looking for is the distance between the two red points.
    (1 vote)
    Default Khan Academy avatar avatar for user
    • hopper cool style avatar for user Chuck Towle
      Robert,
      You need to find the point that is on both lines by solve the system of equations.
      You can o this using substitution.
      y= 1/2x-7
      y=-2x+3
      Because y = 1/2x-7 you can put (1/2x-7) for the y in the second equation
      1/2 x - 7 = -2x+3 Add 2x to both sides.
      1/2x + 2x -7 = 3 Add 7 to both sides
      1/2x+4/2x = 3+7
      5/2x = 10 Multiply both sides by 2/5
      x=10*2/5
      x=4

      Now find y by substituting 4 for x in one of the equations.
      y=-2(4)+3
      y=-8+5
      y= -5
      So the point on both lines is (4,-5)

      And you can now find the distance between point (-1,5) and (4,-5) using the Pythagorean Theorem .

      I hope that helps make it click for you.

      Then you need to find
      (4 votes)

Video transcript

Find the distance between the point negative 2, negative 4. This point right here. And the line y is equal to negative 1/3 x plus 2. That's this line right over here. Now to do it, we just need to figure out a perpendicular line to this blue line, to y is equal to negative 1/3 x plus 2, that contains this point right over here. So we need to figure out the equation of this line. And then we need to figure out where do these two lines intersect, and then we need to find the distance between these two points of intersection, and we have the shortest distance between this point and this line right over here. So the first step is to figure out what is the slope of this perpendicular line. Well, the slope of a perpendicular line is going to be the negative inverse of the slope of this blue line. So the negative inverse of negative 1/3 is going to be positive 3. So this line right over here is going to have a slope of 3. So it's going to have the form y is equal to 3x plus b, where b is its y-intercept. It looks, just eyeballing it here, that it's going to be pretty close to 2. But let's verify that. So to figure out what b actually is, let's substitute this point right over here. We know that not only is this line slope 3, but this point has to sit on it. So this point has to satisfy this equation. So when x is negative 2, y is negative 4. Or we have negative 4 is equal to 3 times negative 2 plus b. Let me write the negative 2 in there. 3 times negative 2 plus b. And now we can solve for b. We get negative 4 is equal to negative 6 plus b. Add 6 to both sides, you get 2 is equal to b or b is equal to 2. So we were right. The y-intercept for the second line is at 2. So we immediately can eyeball, or we can verify, where they both intersect. They both intersect the y-axis at y equals 2. For both of these, when x is equal to 0, y is equal to 2. If it wasn't so obvious, we could set these two equations equal to each other. We could say look, we have 3x plus 2. We know that this is now 3x plus 2, because b is 2. When does 3x plus 2 equal negative 1/3 x plus 2? Well, let's see. If we subtract 2 from both sides, when does 3x equal negative 1/3 x? Well, there's a couple of things that we could do right over here. We could add 1/3 x to both sides. And then we will get 3 and 1/3, which is the same thing as (10/3)x is equal to 0. And if you multiply both sides by 3/10, you get x is equal to 0. So these two lines intersect when x is equal to 0. For both of them, when x is equal to 0, y is equal to 2. But you could have eyeballed it here. You could have seen that both of their y-intercepts, which happens when x is equal to 0, y is equal to 2. So this point right over here is the point 0, 2. We already know that this point right over here is the point negative 2, negative 4. And now we just need to find the distance between these two points. And the distance formula really is just an application of the Pythagorean theorem. We just need to find the distance in the change in the y direction and the change in the x direction. So let's do that separately. So in the y direction, what is this distance right over here? So we went from y is equal to negative 4 to y is equal to 2. This distance right over here is 6. And what is this distance right over here? Well, we go from x equals negative 2 to x equals 0. So this distance right over here is 2. So the distance between these two points is really just the hypotenuse of a right triangle that has sides 6 and 2. If we call this distance d, we could say that the distance squared is equal to. And all I'm really doing here is restating the distance formula. The distance formula tells you all this Y2 minus Y1, which is 6, squared. But that's just the Pythagorean theorem. That's just saying 6 squared plus x2 minus x1, which is 0 minus negative 2, which is positive 2 squared is going to be equal to the distance squared. But we see that's just the Pythagorean theorem. But anyway, let's solve for the distance. So the distance squared is going to be equal to 36 plus 4, which is 40. And now, let's see. The distance is equal to the square root of 40. Square root of 40 is the same thing as the square root of 4 times 10. And so that's the same. So the distance is equal to 2 if we factor out the 4. It's the square root of 4 times square root of 10. 2 is the square root of 4. 2 square roots of 10. And we're done.