terican

Last verified · v1.0

Calculator · math

Line Equation From Two Points Calculator

Find the equation of any straight line by entering two coordinate points. Returns slope, y-intercept, and the complete y = mx + b equation instantly.

FreeInstantNo signupOpen source

Inputs

Computed Value

Explain my result

0/3 free

Get a plain-English breakdown of your result with practical next steps.

Computed Value

The formula

How the
result is
computed.

How to Find the Equation of a Line From Two Points

Given any two distinct points on a coordinate plane, exactly one straight line passes through them. The line equation from two points calculator derives that line in slope-intercept form (y = mx + b) using three sequential steps grounded in algebraic geometry. Any two coordinate pairs — integers, decimals, or negatives — are sufficient to define the complete equation.

The Three Core Formulas

Three formulas work in sequence to produce the line equation from coordinates (x1, y1) and (x2, y2):

  • Slope: m = (y2 - y1) / (x2 - x1)
  • Y-intercept: b = y1 - m * x1
  • Line equation: y = mx + b

Step 1: Calculate the Slope (m)

The slope measures the rate of vertical change per unit of horizontal change between the two points. A positive slope means the line ascends from left to right; a negative slope means it descends. A slope of zero indicates a horizontal line. According to Portland Community College's slope resource, slope is defined as rise divided by run — the vertical difference divided by the horizontal difference between any two points on the line. The order of subtraction must remain consistent: if y2 appears in the numerator, x2 must appear in the denominator.

Step 2: Find the Y-Intercept (b)

With slope known, substitute either coordinate pair into b = y1 - m * x1 to isolate the y-intercept. The result is the y-value at which the line crosses the vertical axis (x = 0). Using either point produces an identical b because both points are collinear. In applied contexts, the y-intercept often represents a fixed baseline — a starting salary, an initial position, or a fixed cost — before the slope-driven rate of change takes effect.

Step 3: Write the Complete Equation

Insert m and b into y = mx + b to obtain the slope-intercept equation. As detailed in Richland College's Lines in the Plane lecture notes, slope-intercept form is the standard representation because both key parameters are immediately visible and any y-value can be computed by direct substitution of x.

Worked Example

Find the equation of the line through points (3, 7) and (9, 19).

  • Slope: m = (19 - 7) / (9 - 3) = 12 / 6 = 2
  • Y-intercept: b = 7 - 2 * 3 = 7 - 6 = 1
  • Equation: y = 2x + 1

Verification: substituting x = 9 gives y = 2(9) + 1 = 19, matching the second given point. The result is confirmed.

Special Cases

  • Vertical lines (x1 = x2): The denominator equals zero, making slope undefined. The line is written x = c, where c is the shared x-coordinate. Points (5, 2) and (5, 8) define x = 5.
  • Horizontal lines (y1 = y2): Slope equals zero and the equation simplifies to y = c, the shared y-coordinate.
  • Lines through the origin: When b = 0, the equation reduces to y = mx.

Real-World Applications

Determining a line equation from two points is a practical skill across many fields:

  • Physics: Deriving a constant-velocity equation from two position-time measurements — an object at 4 m at t = 1 s and at 10 m at t = 4 s yields v = 2t + 2.
  • Finance: Modeling straight-line depreciation from an asset's initial value and projected salvage value.
  • Engineering: Interpolating sensor output between two verified calibration readings to predict intermediate values.
  • Data science: Establishing a linear baseline between anchor observations before fitting a full regression model.

Alternative Equation Forms

The same line is expressible in point-slope form (y - y1 = m(x - x1)) or standard form (Ax + By = C). Point-slope form avoids computing b explicitly and is faster when a known point and slope are already available. Standard form is preferred for systems of linear equations. All three are mathematically equivalent representations of the same geometric object.

Methodology sources: Khan Academy — Slope-Intercept Equation from Two Points and BYU-Idaho — How to Find the Equation of a Line from Two Points.

Reference

Frequently asked questions

What is the formula for finding a line equation from two points?
The process uses three formulas in sequence. First, compute slope m = (y2 - y1) / (x2 - x1). Second, find the y-intercept b = y1 - m * x1. Third, substitute both values into y = mx + b. For example, points (1, 3) and (4, 9) yield m = (9-3)/(4-1) = 2, b = 3 - 2*1 = 1, producing the equation y = 2x + 1.
How do you calculate slope from two coordinate points?
Slope equals rise divided by run using the formula m = (y2 - y1) / (x2 - x1). Subtract the y-coordinates to get the vertical rise, subtract the x-coordinates to get the horizontal run, then divide. For points (-2, 4) and (3, 14): m = (14 - 4) / (3 - (-2)) = 10 / 5 = 2. A positive result means the line rises from left to right; a negative result means it falls.
What does the y-intercept mean in a line equation?
The y-intercept (b) is the y-coordinate where the line crosses the vertical axis — in other words, the value of y when x equals zero. In real-world models it often represents a fixed baseline such as a starting cost or initial measurement. For the equation y = 3x + 5, the y-intercept is 5, meaning the line passes through the point (0, 5) regardless of the slope's steepness.
What happens when both input points share the same x-coordinate?
When x1 equals x2, the denominator in the slope formula is zero, making slope undefined. This identifies a vertical line, which cannot be expressed in slope-intercept form. The correct equation format is x = c, where c is the shared x-value. For example, points (4, 1) and (4, 9) define the vertical line x = 4, not any y = mx + b expression.
Does the line equation calculator work with negative or decimal coordinates?
Yes. The slope and y-intercept formulas accept any real-number inputs, including negative values, fractions, and decimals. For example, points (-1.5, 2.5) and (3.5, 7.5) yield slope m = (7.5 - 2.5) / (3.5 - (-1.5)) = 5 / 5 = 1 and y-intercept b = 2.5 - 1 * (-1.5) = 4, giving the equation y = x + 4. Precision in results depends on the calculator's significant-figure handling.
How is slope-intercept form different from point-slope form?
Slope-intercept form (y = mx + b) displays both the slope and y-intercept explicitly, making it ideal for graphing, quick reading, and substitution. Point-slope form (y - y1 = m(x - x1)) uses a known point and slope directly without solving for b first. Both forms represent exactly the same line. Point-slope is faster to construct from raw coordinates; slope-intercept is more convenient for interpretation and downstream calculation.