Straight Lines
2995 words
15 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Straight Lines ## ๐ฏ Learning Objectives By the end of this topic, you will be able to: 1. **Compute** the slope of a line given two points or an equation 2.

Straight Lines
๐ฏ Learning Objectives
By the end of this topic, you will be able to:
- Compute the slope of a line given two points or an equation
- Write the equation of a line in point-slope, slope-intercept, two-point, intercept, and general forms
- Determine whether two lines are parallel or perpendicular using slope conditions
- Compute the angle between two intersecting lines
- Calculate the distance from a point to a line, and between parallel lines
- Understand the line of best fit using the sum of squared errors (SSE)
๐ Prerequisites
- Coordinate Geometry โ points, distance formula
- Basic algebra โ solving linear equations, working with fractions
๐ Core Content
2.1 The Slope of a Line
2.1.1 Intuition: Steepness
If you're hiking up a mountain trail, some sections are steep and some are gentle. The slope of a line captures exactly this idea of steepness โ how much the line rises (or falls) for each unit you move horizontally.
A flat road has slope 0. A staircase might have slope 0.5 (rise 1 unit for every 2 units forward). A cliff is nearly vertical (slope approaches infinity).
๐ก Why this matters: Slope is the foundation of rate of change โ the core idea in calculus (derivatives). In data science, the slope of a regression line tells you how much the target variable changes per unit change in a feature.
2.1.2 Definition
The slope m of a line passing through points P1โ(x1โ,y1โ) and P2โ(x2โ,y2โ) is:
As inclination: If a line makes angle ฮธ with the positive x-axis:
Key facts:
- Horizontal line (ฮธ=0โ): m=tan0โ=0
- Vertical line (ฮธ=90โ): slope is undefined (tan90โ is undefined)
- Positive slope: line goes up as x increases (rising)
- Negative slope: line goes down as x increases (falling)
2.1.3 Worked Examples
Example 1.1 (Easy): Find the slope of the line through (1,2) and (4,8).
Step 1: m=4โ18โ2โ=36โ=2
Example 1.2 (Medium): Find the slope of the line through (โ3,5) and (2,โ7).
Step 1: m=2โ(โ3)โ7โ5โ=5โ12โ=โ2.4
Example 1.3 (Edge case): Find the slope of the line through (3,4) and (3,9).
Step 1: m=3โ39โ4โ=05โ, which is undefined.
2.2 Equations of a Straight Line
2.2.1 Intuition: Describing a Line
Just as a point is described by its coordinates, a line is described by an equation โ a condition that every point on the line satisfies. If (x,y) lies on the line y=2x+1, then plugging in gives y=2x+1.
There are several forms, each useful in different situations:
(Diagram)
2.2.2 Forms Summary
| Form | Equation | When to Use |
|---|---|---|
| Horizontal | y=a | Line parallel to x-axis |
| Vertical | x=a | Line parallel to y-axis |
| Point-slope | yโy1โ=m(xโx1โ) | Given a point (x1โ,y1โ) and slope m |
| Slope-intercept | y=mx+c | Given slope m and y-intercept c |
| Two-point | yโy1โ=x2โโx1โy2โโy1โโ(xโx1โ) | Given two points |
| Intercept | axโ+byโ=1 | Given x-intercept a and y-intercept b |
| General | Ax+By+C=0 | Standard form, all lines |
| X-intercept form | y=m(xโd) | Given x-intercept d and slope m |
2.2.3 Converting Between Forms
From general form Ax+By+C=0:
- Slope: m=โBAโ
- y-intercept: โBCโ
- x-intercept: โACโ Recipe for writing a line equation:
- Identify what information you have (point + slope? two points? intercepts?)
- Choose the corresponding form
- Substitute the known values
- Simplify to the required form
2.2.4 Worked Examples
Example 2.1 (Easy โ Point-Slope): Find the equation of the line through (2,3) with slope 4.
Step 1: Use point-slope: yโy1โ=m(xโx1โ)
Step 2: yโ3=4(xโ2)
Step 3: Simplify: yโ3=4xโ8โนy=4xโ5
Example 2.2 (Medium โ Two-Point): Find the equation of the line through (1,2) and (4,8).
Step 1: Find slope: m=4โ18โ2โ=2
Step 2: Use point-slope with (1,2): yโ2=2(xโ1)
Step 3: Simplify: yโ2=2xโ2โนy=2x
Example 2.3 (Medium โ Intercept): Find the equation of the line with x-intercept 3 and y-intercept 4.
Step 1: a=3, b=4: 3xโ+4yโ=1
Step 2: Multiply by 12: 4x+3y=12
Example 2.4 (Hard โ General Form): Convert 3xโ2y+6=0 to slope-intercept form and find its slope and intercepts.
Step 1 โ Slope-intercept: 3xโ2y+6=0โนโ2y=โ3xโ6โนy=23โx+3
Step 2 โ Slope: m=23โ
Step 3 โ y-intercept: c=3 (from y=23โx+3)
Step 4 โ x-intercept: Set y=0: 3x+6=0โนx=โ2
2.3 Parallel and Perpendicular Lines
2.3.1 Intuition
- Parallel lines run side by side, never meeting. They have the same steepness (equal slopes).
- Perpendicular lines meet at a right angle (90โ). Their slopes are negative reciprocals.
2.3.2 Conditions
For two non-vertical lines with slopes m1โ and m2โ:
| Condition | Formula | Example |
|---|---|---|
| Parallel | m1โ=m2โ | y=2x+1 , y=2xโ5 |
| Perpendicular | m1โโ m2โ=โ1 | y=2x+1 , y=โ21โx+3 |
For lines in general form A1โx+B1โy+C1โ=0 and A2โx+B2โy+C2โ=0:
- Parallel: A1โB2โ=A2โB1โ
- Perpendicular: A1โA2โ+B1โB2โ=0
2.3.3 Worked Examples
Example 3.1 (Easy): Are y=3x+2 and y=3xโ7 parallel?
Step 1: m1โ=3, m2โ=3
Step 2: Since m1โ=m2โ, the lines are parallel.
Example 3.2 (Medium): Find the equation of the line perpendicular to y=โ21โx+3 passing through (4,1).
Step 1: Slope of given line: m1โ=โ21โ
Step 2: Slope of perpendicular: m2โ=โm1โ1โ=โโ1/21โ=2
Step 3: Point-slope: yโ1=2(xโ4)
Step 4: Simplify: yโ1=2xโ8โนy=2xโ7
Example 3.3 (Hard): Are the lines 2x+3yโ6=0 and 4x+6y+12=0 parallel?
Step 1 โ Method 1 (Slopes):
Line 1: y=โ32โx+2โนm1โ=โ32โ
Line 2: y=โ64โxโ2=โ32โxโ2โนm2โ=โ32โ
m1โ=m2โ โ parallel.
Step 2 โ Method 2 (General form):
A1โ=2,B1โ=3, A2โ=4,B2โ=6
A1โB2โ=2ร6=12, A2โB1โ=4ร3=12
A1โB2โ=A2โB1โ โ parallel.
2.4 Angle Between Two Lines
2.4.1 Formula
The acute angle ฮธ between two lines with slopes m1โ and m2โ (m1โm2โ๎ =โ1) is:
The obtuse angle ฯ=180โโฮธ satisfies:
2.4.2 Worked Example
Find the acute angle between y=2x+3 and y=31โxโ1.
Step 1: m1โ=2, m2โ=31โ
Step 2: tanฮธ=1+2โ
31โ31โโ2โ=1+32โโ35โโ=35โโ35โโ=โ1
Step 3: ฮธ=arctan(โ1)=45โ (acute angle, take absolute value)
2.5 Distance Formulas
2.5.1 Distance from a Point to a Line
The perpendicular distance from point (x1โ,y1โ) to line Ax+By+C=0:
2.5.2 Distance Between Two Parallel Lines
For parallel lines Ax+By+C1โ=0 and Ax+By+C2โ=0:
2.5.3 Worked Examples
Example 5.1 (Easy): Distance from (1,2) to the line 3x+4yโ5=0.
Step 1: d=32+42โโฃ3(1)+4(2)โ5โฃโ=5โฃ3+8โ5โฃโ=5โฃ6โฃโ=56โ
Example 5.2 (Medium): Distance between parallel lines 2xโy+3=0 and 2xโyโ4=0.
Step 1: A=2, B=โ1, C1โ=3, C2โ=โ4
Step 2: d=22+(โ1)2โโฃ3โ(โ4)โฃโ=5โโฃ7โฃโ=5โ7โ
2.6 Line of Best Fit (Straight-Line Fit)
2.6.1 Intuition
In the real world, data points rarely lie exactly on a straight line. But often they roughly follow a linear trend. Linear regression finds the line that best approximates the data by minimizing the sum of squared errors (SSE).
2.6.2 Formula for Best-Fit Line y=mx+c
For n data points (xiโ,yiโ):
where xห and yหโ are the means of the x-values and y-values.
The sum of squared errors is:
2.6.3 Worked Example
Find the line of best fit for the points (1,2), (2,3), (3,5), (4,4).
| xiโ | yiโ | xiโโxห | yiโโyหโ | (xiโโxห)(yiโโyหโ) | (xiโโxห)2 |
|---|---|---|---|---|---|
| 1 | 2 | -1.5 | -1.5 | 2.25 | 2.25 |
| 2 | 3 | -0.5 | -0.5 | 0.25 | 0.25 |
| 3 | 5 | 0.5 | 1.5 | 0.75 | 0.25 |
| 4 | 4 | 1.5 | 0.5 | 0.75 | 2.25 |
xห=2.5, yหโ=3.5
โ(xiโโxห)(yiโโyหโ)=2.25+0.25+0.75+0.75=4
โ(xiโโxห)2=2.25+0.25+0.25+2.25=5
m=54โ=0.8, c=3.5โ0.8(2.5)=3.5โ2=1.5
๐ Key Formulas โ Summary Table
| Concept | Formula | Notes |
|---|---|---|
| Slope | m=x2โโx1โy2โโy1โโ=tanฮธ | Undefined for vertical lines |
| Point-slope | yโy1โ=m(xโx1โ) | Given slope + point |
| Slope-intercept | y=mx+c | c = y-intercept |
| Two-point | yโy1โ=x2โโx1โy2โโy1โโ(xโx1โ) | Given two points |
| Intercept | axโ+byโ=1 | a = x-int, b = y-int |
| General | Ax+By+C=0 | All lines |
| Parallel condition | m1โ=m2โ or A1โB2โ=A2โB1โ | |
| Perpendicular | m1โโ m2โ=โ1 or A1โA2โ+B1โB2โ=0 | |
| Angle between lines | tanฮธ=1+m1โm2โm2โโm1โโ | Acute angle |
| Point-to-line distance | $d = \frac{ | Ax_1 + By_1 + C |
| Parallel lines distance | $d = \frac{ | C_1 - C_2 |
| Best-fit slope | m=โ(xiโโxห)2โ(xiโโxห)(yiโโyหโ)โ | Linear regression |
| Best-fit intercept | c=yหโโmxห | |
| Sum of squared errors | SSE=โ(yiโโmxiโโc)2 | Minimized by best-fit |
โ ๏ธ Common Pitfalls
Pitfall 1: Confusing x-intercept with y-intercept
Mistake: Saying y=mx+c gives the x-intercept as c.
Correct: c is the y-intercept (the point (0,c)). The x-intercept is found by setting y=0: 0=mx+cโนx=โc/m.
Pitfall 2: Thinking Slope is the Same as the Angle
Mistake: If slope is 2, the angle is 2 radians or degrees.
Correct: Slope m=tanฮธ. So ฮธ=arctan(m). For m=2, ฮธโ63.4โ, not 2โ.
Pitfall 3: Forgetting the Vertical Line Has No Slope
Mistake: Saying a vertical line has slope 0 (confusing with horizontal).
Correct: Horizontal (y=a): slope 0. Vertical (x=a): slope undefined.
Pitfall 4: Using Wrong Ratio for Perpendicular Lines
Mistake: Using m2โ=โm1โ for perpendicular lines (that's for reflection across x-axis).
Correct: m1โโ
m2โ=โ1, so m2โ=โ1/m1โ. Example: if m1โ=2, then m2โ=โ1/2.
๐ Practice Questions
Q1: Find the slope of the line through (3,โ2) and (7,6).Strategy Hint: Use m=(y2โโy1โ)/(x2โโx1โ).m=7โ36โ(โ2)โ=48โ=2m=2โ Q2: Write the equation of the line with slope โ3 passing through (2,5).Strategy Hint: Use point-slope form.yโ5=โ3(xโ2)โนyโ5=โ3x+6โนy=โ3x+11y=โ3x+11โ Q3: Are y=โ32โx+4 and 3xโ2y+5=0 perpendicular?Strategy Hint: Find slopes and check m1โโ m2โ=โ1.Line 1: m1โ=โ32โ Line 2: y=23โx+25โโนm2โ=23โ m1โโ m2โ=โ32โโ 23โ=โ1 โYes,ย perpendicularโ Q4: Find the distance from (4,โ1) to 5xโ12y+3=0.Strategy Hint: Use the point-to-line distance formula.d=52+(โ12)2โโฃ5(4)โ12(โ1)+3โฃโ=13โฃ20+12+3โฃโ=1335โ1335โย unitsโ Q5: Find the equation of the line parallel to 3x+4y=12 passing through (0,0).Strategy Hint: Parallel lines have the same A and B (different C).Since lines are parallel, 3x+4y+C=0. Passes through (0,0): 3(0)+4(0)+C=0โนC=0.3x+4y=0โ Q6: Find the acute angle between y=x+1 and y=3โxโ2.Strategy Hint: Use tanฮธ=1+m1โm2โm2โโm1โโ.m1โ=1, m2โ=3โ tanฮธ=1+1โ 3โ3โโ1โ=1+3โ3โโ1โ=3โ1(3โโ1)2โ=24โ23โโ=2โ3โฮธ=arctan(2โ3โ)=15โ15โโ Q7: Write 2xโ5y+10=0 in intercept form.Strategy Hint: Get axโ+byโ=1.2xโ5y+10=0โน2xโ5y=โ10โนโ5xโ+2yโ=1โ5xโ+2yโ=1โ Q8: Find the line through (3,2) perpendicular to x=5.Strategy Hint: x=5 is vertical. Perpendicular to vertical is horizontal.x=5 is vertical. A perpendicular line is horizontal: y=k. Through (3,2): y=2.y=2โ Q9: Find the distance between 2xโ3y+7=0 and 4xโ6yโ5=0.Strategy Hint: First check parallel (they are), then make A, B same.Line 2: 4xโ6yโ5=0โน2xโ3yโ25โ=0 d=22+(โ3)2โโฃ7โ(โ5/2)โฃโ=13โโฃ7+2.5โฃโ=13โ9.5โ=213โ19โ213โ19โย unitsโ Q10: Find the line with x-intercept 2 and y-intercept โ3.Strategy Hint: Intercept form directly.2xโ+โ3yโ=1โน2xโโ3yโ=1โน3xโ2y=63xโ2y=6โ Q11: For points (0,1), (2,3), (4,5), find the best-fit line.Strategy Hint: Use the formulas for m and c.xห=2, yหโ=3 โ(xiโโxห)(yiโโyหโ)=(โ2)(โ2)+0(0)+2(2)=4+0+4=8 โ(xiโโxห)2=4+0+4=8 m=88โ=1, c=3โ1(2)=1y=x+1โ Q12: If a line passes through (2,5) and (โ1,2), write its equation and find its intercepts.Strategy Hint: Find slope, then use point-slope.m=โ1โ22โ5โ=โ3โ3โ=1 yโ5=1(xโ2)โนy=x+3 y-intercept: 3 (when x=0) x-intercept: โ3 (when y=0)y=x+3,ย y-int=3,ย x-int=โ3โ
๐ Cross-References
- Previous topic: Coordinate Geometry
- Next topic: Quadratic Functions โ non-linear curves
- Related: Derivatives โ slope of a curve = derivative
- Across courses: BSMA1002 Stats 1 (linear regression, correlation); BSMA1003 Maths 2 (linear algebra, vector spaces) Join Discord Previous2.1 Coordinate GeometryNext3.1 Quadratic Functions