ProMathTools
ProMathTools

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

Browse Category

All Math Calculators

Related Guides


How this calculator works

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 + b

Worked example

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 this tool

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.

Frequently asked questions

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.

Read the full guide →

About UsBlogChrome ExtensionFAQsTerms and ConditionsPrivacy PolicySitemap
EmailLinkedInFacebook

© 2025-2026 PromathTools. All rights reserved.

Built by KruskalCode – SaaS & Automation Experts · EverydayDevTools