Equation of a Line

Enter two points, or a slope and a point, and get the equation of the line in slope–intercept and standard form — computed with exact fractions and every step shown.
Computed
The line, its intercepts and the full working are shown below.
Slopeexact

3

y-interceptexact

-1

x-interceptexact

1/3

Graph
P₁P₂123510 0

The dashed triangle shows the slope as rise over run: m = Δy / Δx.

P₁, P₂ y-intercept x-intercept
Equation (slope–intercept form)exact
y=3x−1y = 3x - 1

Standard form (Ax + By = C)

3x−y=13x - y = 1

Step-by-step solution

  1. 1

    The given information

    The line passes through two points.

    (x1,y1)=(1, 2)(x2,y2)=(3, 8)(x_1, y_1) = \left(1,\ 2\right) \qquad (x_2, y_2) = \left(3,\ 8\right)
  2. 2

    Slope

    The slope is rise over run: the change in y divided by the change in x.

    m=y2−y1x2−x1=62=3m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{6}{2} = 3
  3. 3

    Point-slope form

    Substitute the slope m = 3 and the point (1, 2) into the point-slope form y − y₁ = m(x − x₁).

    y−2=3(x−1)y - 2 = 3\left(x - 1\right)
  4. 4

    Slope-intercept form

    Solve for y: distribute the slope and collect the constant term. The constant is the y-intercept b = -1, giving y = 3x - 1. Check with the second point: m·x₂ + b = 8, which matches y₂ ✓

    b=y1−m⋅x1=2−3⋅1=−1y=3x−1\begin{aligned} b &= y_1 - m \cdot x_1 \\ &= 2 - 3 \cdot 1 \\ &= -1 \\[2pt] y &= 3x - 1 \end{aligned}
    • b = y₁ − m·x₁ = 2 − 3·1 = -1
  5. 5

    Standard form

    All coefficients are already integers; rearrange y = mx + b into Ax + By = C by moving the x-term to the left side.

    y=3x−1  ⟹  3x−y=1y = 3x - 1 \;\Longrightarrow\; 3x - y = 1
  6. 6

    Intercepts

    Set x = 0 to find the y-intercept: y = -1. Set y = 0 and solve 0 = mx + b for x: x = −b/m = 1/3. The line crosses the axes at (0, -1) and (1/3, 0).

    y-intercept: (0, −1)x-intercept: (13, 0)\text{y-intercept: } \left(0,\ -1\right) \qquad \text{x-intercept: } \left(\frac{1}{3},\ 0\right)
  7. 7

    Result

    The line has slope 3 and crosses the y-axis at (0, -1). Equation: y = 3x - 1.

    y=3x−1y = 3x - 1

About equations of a line

The slope m = rise/run measures steepness; with the y-intercept b it gives the slope-intercept form y = mx + b, the most common way to describe a straight line.

Two distinct points determine exactly one line: m = (y₂ − y₁)/(x₂ − x₁), then substitute one point to find b. A single point plus a slope works the same way (point-slope form).

Slopes and intercepts stay exact fractions — the line through (1/2, 1/3) and (2, 3) has slope exactly 16/9 — and vertical lines, where the slope is undefined, are handled as their own case.