AI Tools Free

Line Equation Calculator

Enter two Cartesian points (x1, y1) and (x2, y2) into this line equation calculator and equation of a line calculator to compute the exact slope-intercept equation y = mx + b or vertical line x = c in one click. Test the preloaded (0, 0) and (3, 4) baseline returning y = 1.33333333333x + 0, or solve negative slopes, horizontal constants, and vertical axes across -1,000,000,000 to 1,000,000,000 in your browser.

Free to useNo sign-upRuns in your browser
Enter your details

Enter the inputs, then select Calculate result.

Your result
Enter your details

Result will appear here

How This Line Equation from Two Points Calculator Works

The Line Equation Calculator is a client-side coordinate geometry tool that determines the unique straight line passing through two distinct 2D points (x1, y1) and (x2, y2). It calculates rise-over-run slope m = (y2 - y1) / (x2 - x1) and y-intercept b = y1 - m * x1 in double-precision JavaScript, formatting y = mx + b or vertical x = x1 to up to 12 significant digits.

m = (y2 - y1) / (x2 - x1), b = y1 - m * x1 => y = mx + b (or x = x1 when x2 - x1 = 0).

Understanding how to calculate the equation of a line from two distinct points (x1, y1) and (x2, y2) relies on horizontal run dx = x2 - x1 and vertical rise dy = y2 - y1. When dx = 0 and dy != 0, this line equation from two points calculator and equation of a line formula calculator outputs x = x1; otherwise it formats y = mx + b to up to 12 significant digits.

Cartesian coordinate graph showing points (x1, y1) and (x2, y2), rise dy, run dx, slope m = dy/dx, and y-intercept b.
From two points (x1, y1) and (x2, y2), slope m = (y2 - y1) / (x2 - x1) and y-intercept b = y1 - m*x1 define y = mx + b.

Line Equation Calculator Quick Reference Table

Use these 10 verified coordinate pairs to see how the line equation calculator handles positive slopes, negative intercepts, horizontal lines, vertical lines, and identical-point validation before entering your own coordinates.

First Point (x1, y1)Second Point (x2, y2)Slope (m = dy / dx)Y-Intercept (b = y1 - m*x1)Exact Calculator Output (#result-main)
(0, 0) [preloaded](3, 4) [preloaded]4 / 3 ≈ 1.333333333330y = 1.33333333333x + 0
(1, 2)(3, 6)4 / 2 = 22 - 2(1) = 0y = 2x + 0
(2, 1)(4, 5)4 / 2 = 21 - 2(2) = -3y = 2x - 3
(-2, 7)(2, -1)-8 / 4 = -27 - (-2)(-2) = 3y = -2x + 3
(0, -4)(8, 0)4 / 8 = 0.5-4y = 0.5x - 4
(-3, 5)(4, 5)0 / 7 = 05y = 0x + 5 (horizontal line)
(3, 0)(3, 4)Undefined (dx = 0)None (parallel to y-axis)x = 3 (vertical line)
(-6, -2)(-6, 9)Undefined (dx = 0)None (parallel to y-axis)x = -6 (vertical line)
(1.5, 2.25)(4.5, 6.75)4.5 / 3 = 1.52.25 - 1.5(1.5) = 0y = 1.5x + 0
(2, 2)(2, 2)dx = 0, dy = 0IndeterminateError: Choose two distinct points.

Step-by-Step Guide to Using the Line Equation Calculator

Follow these three steps in the workspace above to enter your two Cartesian coordinate pairs and export the resulting line equation.

Enter First Point Coordinates (#x1, #y1)

Type the horizontal and vertical coordinates of your starting point into First x coordinate (#x1, default 0) and First y coordinate (#y1, default 0).

Input and settings
Input fields for First x coordinate and First y coordinate preloaded with 0 and 0 in the Line Equation Calculator.
Step 1: Enter the first point (x1, y1), preloaded at the origin (0, 0).

Enter Second Point Coordinates (#x2, #y2)

Supply a distinct second point in Second x coordinate (#x2, default 3) and Second y coordinate (#y2, default 4) within -1,000,000,000 to 1,000,000,000.

Tool result
Input fields for Second x coordinate set to 3 and Second y coordinate set to 4 in the Line Equation Calculator.
Step 2: Enter a distinct second point (x2, y2), preloaded as (3, 4).

Click Calculate Result and Save

Select Calculate result to generate the equation in #result-main, then use Copy result or Download .txt to save the formula for algebra homework or plots.

Review the details
Result panel displaying y = 1.33333333333x + 0 with Copy result and Download .txt buttons.
Step 3: Review the calculated equation y = 1.33333333333x + 0 and copy or download the output.

Worked Examples: How to Calculate the Equation of a Line

These three worked examples show how to calculate the equation of a line across origin-passing slopes, negative y-intercepts, and vertical or horizontal lines.

Preloaded Baseline: (0, 0) to (3, 4)

With (0, 0) and (3, 4), the rise is dy = 4 and the run is dx = 3, giving slope m = 4/3 ≈ 1.33333333333 and y-intercept b = 0, which outputs y = 1.33333333333x + 0.

Line passing through the origin (0, 0) and (3, 4) with slope m = 4/3 and y-intercept 0.
Baseline check: (0, 0) to (3, 4) yields slope 4/3 (1.33333333333) and y-intercept 0.

Negative Y-Intercept Case: (2, 1) to (4, 5)

Between (2, 1) and (4, 5), the slope is m = (5 - 1) / (4 - 2) = 2 and the intercept is b = 1 - 2(2) = -3, so the calculator formats the negative sign cleanly as y = 2x - 3.

Line through (2, 1) and (4, 5) crossing the vertical axis at y-intercept (0, -3).
Negative intercept check: (2, 1) and (4, 5) have slope m = 2 and cross the y-axis at b = -3 (y = 2x - 3).

Vertical Line Case: (3, 0) to (3, 4)

When x1 = x2 = 3 and y1 = 0, y2 = 4, the run is dx = 0 and the tool outputs x = 3. For equal y-coordinates such as (-3, 5) and (4, 5), it returns y = 0x + 5.

Comparison of vertical line x = 3 through (3, 0) and (3, 4) versus horizontal line y = 0x + 5.
Vertical and horizontal cases: dx = 0 outputs x = 3, while dy = 0 outputs y = 0x + 5.

How to Read and Verify the Equation of a Line Calculator Output

The output panel prints either a slope-intercept string (y = mx + b or y = mx - |b|) or a vertical line equation (x = c).

Every non-vertical equation gives you immediate geometric readouts: the coefficient of x is the slope m (how many units y changes for each 1-unit increase in x), and the constant term is the y-intercept (0, b) where the line crosses the vertical axis. To convert y = mx + b into standard form Ax + By = C, rearrange it into -mx + y = b and multiply by the denominator of m so A, B, C are integers with A >= 0.

For any non-horizontal line (m != 0), setting y = 0 solves the x-intercept where the line crosses the horizontal axis: x = -b / m. For y = 2x - 3, the y-intercept is (0, -3) and the x-intercept is (1.5, 0).

Diagram linking slope-intercept form y = 2x - 3 with standard form 2x - y = 3, y-intercept (0, -3), and x-intercept (1.5, 0).
Reading y = 2x - 3: slope m = 2, y-intercept (0, -3), x-intercept (1.5, 0), and standard form 2x - y = 3.

Input Validation, Degenerate Points & Related Line Equation Calculators

Before copying the equation into graphing software or engineering models, keep these validation rules and companion coordinate tools in mind.

If you enter the exact same coordinates for both points (x1 = x2 and y1 = y2, so dx = 0 and dy = 0), infinitely many lines pass through that single location and the workspace displays Choose two distinct points. All four fields accept finite real numbers from -1,000,000,000 to 1,000,000,000, rounding repeating fractions like 4/3 to 12 significant digits.

Chain your 2D analytic geometry calculations with the Distance Between Two Points Calculator and Midpoint Calculator to find segment length and center coordinates, the Line Intersection Calculator and Point to Line Distance Calculator for multi-line geometry, or the Slope Angle Calculator to convert slope m into an angle theta = arctan(m).

Coordinate geometry workflow connecting the Line Equation Calculator with Distance, Midpoint, Line Intersection, and Slope Angle calculators.
Verify two distinct points (x1, y1) != (x2, y2) and chain your coordinates with Distance, Midpoint, or Line Intersection tools.

Frequently Asked Questions About Line Equation Calculator

Answers about using Line Equation Calculator and understanding its results.

How do you calculate the equation of a line from two points?

First compute the slope m = (y2 - y1) / (x2 - x1) by dividing the vertical rise by the horizontal run. Then substitute the slope m and either point (x1, y1) into b = y1 - m * x1 to find the y-intercept, and write the equation as y = mx + b. For (1, 2) and (3, 6), m = (6 - 2) / (3 - 1) = 2 and b = 2 - 2(1) = 0, giving y = 2x + 0.

What is the equation of a vertical line when x1 equals x2?

When x1 = x2 and y1 != y2, the horizontal run dx is zero, so the slope m = dy / 0 is undefined and the line never crosses the y-axis unless x1 = 0. Its equation is simply x = x1 (for example, (3, 0) and (3, 4) produce x = 3).

How do I convert y = mx + b into standard form Ax + By = C?

Subtract mx from both sides to get -mx + y = b, clear any fractions by multiplying every term by the least common denominator, and multiply by -1 if needed so the coefficient A is positive. For y = 0.5x - 4, multiplying -0.5x + y = -4 by -2 gives x - 2y = 8.

Why does the calculator display Choose two distinct points?

A single point (x1, y1) cannot define a unique straight line because infinitely many lines of every possible slope pass through one point. When both x1 = x2 and y1 = y2 (dx = 0 and dy = 0), the slope formula 0/0 is indeterminate, so the calculator prompts Choose two distinct points.

How do you find the x-intercept and y-intercept from the line equation?

In slope-intercept form y = mx + b, the y-intercept is (0, b) directly from the constant term. To find the x-intercept for a non-horizontal line (m != 0), set y = 0 and solve 0 = mx + b to get x = -b / m, which gives the point (-b/m, 0).

Calculate result with your input

Choose another tool for your next calculation, conversion, or text task.

Calculate result