Equation of a Line from Two Points

This calculator helps you determine the equation of a straight line in the slope-intercept form (y = mx + b) when you are given any two distinct points that lie on the line. It automatically computes the slope (m) and the y-intercept (b) for you.

Enter the x-coordinate of the first point.

Enter the y-coordinate of the first point.

Enter the x-coordinate of the second point.

Enter the y-coordinate of the second point.

How it works

This calculator helps you determine the equation of a straight line in the slope-intercept form (y = mx + b) when you are given any two distinct points that lie on the line. It automatically computes the slope (m) and the y-intercept (b) for you.


The Formula
Slope (m) = (y₂ - y₁) / (x₂ - x₁)
Y-intercept (b) = y₁ - m * x₁
Equation: y = mx + b

Worked Example
  1. Example: Line through (2, 3) and (5, 9)

    Given two points (x₁, y₁) = (2, 3) and (x₂, y₂) = (5, 9): 1. Calculate the slope (m): m = (9 - 3) / (5 - 2) = 6 / 3 = 2. 2. Calculate the y-intercept (b) using (2, 3): b = 3 - 2 * 2 = 3 - 4 = -1. 3. The equation of the line is y = 2x - 1.


Tips, Assumptions & Limitations
  • Ensure your two points are distinct; if they are the same, an error will occur.
  • For vertical lines (x₁ = x₂), the slope is undefined, and the equation will be in the form x = C.
  • For horizontal lines (y₁ = y₂), the slope is 0, and the equation will be in the form y = C.
FAQ

The equation of a line is a mathematical expression that describes all the points lying on that line. The most common form is the slope-intercept form, y = mx + b, where 'm' is the slope and 'b' is the y-intercept.

The slope (m) is calculated as the change in y divided by the change in x between two points (x₁, y₁) and (x₂, y₂). The formula is m = (y₂ - y₁) / (x₂ - x₁).

The y-intercept (b) is the point where the line crosses the y-axis. It is the value of y when x is 0. Once you have the slope, you can find 'b' using one of the points: b = y₁ - m * x₁.

Yes, this calculator can handle both vertical and horizontal lines. For vertical lines (where x₁ = x₂), the slope is undefined, and the equation will be in the form x = C. For horizontal lines (where y₁ = y₂), the slope is 0, and the equation will be in the form y = C.

Companion article

Equation of a Line from Two Points: A Step-by-Step Guide

Related Calculators
About UsFAQsTerms and ConditionsPrivacy PolicySitemap
EmailLinkedInFacebook

© 2026 PromathTools. All rights reserved.

Built by KruskalCode – SaaS & Automation Experts