Skip to content

Line equation calculator

Write the equation of a straight line from two points or from one point and its slope.

Known information about the line

Your data stays in this browser.

Enter finite coordinates. Two-point mode requires two different points.

Point A
Point AA (1, 2)
Point B
Point BB (4, 6)

Line equation result

Your equation will appear here

Choose an input mode, complete the fields, then select Calculate.

How to use the line equation calculator

Choose two points or point and slope

Choose Two points when you know A(x₁, y₁) and B(x₂, y₂). The calculator first finds the vertical change y₂−y₁ and horizontal change x₂−x₁, then divides them to obtain the slope. The points must be different, but negative and decimal coordinates are accepted.

Choose One point and slope when a problem already gives m and a point A. Enter a finite numeric slope such as −2 or 0.5. This mode builds the same straight line without asking for a second point. A vertical line cannot be expressed with a finite slope, so vertical lines are handled automatically only when the two entered points have the same x-coordinate.

Slope and equation forms

For nonvertical points, m = (y₂−y₁)/(x₂−x₁). Substituting a known point into y = mx+b gives b = y₁−mx₁. The main result is the familiar slope-intercept form y = mx+b, while the supporting result shows point-slope form y−y₁ = m(x−x₁). Both describe the same infinite line.

A horizontal line has m = 0 and simplifies to y = c. If x₁ = x₂ for two distinct points, division by zero signals a vertical line. Its slope is undefined and its equation is x = c, so the calculator does not invent an infinite slope or a y-intercept.

Read, copy, and check the line

The result lists the equation, slope, y-intercept when it exists, and point-slope form. Numbers display with at most two ordinary decimal places, with compact scientific notation for supported values that would otherwise lose meaning. Substitute either known point into the displayed equation to check the result.

The sketch uses the known points and calculated direction, rescaled to fit. It helps identify rising, falling, horizontal, and vertical lines but is not a full graph editor and does not show intersections or inequalities. Copy result creates a concise text summary. Any edit or mode change clears the old result before a new calculation.

Worked examples

Two points A(1, 2) and B(4, 8)

m = (8−2)/(4−1) = 2. Then b = 2−2·1 = 0, so the line is y = 2x. Point-slope form is y−2 = 2(x−1).

One point (3, −1) and slope 0.5

b = −1−0.5·3 = −2.5. The equation is y = 0.5x−2.5. Substituting x = 3 gives y = −1.

Vertical and horizontal cases

Points (4, −2) and (4, 7) give the vertical line x = 4 with undefined slope. Points (−3, 5) and (8, 5) give the horizontal line y = 5 with slope 0.

Uses, limits, and output

Appropriate uses

Use this calculator to check coordinate-geometry homework, obtain a line before plotting it, confirm a slope, or translate point data into a readable equation. It models one infinite straight line in a two-dimensional Cartesian plane.

Supported boundaries

The page does not find intersections, regression or best-fit lines, inequalities, curves, segments, or three-dimensional equations. It accepts decimal real numbers, not fractions such as 1/3 or a pasted full equation. Enter a decimal approximation when needed.

Two identical points do not determine one unique line and are rejected. Very extreme combinations that make a slope or intercept exceed the supported finite range also show an error rather than Infinity. Display rounding is for reading; it is not an arbitrary-precision algebra system.

Frequently asked questions

What if the two x-coordinates are equal?

Different points with equal x-coordinates form a vertical line x = c. Its slope and y-intercept are undefined.

What if the two y-coordinates are equal?

The line is horizontal, has slope 0, and simplifies to y = that shared y-coordinate.

Can I enter a fraction for the slope?

Enter a decimal real number such as 0.75 rather than text such as 3/4.

Why are identical points rejected?

Infinitely many lines pass through one point, so a repeated point does not determine a unique equation.

How do I check the equation?

Substitute the coordinates of a known point. Both sides of the displayed equation should agree.