Sub topic 8
Horizontal and Vertical Distances
Prerequisites and the basic idea
This chapter assumes you can read ordered pairs, use positive and negative numbers, and subtract integers. You should also know that the first coordinate is \(x\), the horizontal position, and the second coordinate is \(y\), the vertical position.
On a coordinate plane, a horizontal distance measures how far left or right two points are. A vertical distance measures how far up or down they are. These distances do not depend on the direction of travel, so they are always nonnegative.
For two numbers \(a\) and \(b\), the absolute difference is written \(\lvert a-b\rvert\). It gives the distance between the numbers on a number line.
Finding horizontal distance
Two points have a horizontal separation when they have the same \(y\)-coordinate. Their \(x\)-coordinates may differ.
For points \(A=(x1,y)\) and \(B=(x2,y)\), use:
\[ \text{horizontal distance}=\lvert x2-x1\rvert \]
Example: Let \(A=(-3,4)\) and \(B=(5,4)\). Both points have \(y=4\), so the segment between them is horizontal.
\[ \lvert 5-(-3)\rvert=\lvert 8\rvert=8 \]
The points are 8 units apart horizontally.
The subtraction order does not matter after taking the absolute value:
\[ \lvert 5-(-3)\rvert=\lvert -3-5\rvert=8 \]
Finding vertical distance
Two points have a vertical separation when they have the same \(x\)-coordinate. Their \(y\)-coordinates may differ.
For points \(C=(x,y1)\) and \(D=(x,y2)\), use:
\[ \text{vertical distance}=\lvert y2-y1\rvert \]
Example: Let \(C=(2,-1)\) and \(D=(2,6)\). Both points have \(x=2\), so the segment is vertical.
\[ \lvert 6-(-1)\rvert=\lvert 7\rvert=7 \]
The points are 7 units apart vertically.
| Segment | Coordinates | Matching coordinate | Distance |
|---|---|---|---|
| Horizontal | \((-3,4)\), \((5,4)\) | \(y=4\) | \(\lvert 5-(-3)\rvert=8\) |
| Vertical | \((2,-1)\), \((2,6)\) | \(x=2\) | \(\lvert 6-(-1)\rvert=7\) |
A coordinate-plane view
The following diagram shows why matching coordinates identify the direction of a segment.
Using a table or a program
A table can organize coordinates before you calculate. For a horizontal segment, place the two \(x\)-values in the subtraction. For a vertical segment, place the two \(y\)-values in the subtraction.
Python's abs function returns an absolute value:
def horizontal_distance(point_a, point_b):
x1, y1 = point_a
x2, y2 = point_b
if y1 != y2:
raise ValueError("The points must have the same y-coordinate.")
return abs(x2 - x1)
def vertical_distance(point_a, point_b):
x1, y1 = point_a
x2, y2 = point_b
if x1 != x2:
raise ValueError("The points must have the same x-coordinate.")
return abs(y2 - y1)
print(horizontal_distance((-3, 4), (5, 4)))
print(vertical_distance((2, -1), (2, 6)))The output is:
8
7If neither coordinate matches, the segment is slanted. It has a horizontal change and a vertical change, but neither one alone is the full distance between the points. The distance formula is needed for that case.
Common errors
- Subtracting the \(y\)-coordinates for a horizontal segment.
- Forgetting the absolute value when the second coordinate is smaller.
- Calling a segment horizontal or vertical without checking its matching coordinate.
- Confusing a coordinate's value with a distance. For example, the point \((-4,2)\) is not 4 units from the y-axis because its horizontal distance from that axis is \(\lvert -4\rvert=4\).
Exercise
Find the horizontal distance between \(P=(-7,3)\) and \(Q=(4,3)\), and the vertical distance between \(R=(-2,-5)\) and \(S=(-2,1)\).
Show answer
The horizontal distance is \(\lvert 4-(-7)\rvert=11\) units. The vertical distance is \(\lvert 1-(-5)\rvert=6\) units.