Equation of a Line From Two Points: Slope-Intercept Form and Real-World Cost Models

October 29, 2026

A straight line can be written in slope-intercept form, y = mx + b, where m is the slope (the change in y per unit change in x) and b is the y-intercept (the value of y when x = 0). Given two points, you can find the line in three steps: compute the slope, solve for the intercept, and write the equation.

Take the points (2, 5) and (6, 13). The slope is m = (13 − 5) ÷ (6 − 2) = 8 ÷ 4 = 2. Substitute one point to find b: 5 = 2 × 2 + b, so b = 1. The line is y = 2x + 1. Check with the second point: 2 × 6 + 1 = 13.

Skip the math and get your answer instantly:

Open the Scientific Calculator →

Point-Slope Form

An alternative is point-slope form: y − y₁ = m(x − x₁). With m = 2 and the point (2, 5): y − 5 = 2(x − 2), which simplifies to y = 2x + 1. This form is convenient when you know the slope and one point. Standard form, Ax + By = C, is useful for finding intercepts: 2x − y = −1. Vertical lines (x = constant) have an undefined slope, and horizontal lines (y = constant) have zero slope. Parallel lines have equal slopes, and perpendicular lines have slopes that are negative reciprocals: a line perpendicular to slope 2 has slope −1/2.

Real-World Example: Taxi Fare

A taxi charges a flat fee plus a per-mile rate. A 2-mile ride costs $9.50 and a 10-mile ride costs $25.50. The points are (2, 9.5) and (10, 25.5). Slope = (25.5 − 9.5) ÷ (10 − 2) = 16 ÷ 8 = $2 per mile. Intercept: 9.5 = 2 × 2 + b, so b = $5.50. The model is cost = 2 × miles + 5.50. A 6-mile ride costs 2 × 6 + 5.5 = $17.50. The slope is the rate per mile and the intercept is the base fare. The model is only valid within the range of the data, and real fares may include minimums, tolls, and time charges.

ContextVariablesSlope mIntercept b
Taxi farecost vs. miles$2.00 per mile$5.50 base fare
Gym membershiptotal cost vs. months$40 per month$75 joining fee
Phone planbill vs. gigabytes$10 per GB$30 base
Car valuevalue vs. years-$2,400 per year$24,000 initial value
Temperature°F vs. °C1.832

Linear Depreciation and Break-Even

A machine worth $24,000 that loses $2,400 a year follows V = 24,000 − 2,400t. After 5 years, V = $12,000, and it reaches zero after 10 years. Comparing two linear plans finds the break-even by setting the equations equal: Plan A costs 30 + 10g and Plan B costs 55 + 5g; they are equal when 30 + 10g = 55 + 5g, so g = 5 gigabytes. For more than 5 GB, Plan B is cheaper. The intersection of two lines is the solution of the system of equations.

Fitting Lines to Data

When data are not perfectly linear, regression finds the best-fit line. The two-point method gives a line through exactly two points, which is fine when data are exact. Check the reasonableness of the slope and intercept in the context: a negative intercept for a fare would be impossible. Plot the points to see whether a line is appropriate. If the relationship curves, a linear model will mislead beyond the data range.

Frequently Asked Questions

How do I find the slope from two points?

Divide the change in y by the change in x.

What does the y-intercept mean?

The value of y when x is zero, often a fixed or starting amount.

What is point-slope form?

y − y₁ = m(x − x₁), used with a known slope and a point.

How do I find where two lines intersect?

Set the equations equal and solve for x.

What is the slope of a line perpendicular to slope 2?

−1/2.