Line Equation from Two Points Calculator
Enter two coordinate points to find the slope, y-intercept, and line equation in slope-intercept, point-slope, and standard forms.
Enter the coordinates of two points (x₁, y₁) and (x₂, y₂), then click Calculate Equation.
Line Equation from Two Points Calculator
Enter two coordinate points to find the slope, y-intercept, and line equation in slope-intercept, point-slope, and standard forms.
Point 1 (x₁, y₁)
Point 2 (x₂, y₂)
About the Line Equation Calculator
A straight line in the Cartesian plane is completely determined by any two distinct points on it. Given points (x₁, y₁) and (x₂, y₂), this calculator computes the line's equation in three standard forms and provides the slope, y-intercept, and the distance between the two input points.
The slope m of a line is the ratio of the vertical change to the horizontal change between any two points on the line: m = (y₂ − y₁) / (x₂ − x₁). The slope tells you how steeply the line rises or falls. A positive slope means the line rises from left to right; a negative slope means it falls. A slope of zero gives a horizontal line; an undefined slope (division by zero, when x₁ = x₂) gives a vertical line.
The slope-intercept form y = mx + b is the most commonly used representation. It expresses y as a linear function of x, where m is the slope and b is the y-intercept — the value of y when x = 0. To find b, substitute one of the known points and the computed slope: b = y₁ − m · x₁.
The point-slope form y − y₁ = m(x − x₁) is convenient when you know the slope and one point but do not need to find the y-intercept explicitly. It is often the form encountered in differential equations and tangent-line problems in calculus.
The standard form Ax + By = C is preferred in many algebraic contexts and for systems of linear equations. In this form, A, B, and C are integers with A ≥ 0 and GCD(|A|, |B|, |C|) = 1. Converting from slope-intercept form: multiply through by the denominator of m if m is fractional, then rearrange to move x and y to the left side.
The Euclidean distance between the two input points is computed as √[(x₂ − x₁)² + (y₂ − y₁)²], which follows directly from the Pythagorean theorem applied to the right triangle formed by the two points and their horizontal and vertical legs.
Special cases: a horizontal line (y₁ = y₂) has slope 0 and equation y = y₁. A vertical line (x₁ = x₂) has undefined slope and equation x = x₁ — it cannot be written in slope-intercept form. This calculator handles both cases and clearly labels the result.
This tool is useful for analytic geometry, linear algebra, physics (projectile paths, kinematics), machine learning (drawing decision boundaries), data analysis (trend lines), and everyday tasks like map navigation, carpentry angles, and road gradients.
Line Equation Examples
Four scenarios covering the standard case, horizontal line, vertical line, and coordinates with decimals and negatives.
| Points | Equation | Notes |
|---|---|---|
| (1, 2) and (3, 6) | y = 2x | Slope m = 2, y-intercept b = 0. Standard case with positive slope. |
| (2, 4) and (5, 4) | y = 4 | Horizontal line — y-coordinates are equal, so slope = 0. |
| (3, 1) and (3, 5) | x = 3 | Vertical line — x-coordinates are equal, slope is undefined. |
| (−1, −2.5) and (4, 7.5) | y = 2x − 0.5 | Handles negative and decimal coordinates. Slope m = 2, b = −0.5. |
How to Use the Line Equation Calculator
- Enter the x and y coordinates for Point 1 (x₁, y₁) in the first pair of input fields.
- Enter the x and y coordinates for Point 2 (x₂, y₂) in the second pair of input fields.
- Click Calculate Equation. The calculator computes the slope, y-intercept, and all three equation forms.
- Read the results: slope-intercept form (y = mx + b), point-slope form, standard form, and the distance between the two points.
- Click Reset Fields to clear all inputs and start a new calculation.
Line Equation Calculator FAQ
What is the slope-intercept form of a line?
Slope-intercept form is y = mx + b, where m is the slope (rise over run) and b is the y-intercept (where the line crosses the y-axis). It is the most common way to express a linear equation because you can immediately read off both the slope and the y-intercept.
What does it mean if the slope is undefined?
An undefined slope occurs when the two points have the same x-coordinate, making the denominator (x₂ − x₁) equal to zero. The line is vertical — it runs straight up and down. A vertical line cannot be written as y = mx + b; instead its equation is simply x = c for some constant c.
How do I convert to standard form Ax + By = C?
Start from y = mx + b. Subtract mx from both sides to get −mx + y = b, then multiply through by −1 (or the denominator of m if m is a fraction) to make the coefficient of x positive. Simplify so that A, B, C share no common factor. For example, y = (2/3)x + 1 becomes 3y = 2x + 3, then 2x − 3y = −3.
What is the distance formula?
The distance between (x₁, y₁) and (x₂, y₂) is √[(x₂ − x₁)² + (y₂ − y₁)²]. It is derived from the Pythagorean theorem: the horizontal leg has length |x₂ − x₁|, the vertical leg |y₂ − y₁|, and the hypotenuse is the straight-line distance between the two points.
Can I find the midpoint from this calculator?
The midpoint is not displayed in this calculator, but you can compute it easily: midpoint = ((x₁ + x₂) / 2, (y₁ + y₂) / 2). The midpoint lies exactly halfway between the two input points on the line.
How do I find the equation of a parallel or perpendicular line?
Parallel lines have the same slope m. To find a parallel line through a new point (a, b), use point-slope form: y − b = m(x − a). Perpendicular lines have slopes that are negative reciprocals: if the original slope is m, the perpendicular slope is −1/m. Substitute the perpendicular slope and the new point into point-slope form to get the equation.
Related tools
Scatter Plot Calculator - Correlation & Linear Regression
Scatter plot calculator for linear regression and Pearson correlation. Enter X and Y data to get slope, intercept, r, and R² — free regression analysis.
Queueing Theory Calculator - M/M/c Queue Analysis
Queueing theory calculator for M/M/1, M/M/c, M/M/c/K, and M/M/c/N models. Compute utilization, queue length, wait times, and system probabilities instantly.
3D Distance Calculator - Two Points in 3D Space
Calculate the Euclidean distance between two points in 3D space using the 3D distance formula. Handles negative coordinates. Free, fast, and accurate.
Perfect Square Calculator - Find Square Roots Instantly
Perfect square calculator to check if any non-negative integer is a perfect square, find its integer square root, or show the nearest perfect squares.
Partial Products Calculator - Step-by-Step Multiplication
Partial products calculator breaks multiplication into place value steps. Great for learning multi-digit arithmetic visually with instant results.
Double Angle Formula Calculator - sin cos tan 2x
Double angle formula calculator for sin(2x), cos(2x), and tan(2x) in degrees or radians. Instant trig identity results for students and engineers.
Scientific Notation Calculator - Convert to Standard Form
Scientific notation calculator to convert numbers to standard form or expand scientific notation to decimals. Handles large and small numbers instantly.
Condition Number Calculator - Matrix Stability
Compute the condition number of 2x2 or 3x3 matrices in the 1-norm, infinity-norm, or Frobenius norm. Diagnose numerical stability instantly.