Skip to main content
math

Line Equation from Two Points Calculator

Find the equation of the line passing through two given points in slope-intercept form.

Reviewed by Chase FloiedUpdated

This free online line equation from two points calculator provides instant results with no signup required. All calculations run directly in your browser — your data is never sent to a server. Enter your values below and see results update in real time as you type. Perfect for everyday calculations, homework, or professional use.

x coordinate of the first point

y coordinate of the first point

x coordinate of the second point

y coordinate of the second point

How to Use This Calculator

1

Enter your input values

Fill in all required input fields for the Line Equation from Two Points Calculator. Most fields include unit selectors so you can work in your preferred unit system — metric or imperial, whichever matches your problem.

2

Review your inputs

Double-check that all values are correct and that you have selected the right units for each field. Incorrect units are the most common source of calculation errors and can produce results that are off by factors of 2, 10, or more.

3

Read the results

The Line Equation from Two Points Calculator instantly computes the output and displays results with units clearly labeled. All calculations happen in your browser — no loading time and no data sent to a server.

4

Explore parameter sensitivity

Try adjusting individual input values to see how the output changes. This is a quick and effective way to develop intuition about how different parameters influence the result and to identify which inputs have the largest effect.

Formula Reference

Line Equation from Two Points Calculator Formula

See calculator inputs for the governing equation

Variables: All variables and their units are labeled in the calculator interface above. Input fields accept values in multiple unit systems — select your preferred unit from the dropdown next to each field.

When to Use This Calculator

  • Use the Line Equation from Two Points Calculator when you need a quick mathematical result without writing out all the steps manually, saving time on repetitive calculations.
  • Use it to verify hand calculations on tests or assignments and catch arithmetic mistakes.
  • Use it when teaching or explaining mathematical concepts to others, demonstrating how changing inputs affects the result.
  • Use it to explore the behavior of mathematical functions across a range of inputs.

About This Calculator

The Line Equation from Two Points Calculator is a free mathematical calculation tool for students, educators, and professionals who need quick, reliable results. Find the equation of the line passing through two given points in slope-intercept form. The underlying algorithms implement well-established mathematical formulas and numerical methods. Results are computed instantly in the browser. This tool is useful for learning, verification of hand calculations, and rapid exploration of mathematical relationships. All computation happens locally — no data is sent to a server.

About Line Equation from Two Points Calculator

Finding the equation of a line through two points is one of the most common tasks in coordinate geometry. Given any two distinct points, there is exactly one line passing through both. The process involves two steps: first computing the slope as the ratio of the vertical change to the horizontal change, then using one of the points to find the y-intercept. The result is the line equation in slope-intercept form y = mx + b. This fundamental skill is used in data analysis for fitting trend lines, in physics for modeling linear relationships, in economics for supply and demand curves, and in any field where two data points define a linear relationship. Linear interpolation — estimating values between known data points — uses this exact procedure. Surveyors determine elevations along a line of sight, engineers calculate pipe grades between two elevation benchmarks, and scientists establish calibration curves from two reference measurements, all using the line equation from two points. This calculator provides the slope, y-intercept, and x-intercept for the line through any two points.

The Math Behind It

The slope of the line through (x₁, y₁) and (x₂, y₂) is m = (y₂ - y₁)/(x₂ - x₁), which requires x₁ ≠ x₂. The y-intercept is then b = y₁ - mx₁, giving the equation y = mx + b. The x-intercept, where y = 0, is x = -b/m (when m ≠ 0). An alternative form is the two-point form: (y - y₁)/(y₂ - y₁) = (x - x₁)/(x₂ - x₁), which does not require computing slope and intercept separately. The general form Ax + By + C = 0 can also be written directly: (y₁ - y₂)x + (x₂ - x₁)y + (x₁y₂ - x₂y₁) = 0. The term x₁y₂ - x₂y₁ is the cross product of the position vectors and relates to the signed area of the triangle formed by the two points and the origin. This construction generalizes to higher dimensions: in 3D, a line through two points is parameterized as P(t) = (1-t)P₁ + tP₂, and its equation requires two equations (or one vector equation) rather than a single equation. The concept of linear interpolation uses the same parameterization: f(x) = f(x₁) + [f(x₂) - f(x₁)]·(x - x₁)/(x₂ - x₁).

Formula Reference

Slope

m = (y₂ - y₁) / (x₂ - x₁)

Variables: (x₁, y₁) and (x₂, y₂) are the two points

Slope-Intercept Form

y = mx + b, where b = y₁ - mx₁

Variables: m = slope; b = y-intercept

Worked Examples

Example 1: Line through (1, 2) and (4, 8)

Find the equation of the line through (1, 2) and (4, 8).

Step 1:Slope m = (8 - 2)/(4 - 1) = 6/3 = 2
Step 2:b = 2 - 2(1) = 0
Step 3:Equation: y = 2x
Step 4:x-intercept = -0/2 = 0

The line is y = 2x, passing through the origin.

Example 2: Line through (-2, 5) and (3, -5)

Find the equation of the line through (-2, 5) and (3, -5).

Step 1:Slope m = (-5 - 5)/(3 - (-2)) = -10/5 = -2
Step 2:b = 5 - (-2)(-2) = 5 - 4 = 1
Step 3:Equation: y = -2x + 1
Step 4:x-intercept = -1/(-2) = 0.5

The line is y = -2x + 1, with x-intercept at 0.5.

Common Mistakes & Tips

  • !Getting zero in the denominator when x₁ = x₂ — this means the line is vertical and cannot be expressed as y = mx + b.
  • !Inconsistent subtraction order — use (y₂ - y₁)/(x₂ - x₁), not mixing orders like (y₁ - y₂)/(x₂ - x₁).
  • !Arithmetic errors when computing the y-intercept from b = y₁ - mx₁, especially with negative values.
  • !Assuming two points always define a non-trivial line — if both points are identical, infinitely many lines pass through them.

Related Concepts

Used in These Calculators

Calculators that build on or apply the concepts from this page:

Frequently Asked Questions

What if the two points have the same x-coordinate?

If x₁ = x₂, the line is vertical and the slope is undefined. The equation is x = x₁ (or x = x₂). This cannot be written in slope-intercept form.

Does the order of the two points matter?

No. Swapping the points changes the sign of both the numerator and denominator, so the slope remains the same, and the y-intercept is unchanged.

How do I extend this to three or more points?

If three or more points must lie on a single line, they must all be collinear (have the same slope between consecutive pairs). For approximate fitting, use linear regression (least squares).