Find the equation of a line given two points on it.
Last updated: April 2026 | By Patchworkr Team
A line equation in its slope-intercept form (y = mx + b) expresses the mathematical relationship between x and y coordinates for all points on that line. The slope m represents the steepness or rate of change, indicating how much y increases (or decreases) for each unit increase in x. The y-intercept b is the point where the line crosses the y-axis, occurring when x = 0. This form is fundamental to linear algebra, analytic geometry, and countless practical applications. Given any two distinct points on a line, you can uniquely determine both the slope and y-intercept, completely defining the line's behavior. Line equations are essential in graphing, solving systems of equations, and modeling linear relationships in science and engineering.
Linear equations appear ubiquitously in real-world modeling: physicists use them to describe motion and force relationships, economists use them to model supply and demand, engineers apply them to structural analysis and electrical circuits, and data scientists employ linear regression for prediction. The two-point method for finding line equations is computationally efficient and always yields a unique solution when the two points are distinct. Understanding slope is particularly important—positive slopes indicate increasing relationships, negative slopes indicate inverse relationships, zero slope represents horizontal lines, and undefined slope (vertical lines) occurs when the two points share the same x-coordinate. Mastering line equations provides intuition for more complex nonlinear relationships and is foundational to calculus, where derivatives measure instantaneous slopes of curves.
Gather your two points (x₁, y₁) and (x₂, y₂). Ensure they are distinct (not the same point) and ideally separated on the coordinate plane for numerical stability.
Why: Two distinct points uniquely define a line. If points are too close together numerically, rounding errors can distort slope calculations.
Apply the slope formula: m = (y₂ − y₁) / (x₂ − x₁). Subtract the y-coordinates and divide by the difference of x-coordinates. This gives the rate of change of the line.
Why: Slope measures steepness and direction. A positive slope means the line rises left to right; negative means it falls. The magnitude tells you how steep the line is.
Using point-slope form, calculate b = y₁ − m × x₁. Substitute either point and the calculated slope to solve for the y-intercept. This is where the line crosses the y-axis (when x = 0).
Why: The y-intercept is crucial for graphing and interpretation. It represents the line's vertical position and is required for slope-intercept form.
Combine slope and intercept into slope-intercept form: y = mx + b. This is the standard form for expressing the line mathematically. This equation describes every point on the line.
Why: Slope-intercept form is the most intuitive representation. It directly reveals both key properties (slope and position) and is ideal for graphing and analysis.
Substitute both original points into your equation to verify they satisfy y = mx + b. Both points should produce true statements (e.g., 2 = 3(1) − 1 = 2 ✓).
Why: Verification catches algebraic errors before you apply the equation. This simple check saves time and ensures confidence in your result.
Finding a Line Through Two Physics Experiment Points
Where v = speed (m/s) and t = time (seconds). Every second the object falls, its speed increases by 3 m/s, starting from −1 m/s at t = 0.
Line goes down from left to right. The slope value is negative, indicating an inverse relationship between x and y.
Yes, when b = 0, the line passes through the origin (0,0). Equation becomes y = mx.
Horizontal line. Equation: y = b (constant). No change in y regardless of x value.
Substitute both original points into your equation. Both should satisfy it: y = mx + b should be true.
Yes, for vertical lines where x₁ = x₂. Division by zero occurs; equation is x = constant instead.
Alternative form: y − y₁ = m(x − x₁). Useful when you know one point and the slope.
Predicting trends (sales growth), linear regression, physics equations (motion), economics (supply/demand).
Only one straight line passes through two distinct points. For curves, you need more points or a parametric equation.
Minimize by using well-separated points and maintaining precision in intermediate calculations.
Rearrange: x = (y − b) / m. This is the inverse relationship; input y to find corresponding x.
Related Tools
Calculate gradient.
Calculate line intersection.
Calculate regression line.
Calculate plane intersection.
Calculate parallel lines.
Calculate perpendicular lines.