Home / Articles / Geometry & Trigonometry
Geometry & Trigonometry · 4 min read

Coordinate Geometry: Distance, Midpoint and Slope

Learn the distance, midpoint and slope formulas in coordinate geometry, with clear derivations and worked examples on parallel and perpendicular lines.

Coordinate geometry turns shapes into numbers. By placing points on the \( xy \)-plane, you can measure lengths, find centres and test whether lines are parallel or perpendicular using simple algebra. The three formulas in this guide (distance, midpoint and slope) are the foundation of everything else in the topic, from equations of lines to circles and conic sections.

The Coordinate Plane in Brief

Every point is written as an ordered pair \( (x, y) \): first the horizontal position, then the vertical. Throughout this guide we use two general points:

$$ P(x_1, y_1) \qquad\text{and}\qquad Q(x_2, y_2) $$

The Distance Formula

The distance between \( P \) and \( Q \) is:

$$ d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2} $$

Where It Comes From

Draw a horizontal line from \( P \) and a vertical line from \( Q \). They meet at a right angle, forming a right triangle with horizontal leg \( x_2 - x_1 \) and vertical leg \( y_2 - y_1 \). The segment \( PQ \) is the hypotenuse, so the distance formula is just the Pythagorean theorem.

Because the differences are squared, it does not matter which point you call \( P \) and which you call \( Q \).

The Midpoint Formula

The midpoint \( M \) of segment \( PQ \) is found by averaging the coordinates:

$$ M = \left( \frac{x_1 + x_2}{2},\ \frac{y_1 + y_2}{2} \right) $$

This makes sense: halfway between two numbers is their average, and this is true separately in the \( x \) and \( y \) directions.

The Section Formula (Extension)

For FSc and A Level, the point dividing \( PQ \) internally in the ratio \( m : n \) is:

$$ \left( \frac{mx_2 + nx_1}{m + n},\ \frac{my_2 + ny_1}{m + n} \right) $$

The midpoint is the special case \( m = n = 1 \).

The Slope (Gradient) Formula

The slope \( m \) of the line through \( P \) and \( Q \) measures its steepness:

$$ m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{\text{rise}}{\text{run}} $$

What the value tells you:

  • \( m > 0 \): the line rises from left to right.
  • \( m < 0 \): the line falls from left to right.
  • \( m = 0 \): the line is horizontal.
  • Undefined (\( x_2 = x_1 \)): the line is vertical.

The slope also equals \( \tan\theta \), where \( \theta \) is the angle the line makes with the positive \( x \)-axis.

Parallel and Perpendicular Lines

  • Parallel lines have equal slopes: \( m_1 = m_2 \).
  • Perpendicular lines have slopes whose product is \( -1 \): \( m_1 m_2 = -1 \), so \( m_2 = -\dfrac{1}{m_1} \).

(Vertical and horizontal lines are perpendicular too, even though the product rule cannot be applied.)

Worked Example 1: All Three Formulas

Question: For \( A(2, -1) \) and \( B(8, 7) \), find the length \( AB \), the midpoint of \( AB \) and the slope of \( AB \).

Step 1: Distance.

$$ AB = \sqrt{(8 - 2)^2 + (7 - (-1))^2} = \sqrt{6^2 + 8^2} = \sqrt{36 + 64} = \sqrt{100} = 10 $$

Step 2: Midpoint.

$$ M = \left( \frac{2 + 8}{2},\ \frac{-1 + 7}{2} \right) = \left( \frac{10}{2},\ \frac{6}{2} \right) = (5, 3) $$

Step 3: Slope.

$$ m = \frac{7 - (-1)}{8 - 2} = \frac{8}{6} = \frac{4}{3} $$

Check: \( M \) should be 5 units from both ends: \( \sqrt{3^2 + 4^2} = 5 \). Correct.

Worked Example 2: Proving a Right-Angled Triangle

Question: Show that \( P(1, 1) \), \( Q(4, 5) \) and \( R(8, 2) \) form a right-angled triangle, and find its area.

Step 1: Slopes of two sides meeting at \( Q \).

$$ m_{PQ} = \frac{5 - 1}{4 - 1} = \frac{4}{3}, \qquad m_{QR} = \frac{2 - 5}{8 - 4} = \frac{-3}{4} $$

Step 2: Test for perpendicularity.

$$ m_{PQ} \times m_{QR} = \frac{4}{3} \times \left(-\frac{3}{4}\right) = -1 $$

So \( PQ \perp QR \) and the right angle is at \( Q \).

Step 3: Lengths of the legs.

$$ PQ = \sqrt{3^2 + 4^2} = 5, \qquad QR = \sqrt{4^2 + (-3)^2} = 5 $$

Step 4: Area.

$$ \text{Area} = \frac12 \times PQ \times QR = \frac12 \times 5 \times 5 = 12.5 \text{ square units} $$

Check with Pythagoras: \( PR = \sqrt{7^2 + 1^2} = \sqrt{50} \), and \( 5^2 + 5^2 = 50 \). Correct. The triangle is also isosceles.

Worked Example 3: Finding a Missing Endpoint

Question: The midpoint of \( CD \) is \( M(3, -2) \) and \( C = (-1, 4) \). Find \( D \).

Step 1: Set up equations. Let \( D = (x, y) \).

$$ \frac{-1 + x}{2} = 3 \qquad\text{and}\qquad \frac{4 + y}{2} = -2 $$

Step 2: Solve.

$$ -1 + x = 6 \Rightarrow x = 7, \qquad 4 + y = -4 \Rightarrow y = -8 $$

So \( D = (7, -8) \).

Worked Example 4: Collinear Points

Question: Are \( (1, 2) \), \( (3, 6) \) and \( (6, 12) \) collinear?

Step 1: Slope of the first pair. \( \dfrac{6 - 2}{3 - 1} = \dfrac{4}{2} = 2 \).

Step 2: Slope of the second pair. \( \dfrac{12 - 6}{6 - 3} = \dfrac{6}{3} = 2 \).

The slopes are equal and the lines share the point \( (3, 6) \), so the three points are collinear.

Common Mistakes

  • Sign errors with negatives. \( 7 - (-1) = 8 \), not 6. Use brackets when substituting.
  • Mixing the order in the slope formula. If you use \( y_2 - y_1 \) on top, you must use \( x_2 - x_1 \) below.
  • Subtracting in the midpoint formula. The midpoint uses a sum, not a difference.
  • Thinking perpendicular slopes are just negatives. They are negative reciprocals: the perpendicular to slope 2 is \( -\tfrac12 \), not \( -2 \).

Key Takeaways

  • Distance: \( \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2} \), which is Pythagoras on the grid.
  • Midpoint: average the \( x \)-coordinates and average the \( y \)-coordinates.
  • Slope: rise over run; it equals \( \tan\theta \) of the line's angle.
  • Parallel lines share a slope; perpendicular slopes multiply to \( -1 \).
  • Combine the formulas to prove shapes are right-angled, isosceles or collinear.

Have a coordinate geometry exercise or assignment you need help with? Message Amathify on WhatsApp or use the "Ask a Question" form, and our experts and PhD scholars will send a complete step-by-step solution.

Stuck on a problem or assignment?

Our experts and PhD scholars solve maths, physics and chemistry — step by step.

WhatsApp usAsk a question

Related articles