Skip to content

Equation of a Line Calculator

Line equation from two points, a point and a slope, y = mx + b or Ax + By + C = 0, with intercepts.

Your details

Optional: the y-value of the line (the linear function f) at this x.

Results update as you type

Slope-intercept form y = mx + b

y = −(3/2)x + 5/2

Point-slope form
y − 4 = −(3/2)(x + 1)
General form Ax + By + C = 0
3x + 2y − 5 = 0
Standard form Ax + By = C
3x + 2y = 5
Slope m
-1.5
Slope as a fraction
−3/2
y-intercept b
2.5
x-intercept
1.6666666667
Angle with the x-axis
-56.3099 °
y at the chosen x
-5

Step-by-step solution
  1. Slope: m = (y₂ − y₁) / (x₂ − x₁) = (−2 − 4) / (3 − (−1)) = −6 / 4 = −3/2
  2. y-intercept: b = y₁ − m·x₁ = 4 − (−3/2) × (−1) = 5/2
  3. y = −(3/2)x + 5/2
  4. General form (integer coefficients): 3x + 2y − 5 = 0
  5. x-intercept (y = 0): x = 5/3
  6. Value at x = 5: y = −5

A straight line in the plane can be written in several equivalent ways, and each one is handy for a different job. This equation of a line calculator takes whatever you know — two points, one point and the slope, the slope and the y-intercept, or a general equation Ax+By+C=0Ax + By + C = 0 — and returns all the usual forms at once: slope-intercept y=mx+by = mx + b, point-slope y−y1=m(x−x1)y - y_1 = m(x - x_1), general form with whole-number coefficients and standard form Ax+By=CAx + By = C.

It also gives the slope as a decimal and as a fraction, the x- and y-intercepts, the angle the line makes with the x-axis, and the value of yy for any xx you choose — which is simply evaluating the linear function f(x)=mx+bf(x) = mx + b.

Whole-number inputs are kept exact: a slope of −32-\frac{3}{2} stays a fraction rather than turning into a rounded decimal, and the general form is reduced to coprime integers. Vertical lines, which have no slope, are recognised and written as x=kx = k. To study the steepness itself (angle, percent grade, distance and midpoint), see the slope calculator and the distance between two points calculator.

How to use this calculator

  1. Choose what you know: two points, a point and the slope, the slope and the intercept, or the coefficients AA, BB, CC of Ax+By+C=0Ax + By + C = 0.
  2. Type the numbers. Negative values and decimals are accepted; with whole numbers every result stays an exact fraction.
  3. Optionally enter an xx value to read the matching yy on the line.
  4. Read the slope-intercept form at the top, then the other forms and the intercepts below. Copy the form your teacher or software expects.
  5. Open the steps to follow the slope and intercept computations.

The formula

Through two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) with x1≠x2x_1 \neq x_2, the slope is

m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}

and the y-intercept is b=y1−mx1b = y_1 - m x_1. The four forms of the same line are:

Form Equation
Slope-intercept y=mx+by = mx + b
Point-slope y−y1=m(x−x1)y - y_1 = m(x - x_1)
General Ax+By+C=0Ax + By + C = 0
Standard Ax+By=C′Ax + By = C'

From the general form with B≠0B \neq 0: m=−ABm = -\frac{A}{B} and b=−CBb = -\frac{C}{B}. The x-intercept solves y=0y = 0, i.e. x=−bmx = -\frac{b}{m} when m≠0m \neq 0. If B=0B = 0 the line is vertical, x=−CAx = -\frac{C}{A}, and has no slope.

Worked example

Two points. Take (−1,4)(-1, 4) and (3,−2)(3, -2). The slope is m=−2−43−(−1)=−64=−32m = \frac{-2 - 4}{3 - (-1)} = \frac{-6}{4} = -\frac{3}{2}, and b=4−(−32)(−1)=52b = 4 - (-\frac{3}{2})(-1) = \frac{5}{2}.

  • Slope-intercept: y = −(3/2)x + 5/2
  • Point-slope (through the first point): y − 4 = −(3/2)(x + 1)
  • General form: 3x + 2y − 5 = 0; standard form: 3x + 2y = 5
  • x-intercept: x = 5/3 ≈ 1.6667; at x=5x = 5 the line passes through y = −5.

Point and slope. Through (2,−1)(2, -1) with slope 3: y = 3x − 7, or 3x − y − 7 = 0.

General form. 2x−4y+8=02x - 4y + 8 = 0 reduces to x − 2y + 4 = 0, i.e. y = (1/2)x + 2.

Linear functions: f(x) = mx + b

Every non-vertical line is the graph of a linear function (also called an affine function) f(x)=mx+bf(x) = mx + b. The slope mm is the rate of change — how much f(x)f(x) increases when xx increases by 1 — and b=f(0)b = f(0) is the starting value. For y = 2x − 3, f(4) = 5 and the function crosses zero at x = 1.5.

Typical real-world examples: a taxi fare with a fixed pickup charge plus a price per kilometre, a phone plan with a monthly fee plus a cost per gigabyte, or a temperature conversion such as F=1.8C+32F = 1.8C + 32. Knowing two data points is enough to rebuild the whole function with the two-point mode.

Parallel, perpendicular, horizontal and vertical lines

Two non-vertical lines are parallel when they have the same slope and perpendicular when their slopes multiply to −1-1. A horizontal line has slope 0 and an equation y=ky = k; a vertical line has an undefined slope and an equation x=kx = k, which is why only the general and standard forms can describe every line in the plane. For intersections of two lines, solve the system — for example with the matrix calculator.

Frequently asked questions

How do I find the equation of a line through two points?

Compute the slope m = (y₂ − y₁) / (x₂ − x₁), then the intercept b = y₁ − m·x₁, and write y = mx + b. Through (−1, 4) and (3, −2) you get m = −3/2, b = 5/2, so y = −(3/2)x + 5/2.

What is the difference between general form and standard form?

Both put x and y on the same side. General form sets everything equal to zero, Ax + By + C = 0; standard form keeps the constant on the right, Ax + By = C. Textbooks usually ask for integer coefficients with A positive, which is what the calculator returns.

Why does a vertical line have no slope-intercept form?

On a vertical line every point has the same x, so the run x₂ − x₁ is zero and the slope cannot be computed. Its equation is x = k, and y is not a function of x.

How do I convert Ax + By + C = 0 to y = mx + b?

Isolate y: By = −Ax − C, then divide by B. The slope is −A/B and the intercept −C/B. For 2x − 4y + 8 = 0, y = (1/2)x + 2.

How do I find the x- and y-intercepts?

Set x = 0 to get the y-intercept and y = 0 to get the x-intercept. A horizontal line other than the x-axis never meets the x-axis, so it has no x-intercept.

Sources

Last updated:

More Math calculators

People also use