Equation of a Line from Two Points: A Step-by-Step Guide
ByMuhammad Ali•Founder of KruskalCode
21:01
6 min read

Understanding how to find the equation of a line is a fundamental skill in algebra and geometry. Whether you're tackling homework, preparing for an exam, or just curious, this guide will walk you through the process of deriving a line's equation when you know two points it passes through. We'll focus on the popular slope-intercept form: y = mx + b.
Explanation
A straight line can be uniquely defined by any two distinct points it passes through. The process involves two main steps: first, calculating the slope (m) of the line, and second, determining the y-intercept (b). The slope tells us the steepness and direction of the line, while the y-intercept tells us where the line crosses the vertical (y) axis. Once these two values are found, they can be plugged into the slope-intercept form to complete the equation.
Formula
To find the equation of a line from two points (x₁, y₁) and (x₂, y₂):
1. **Calculate the Slope (m):**
m = (y₂ - y₁) / (x₂ - x₁)
2. **Calculate the Y-intercept (b):**
Using one of the points (e.g., x₁, y₁) and the calculated slope (m):
b = y₁ - m * x₁
3. **Form the Equation:**
Substitute 'm' and 'b' into the slope-intercept form:
y = mx + bExample
Let's find the equation of the line that passes through the points (1, 4) and (3, 10). 1. **Calculate Slope (m):** x₁ = 1, y₁ = 4 x₂ = 3, y₂ = 10 m = (10 - 4) / (3 - 1) = 6 / 2 = 3 2. **Calculate Y-intercept (b):** Using point (1, 4) and m = 3: b = 4 - 3 * 1 = 4 - 3 = 1 3. **Form the Equation:** y = 3x + 1 So, the equation of the line passing through (1, 4) and (3, 10) is y = 3x + 1.
How to use the related calculator
To use the Equation of a Line from Two Points Calculator, simply enter the x and y coordinates for your first point (x₁, y₁) and your second point (x₂, y₂) into the respective input fields. The tool will instantly calculate the slope, y-intercept, and the final equation of the line. Ensure your points are distinct; if you enter the same point twice, the calculator will prompt an error.
Try the related calculator
Open toolFAQ
What happens if the two points have the same x-coordinate?
If the two points have the same x-coordinate (x₁ = x₂), the line is vertical. In this case, the slope is undefined, and the equation of the line will be in the form x = C, where C is the common x-coordinate.
What if the two points have the same y-coordinate?
If the two points have the same y-coordinate (y₁ = y₂), the line is horizontal. The slope will be 0, and the equation of the line will be in the form y = C, where C is the common y-coordinate.
Can I use this for any two points?
Yes, as long as the two points are distinct (not the exact same point), this method and calculator can be used to find the equation of the straight line passing through them.
Related articles

About the author
Muhammad Ali. Muhammad Ali is a full-stack developer and founder of KruskalCode. He builds SaaS platforms and automation systems with React and Laravel, and helps teams ship fast, scalable tools.
Need a custom calculator, dashboard, or automation workflow? Reach out to KruskalCode.