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 formula

Walk through deriving a general formula for the distance between two points.
The start color #11accd, start text, d, i, s, t, a, n, c, e, end text, end color #11accd between the points left parenthesis, start color #1fab54, x, start subscript, 1, end subscript, end color #1fab54, comma, start color #e07d10, y, start subscript, 1, end subscript, end color #e07d10, right parenthesis and left parenthesis, start color #1fab54, x, start subscript, 2, end subscript, end color #1fab54, comma, start color #e07d10, y, start subscript, 2, end subscript, end color #e07d10, right parenthesis is given by the following formula:
square root of, left parenthesis, start color #1fab54, x, start subscript, 2, end subscript, minus, x, start subscript, 1, end subscript, end color #1fab54, right parenthesis, squared, plus, start color #e07d10, left parenthesis, y, start subscript, 2, end subscript, minus, y, start subscript, 1, end subscript, end color #e07d10, right parenthesis, squared, end square root
In this article, we're going to derive this formula!

Deriving the distance formula

Let's start by plotting the points left parenthesis, start color #1fab54, x, start subscript, 1, end subscript, end color #1fab54, comma, start color #e07d10, y, start subscript, 1, end subscript, end color #e07d10, right parenthesis and left parenthesis, start color #1fab54, x, start subscript, 2, end subscript, end color #1fab54, comma, start color #e07d10, y, start subscript, 2, end subscript, end color #e07d10, right parenthesis.
The first quadrant of a coordinate plane with two tick marks on the x axis labeled x one and x two. There are two tick marks on the y axis labeled y one and y two. There is a point at x one, y one and another point at x two, y two.
The length of the segment between the two points is the start color #11accd, start text, d, i, s, t, a, n, c, e, end text, end color #11accd between them:
The first quadrant of a coordinate plane with two tick marks on the x axis labeled x one and x two. There are two tick marks on the y axis labeled y one and y two. There is a point at x one, y one and another point at x two, y two. A line connects the two points.
We want to find the start color #11accd, start text, d, i, s, t, a, n, c, e, end text, end color #11accd. If we draw a right triangle, we'll be able to use the Pythagorean theorem!
The first quadrant of a coordinate plane with two tick marks on the x axis labeled x one and x two. There are two tick marks on the y axis labeled y one and y two. There is a point at x one, y one and another point at x two, y two. A line connects the two points. A third unlabeled point is at x two, y one with a line connecting from it to the point at x two, y two and another line connecting from it to the point at x one, y one forming a right triangle.
An expression for the length of the base is start color #1fab54, x, start subscript, 2, end subscript, minus, x, start subscript, 1, end subscript, end color #1fab54:
The first quadrant of a coordinate plane with two tick marks on the x axis labeled x one and x two. There are two tick marks on the y axis labeled y one and y two. There is a point at x one, y one and another point at x two, y two. A line connects the two points. A third unlabeled point is at x two, y one with a line connecting from it to the point at x two, y two and another line connecting from it to the point at x one, y one forming a right triangle. The hypotenuse of the right triangle is unknown and the side made from the point at x one, y one and x two, y one is labeled x two minus x one.
Similarly, an expression for the length of the height is start color #e07d10, y, start subscript, 2, end subscript, minus, y, start subscript, 1, end subscript, end color #e07d10:
The first quadrant of a coordinate plane with two tick marks on the x axis labeled x one and x two. There are two tick marks on the y axis labeled y one and y two. There is a point at x one, y one and another point at x two, y two. A line connects the two points. A third unlabeled point is at x two, y one with a line connecting from it to the point at x two, y two and another line connecting from it to the point at x one, y one forming a right triangle. The hypotenuse of the right triangle is unknown and the side made from the point at x one, y one and x two, y one is labeled x two minus x one. The third side is labeled y two minus y one.
Now we can use the Pythagorean theorem to write an equation:
start color #11accd, question mark, end color #11accd, squared, equals, left parenthesis, start color #1fab54, x, start subscript, 2, end subscript, minus, x, start subscript, 1, end subscript, end color #1fab54, right parenthesis, squared, plus, start color #e07d10, left parenthesis, y, start subscript, 2, end subscript, minus, y, start subscript, 1, end subscript, end color #e07d10, right parenthesis, squared
We can solve for start color #11accd, question mark, end color #11accd by taking the square root of each side:
start color #11accd, question mark, end color #11accd, equals, square root of, left parenthesis, start color #1fab54, x, start subscript, 2, end subscript, minus, x, start subscript, 1, end subscript, end color #1fab54, right parenthesis, squared, plus, start color #e07d10, left parenthesis, y, start subscript, 2, end subscript, minus, y, start subscript, 1, end subscript, end color #e07d10, right parenthesis, squared, end square root
That's it! We derived the distance formula!
Interestingly, a lot of people don't actually memorize this formula. Instead, they set up a right triangle, and use the Pythagorean theorem whenever they want to find the distance between two points.

Want to join the conversation?

  • duskpin sapling style avatar for user Karen Boyce
    How do you find the distance between two points if it is just a line?
    (5 votes)
    Default Khan Academy avatar avatar for user
    • duskpin ultimate style avatar for user V1rtua1F0X
      To find the distance between to points if it is just a line, you simply draw a dot where the line ends, then you make a number line and find the coordinates for both points. Finally, you follow the distance formula, plug the values in, and solve.

      I hope this helps and wasn't a bore!
      (2 votes)
  • blobby green style avatar for user Maria Lopes
    what is the formula that is used to find distance between two points
    (0 votes)
    Default Khan Academy avatar avatar for user
  • male robot johnny style avatar for user Ivan Brown
    I still don't understand any of this... :I
    (1 vote)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user Durgen
    I prefer the straight up: draw a right triangle, use pythagorean theorem method. Anyone agree?
    (4 votes)
    Default Khan Academy avatar avatar for user
    • mr pink green style avatar for user David Severin
      The distance formula is an application of the Pythagorean Theorem, so what are you doing differently that makes it seem different to you? Are you just finding the x2-x1 and y2-y1 from the graph before putting it into the Pythagorean Theorem?
      (1 vote)
  • aqualine tree style avatar for user rose
    who came up with this formula?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • marcimus purple style avatar for user Nevaeh
      .Nevertheless, the theorem came to be credited to Pythagoras. It is also proposition number 47 from Book I of Euclid's Elements. According to the Syrian historian Iamblichus (c. 250–330 ce), Pythagoras was introduced to mathematics by Thales of Miletus and his pupil Anaximander. Brittanica.com states “ Pythagorean theorem, the well-known geometric theorem that the sum of the squares on the legs of a right triangle is equal to the square on the hypotenuse (the side opposite the right angle)—or, in familiar algebraic notation, a2 + b2 = c2. Although the theorem has long been associated with Greek mathematician-philosopher Pythagoras (c. 570–500/490 BCE), it is actually far older. Four Babylonian tablets from circa 1900–1600 BCE indicate some knowledge of the theorem, with a very accurate calculation of the square root of 2 (the length of the hypotenuse of a right triangle with the length of both legs equal to 1) and lists of special integers known as Pythagorean triples that satisfy it (e.g., 3, 4, and 5; 32 + 42 = 52, 9 + 16 = 25). The theorem is mentioned in the Baudhayana Sulba-sutra of India, which was written between 800 and 400 BCE. Nevertheless, the theorem came to be credited to Pythagoras.” I know that’s a lot of words but I had to do it...even tho this isn’t ELA class 😀😂. Hope this helps rose!
      (7 votes)
  • spunky sam blue style avatar for user Pink_Ivy_Nikes
    Sooooo, if I have two points, (1, 2) and (-1, 4), it does not matter in which order I subtract as long as I do the x with the x, and so on? Because it doesn't look that way.
    (1 vote)
    Default Khan Academy avatar avatar for user
  • duskpin seed style avatar for user K.B
    what is one of the points are a fraction? like how would that work
    (2 votes)
    Default Khan Academy avatar avatar for user
    • primosaur seed style avatar for user Ian Pulizzotto
      You would still use the distance formula or the Pythagorean theorem, except that you would perform the arithmetic with the fractions. Remember that when you square a fraction, you need to square both top and bottom; when you take the square root of a fraction, you need to take the square root of both top and bottom.

      Have a blessed, wonderful day!
      (2 votes)
  • aqualine ultimate style avatar for user Alek Burkowicz
    Why is it called the Pythagorean theorem? Can't it be something else like the triangle theory?
    (0 votes)
    Default Khan Academy avatar avatar for user
  • spunky sam blue style avatar for user rasheedw1028
    this is hard and can you help me.
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user isabellemontgomery
    okay I understand all you to do is take your Y axis and divide it by your X axis
    (2 votes)
    Default Khan Academy avatar avatar for user