What Is the Equation of a Straight Line: y = mx + b

The most common equation of a straight line is y = mx + b, where m is the slope (how steep the line is) and b is the y-intercept (where the line crosses the vertical axis). This is called slope-intercept form, and it’s the version you’ll use most often. But there are several other forms of the same equation, each useful in different situations.

Slope-Intercept Form: y = mx + b

This is the go-to format for most straight-line problems. It tells you two things at a glance: the slope of the line and the exact point where it crosses the y-axis.

The slope, m, describes how much y changes every time x increases by 1. If m = 3, the line rises 3 units for every 1 unit you move to the right. If m = -2, the line drops 2 units instead. A larger absolute value means a steeper line.

The y-intercept, b, is the value of y when x equals zero. That gives you the coordinate point (0, b) on the graph. You can verify this yourself: plug x = 0 into y = mx + b, and the mx term disappears entirely, leaving y = b.

So if you see y = 4x + 7, the line has a slope of 4 and crosses the y-axis at the point (0, 7).

How to Calculate Slope

If you have two points on a line, you can find the slope using the formula:

m = (y₂ – y₁) / (x₂ – x₁)

This is often described as “rise over run.” The numerator is how far the line moves vertically between the two points (the rise), and the denominator is how far it moves horizontally (the run). For example, given the points (1, 2) and (4, 8), the slope is (8 – 2) / (4 – 1) = 6/3 = 2. The line rises 2 units for every 1 unit to the right.

Point-Slope Form

Sometimes you know the slope of a line and one point on it, but that point isn’t the y-intercept. Point-slope form handles this situation directly:

y – y₁ = m(x – x₁)

Here, (x₁, y₁) is any known point on the line, and m is the slope. Say you know a line passes through (3, 5) with a slope of 2. Plug those values in and you get y – 5 = 2(x – 3). You can then rearrange this into slope-intercept form if you want: distribute the 2 to get y – 5 = 2x – 6, then add 5 to both sides for y = 2x – 1.

Point-slope form is especially handy when you’re given two points. Calculate the slope first using the rise-over-run formula, then plug the slope and either point into y – y₁ = m(x – x₁).

Standard Form: Ax + By = C

Standard form writes the equation as Ax + By = C, where A, B, and C are integers. Unlike slope-intercept form, both x and y sit on the same side of the equation. For example, 3x + 2y = 12 is in standard form.

This format doesn’t show you the slope or y-intercept directly, but it makes finding both intercepts very straightforward. To find the y-intercept, set x to 0 and solve for y. To find the x-intercept, set y to 0 and solve for x. Using 3x + 2y = 12 as an example: setting x = 0 gives 2y = 12, so y = 6 and the y-intercept is (0, 6). Setting y = 0 gives 3x = 12, so x = 4 and the x-intercept is (4, 0).

You can always convert between forms. To go from standard form to slope-intercept form, isolate y on one side of the equation.

Horizontal and Vertical Lines

Not every straight line fits neatly into y = mx + b. Two special cases have their own simplified equations.

A horizontal line has a slope of zero. No matter how far you move along the x-axis, y stays the same. Its equation is simply y = some constant. For example, y = 6 is a flat horizontal line that passes through every point where the y-coordinate is 6.

A vertical line has an undefined slope because the run (horizontal change) is zero, and you can’t divide by zero. Its equation takes the form x = some constant. For instance, x = -5 is a vertical line passing through every point where the x-coordinate is -5. Vertical lines are the one type of straight line you cannot write in slope-intercept form.

Finding Intercepts From Any Equation

Regardless of which form your equation is in, the method for finding intercepts is always the same. To find the y-intercept, substitute x = 0 and solve for y. To find the x-intercept, substitute y = 0 and solve for x. The y-intercept will always be a point of the form (0, y), and the x-intercept will always be a point of the form (x, 0), because intercepts are where the line crosses each axis.

Parallel and Perpendicular Lines

Once you understand slope, you can identify how two lines relate to each other. Parallel lines have identical slopes. If one line has a slope of 3, any line parallel to it also has a slope of 3. They never intersect because they rise at exactly the same rate.

Perpendicular lines intersect at a 90-degree angle, and their slopes are negative reciprocals of each other. If one line has a slope of 2/3, a perpendicular line has a slope of -3/2. You flip the fraction and change the sign. If the original slope is 5 (which is 5/1), the perpendicular slope is -1/5. Multiplying the two slopes together always gives -1, which is a quick way to check your work.