Slope using coordinates

Give a surveyor two pegs in a field and, without ever pointing a protractor at either, they can tell you how steeply a fence line between them climbs. The trick is the coordinate slope formula — one of the most-used tools in the whole "Straight Lines" chapter of CBSE Class 11 Coordinate Geometry. You already know slope as m=tan⁡θm = \tan\theta, the tangent of the angle a line makes with the horizontal. That definition is elegant but hard to use directly: you rarely get handed an angle. What you do get, over and over, are coordinates — two points a line passes through. This article turns those coordinates directly into a slope, shows why the formula is really the same tan⁡θ\tan\theta in disguise, flags when slope refuses to exist at all, and uses the idea to test whether three points sit on one straight line.

The core insight

The slope of a line through (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2) is the ratio of vertical change to horizontal change, m=y2−y1x2−x1m = \dfrac{y_2-y_1}{x_2-x_1}, undefined exactly when the line is vertical.

The core idea

From two points to a number. Let a line pass through two distinct points P(x1,y1)P(x_1, y_1) and Q(x2,y2)Q(x_2, y_2), with x1≠x2x_1 \neq x_2. Its slope is defined as the change in yy divided by the change in xx between the two points:

m=y2−y1x2−x1,m = \frac{y_2 - y_1}{x_2 - x_1},

where: mm is the slope of line PQPQ, (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2) are the two given points, and the difference x2−x1x_2-x_1 must be nonzero for the ratio to be defined.

It agrees with the angle definition. (y2−y1)(y_2-y_1) is exactly the vertical rise between the points and (x2−x1)(x_2-x_1) is exactly the horizontal run, so their ratio equals tan⁡θ\tan\theta, where θ\theta is the line's inclination — this coordinate formula is not a new idea, just a computable version of m=tan⁡θm=\tan\theta.

Order doesn't matter, as long as it's consistent. Swapping which point you call "first" and which "second" flips the sign of both the numerator and the denominator, so the ratio is unchanged: y2−y1x2−x1=y1−y2x1−x2\dfrac{y_2-y_1}{x_2-x_1} = \dfrac{y_1-y_2}{x_1-x_2}. What you must never do is swap only one of the two subtractions.

Two special cases to recognise on sight. If x1=x2x_1 = x_2 the line is vertical and the denominator is zero, so the slope is undefined — not zero, not infinite in a usable sense, simply not defined as a number. If y1=y2y_1 = y_2 the line is horizontal and the numerator is zero, so the slope is exactly 00.

Why the ratio never depends on which two points you pick. Take any two points on a line and drop a horizontal segment from the left one and a vertical segment from the right one; they meet at a right angle, forming a right triangle whose legs have lengths x2−x1x_2-x_1 and y2−y1y_2-y_1. The angle between the line and its horizontal leg is the inclination θ\theta itself, so tan⁡θ=y2−y1x2−x1\tan\theta = \dfrac{y_2-y_1}{x_2-x_1}. Any other pair of points on the same line forms a similar right triangle — same angle θ\theta, proportionally scaled legs — so the ratio of vertical to horizontal leg is identical every time. That is precisely why slope is a property of the whole line, not of any one pair of points on it.

Figure
Right triangle formed by two points on a line showing rise over run equal to slope
P(x1, y1) Q(x2, y2) run = x2 minus x1 rise = y2 minus y1 slope m = rise over run
Derivation ADeriving the coordinate slope formula

Show that for any two distinct points P(x1,y1)P(x_1, y_1) and Q(x2,y2)Q(x_2, y_2) on a line with x1≠x2x_1 \neq x_2, the slope m=tan⁡θm = \tan\theta defined by the line's inclination θ\theta equals exactly y2−y1x2−x1\dfrac{y_2 - y_1}{x_2 - x_1}, regardless of which of the two points is labelled first, and this ratio is the same no matter which two points on the line are used to compute it.

Step 1. Draw the line through P(x1,y1)P(x_1,y_1) and Q(x2,y2)Q(x_2,y_2), and let θ\theta be its inclination — the angle it makes with the positive direction of the x-axis, measured anticlockwise, with 0∘≤θ<180∘0^\circ \le \theta < 180^\circ and θ≠90∘\theta \neq 90^\circ so the line is not vertical.

Step 2. From PP draw a horizontal segment to the point R(x2,y1)R(x_2, y_1) directly below or above QQ, and from RR draw a vertical segment up to QQ. Because PRPR is horizontal and RQRQ is vertical, angle PRQPRQ is a right angle, and triangle PRQPRQ is right-angled at RR.

Step 3. The length of the horizontal leg PRPR is ∣x2−x1∣|x_2 - x_1| and the length of the vertical leg RQRQ is ∣y2−y1∣|y_2 - y_1|. Because PQPQ is itself a segment of the line, the angle that PQPQ makes with the horizontal leg PRPR is exactly the inclination θ\theta of the whole line.

Step 4. By the definition of tangent in a right triangle, tan⁡θ\tan\theta equals the opposite leg over the adjacent leg at the vertex PP: tan⁡θ=RQPR\tan\theta = \dfrac{RQ}{PR}. Keeping track of signs (rather than just magnitudes) so the formula works whether the line rises or falls, this becomes tan⁡θ=y2−y1x2−x1\tan\theta = \dfrac{y_2-y_1}{x_2-x_1}, and since slope is defined as m=tan⁡θm = \tan\theta, we get m=y2−y1x2−x1m = \dfrac{y_2-y_1}{x_2-x_1}.

Step 5. To confirm the formula does not depend on labelling, swap the points: using QQ first and PP second gives y1−y2x1−x2\dfrac{y_1-y_2}{x_1-x_2}, which is the previous fraction with both numerator and denominator multiplied by −1-1, so the value is unchanged. Hence the coordinate slope formula is well-defined for the line itself, not for an ordered pair of points.

Worked example

Problem. Find the slope of the line through A(2,−3)A(2,-3) and B(6,5)B(6,5), then use the same method to check whether A(1,1)A(1,1), B(3,5)B(3,5), and C(5,9)C(5,9) are collinear.

Step 1. Apply the formula to A(2,−3)A(2,-3) and B(6,5)B(6,5) with (x1,y1)=(2,−3)(x_1,y_1)=(2,-3) and (x2,y2)=(6,5)(x_2,y_2)=(6,5):

m=5−(−3)6−2=84=2.m = \frac{5-(-3)}{6-2} = \frac{8}{4} = 2.

Step 2. Sanity-check the sign: as xx increases from 22 to 66, yy increases from −3-3 to 55, so the line rises left to right — a positive slope of 22 is consistent with the picture.

Step 3. Now take the second, unrelated set of points A(1,1)A(1,1), B(3,5)B(3,5), C(5,9)C(5,9), and find the slope of ABAB: mAB=5−13−1=42=2m_{AB} = \dfrac{5-1}{3-1} = \dfrac{4}{2} = 2. Find the slope of BCBC: mBC=9−55−3=42=2m_{BC} = \dfrac{9-5}{5-3} = \dfrac{4}{2} = 2.

Step 4. Since mAB=mBC=2m_{AB} = m_{BC} = 2 and both were computed through the shared point BB, the three points lie on one straight line. As a cross-check, the slope of ACAC directly is mAC=9−15−1=84=2m_{AC} = \dfrac{9-1}{5-1} = \dfrac{8}{4} = 2, agreeing with both.

Final answer: the slope of ABAB is m=2\mathbf{m=2}, and A(1,1)A(1,1), B(3,5)B(3,5), C(5,9)C(5,9) are collinear because mAB=mBC=mAC=2m_{AB} = m_{BC} = m_{AC} = 2.

Competitive stretch

Find kk so that A(1,4)A(1,4), B(3,k)B(3,k), C(7,2)C(7,2) are collinear. Set mAB=mACm_{AB} = m_{AC}: k−43−1=2−47−1\dfrac{k-4}{3-1} = \dfrac{2-4}{7-1}, so k−42=−26=−13\dfrac{k-4}{2} = \dfrac{-2}{6} = -\dfrac{1}{3}, giving k−4=−23k-4 = -\dfrac{2}{3}, so k=103k = \dfrac{10}{3}. This kind of "find the unknown coordinate that keeps points collinear" question is a favourite in competitive papers precisely because it needs nothing beyond the slope formula, applied twice.

Common traps

  • Mixing up which coordinate goes on top: it is always y2−y1x2−x1\dfrac{y_2-y_1}{x_2-x_1}, change in yy over change in xx, never the reverse.
  • Subtracting in a criss-cross, mismatched order — for example computing y2−y1x1−x2\dfrac{y_2-y_1}{x_1-x_2} — which flips the sign of the slope and gives a wrong answer even though the arithmetic "looks" fine.
  • Forgetting to check x1≠x2x_1 \neq x_2 before dividing; if the two points share an x-coordinate the line is vertical and the slope is undefined, not zero.
  • In collinearity checks, comparing the wrong pair of slopes, or computing them with inconsistent point order, and getting a spurious mismatch that suggests three points are not collinear when they actually are.

Ask the tutor: want a quick set of coordinate-slope and collinearity practice problems, or a walk-through of how this formula feeds into the point-slope form of a line's equation?

Why is the slope of a vertical line undefined instead of just being infinity?

Because slope is defined as a ratio y2−y1x2−x1\dfrac{y_2-y_1}{x_2-x_1}, and division by zero simply has no numerical value in ordinary arithmetic — it is not that the answer is some very large number. A vertical line has no finite tan⁡θ\tan\theta either, since θ=90∘\theta = 90^\circ and tangent is undefined there. So "undefined" is the mathematically honest description, and it is a separate case you must check for before dividing, not a number you can compute and then interpret as infinite.

Do I always have to call one point 1 and the other point 2, and does it matter which is which?

No — you can label either point as (x1,y1)(x_1,y_1) and the other as (x2,y2)(x_2,y_2); the formula gives the same slope either way, because swapping the labels multiplies both the numerator and the denominator by −1-1, leaving the ratio unchanged. What you cannot do is swap only one of the two subtractions, for example using y2−y1y_2-y_1 on top but x1−x2x_1-x_2 on the bottom — that genuinely flips the sign and gives a wrong slope.

If three points give equal slopes for AB and BC, is that always enough to prove collinearity, or do I need to check AC too?

Equal slopes for ABAB and BCBC already prove collinearity, because both segments share the point BB and pass through it in the same direction — two lines through a common point with the same slope must be the same line. Checking ACAC as well is not logically necessary, but it is a quick, cheap arithmetic cross-check that catches labelling or calculation slips, which is why worked solutions often include it as a final verification step.

Before this

Where this leads