
Distance Between Two Points Calculator
Use our free distance between two points calculator to find the 2D Euclidean distance between (x1, y1) and (x2, y2) with step-by-step distance formula rules.
Open toolEnter 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.
Enter the inputs, then select Calculate result.
Result will appear here
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.
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.33333333333 | 0 | y = 1.33333333333x + 0 |
| (1, 2) | (3, 6) | 4 / 2 = 2 | 2 - 2(1) = 0 | y = 2x + 0 |
| (2, 1) | (4, 5) | 4 / 2 = 2 | 1 - 2(2) = -3 | y = 2x - 3 |
| (-2, 7) | (2, -1) | -8 / 4 = -2 | 7 - (-2)(-2) = 3 | y = -2x + 3 |
| (0, -4) | (8, 0) | 4 / 8 = 0.5 | -4 | y = 0.5x - 4 |
| (-3, 5) | (4, 5) | 0 / 7 = 0 | 5 | y = 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.5 | 2.25 - 1.5(1.5) = 0 | y = 1.5x + 0 |
| (2, 2) | (2, 2) | dx = 0, dy = 0 | Indeterminate | Error: Choose two distinct points. |
Follow these three steps in the workspace above to enter your two Cartesian coordinate pairs and export the resulting line equation.
Type the horizontal and vertical coordinates of your starting point into First x coordinate (#x1, default 0) and First y coordinate (#y1, default 0).
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.
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.
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.
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.

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.

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.

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).

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).


Use our free distance between two points calculator to find the 2D Euclidean distance between (x1, y1) and (x2, y2) with step-by-step distance formula rules.
Open tool
Use our free midpoint calculator and midpoint formula calculator to find the exact center point ((x1+x2)/2, (y1+y2)/2) between any two 2D coordinates.
Open tool
Find the unique intersection of two 2D lines in Ax + By + C = 0 form.
Open toolChoose another tool for your next calculation, conversion, or text task.

Find perpendicular distance from a point to Ax + By + C = 0.
Open tool
Convert a finite line slope into its principal inclination angle in degrees.
Open tool
Interpolate one y value between two known points.
Open tool
Use this free linear equation solver to solve a*x + b = c for x over the real numbers. Handles unique roots, no solution, and infinitely many solutions.
Open toolAnswers about using Line Equation Calculator and understanding its results.
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.
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).
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.
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.
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).
Choose another tool for your next calculation, conversion, or text task.