What is my line in y = mx + b form?
Type two points on a line, or its slope and one point, to get its equation as y = mx + b with exact fractions and a graph.
- Slope-intercept form
- y = 2x + 1
The line is y = 2x + 1.
- Slope m
- 2
- y-intercept b
- 1
- x-intercept
- -0.5
- Point-slope form
- y − 3 = 2(x − 1)
- Standard form
- 2x − y = −1
Slope-intercept form: y = 2x + 1. The line is y = 2x + 1.
y on the line by x
How to calculate
Finds the slope-intercept form y = mx + b of a line through two points, or through one point with a given slope, in exact fractions, with the point-slope and standard forms.
Example with the default inputs (I know Two points, x₁ 1, y₁ 3, x₂ 3, y₂ 7): The line is y = 2x + 1.
Method: m = (y₂ − y₁) ÷ (x₂ − x₁) (or the slope as typed), b = y₁ − m × x₁, and the line is y = mx + b; all in exact fractions.
- Every number is read exactly as typed: 0.1 is 1/10, so the slope and intercept are exact fractions.
- The two points must have different x values. A vertical line, x = c, has no slope-intercept form.
- The point-slope form uses the first point, (x₁, y₁).
- The standard form Ax + By = C uses whole numbers with no common factor, with A ≥ 0.
- y at x is shown when it is at most 10³⁰⁰ in size.
Worked examples
Each example is checked against the calculator on every build.
- I know Two points, x₁ 1, y₁ 3, x₂ 3, y₂ 7 gives Slope-intercept form y = 2x + 1, Slope m 2, y-intercept b 1, x-intercept -0.5, Point-slope form y − 3 = 2(x − 1), Standard form 2x − y = −1.Source: hand calculation in content.mdx: m = (7 − 3) ÷ (3 − 1) = 2, b = 3 − 2 × 1 = 1
- I know Two points, x₁ 3, y₁ 4, x₂ 0, y₂ -3 gives Slope-intercept form y = (7/3)x − 3, Slope m 2.333333, y-intercept b -3, x-intercept 1.285714, Standard form 7x − 3y = 9.Source: OpenStax College Algebra 2e, section 2.2: the line through (3, 4) and (0, −3) is y = (7/3)x − 3
- I know Slope and a point, Slope (m) -0.5, x₁ 4, y₁ 1, x 10 gives Slope-intercept form y = −(1/2)x + 3, y-intercept b 3, x-intercept 6, Point-slope form y − 1 = −(1/2)(x − 4), Standard form x + 2y = 6, y on the line -2.Source: hand calculation in content.mdx: b = 1 − (−1/2) × 4 = 3; at x = 10, y = −5 + 3 = −2
- I know Two points, x₁ -2, y₁ 5, x₂ 4, y₂ 5 gives Slope-intercept form y = 5, Slope m 0, y-intercept b 5, Standard form y = 5.Source: hand calculation in content.mdx: equal y values give slope 0, a flat line
- I know Two points, x₁ 0.1, y₁ 0.2, x₂ 0.3, y₂ 0.5 gives Slope-intercept form y = (3/2)x + 1/20, Slope m 1.5, y-intercept b 0.05.Source: hand calculation in content.mdx: decimals are exact, m = 0.3 ÷ 0.2 = 3/2, b = 0.2 − 0.15 = 1/20
How it works
A non-vertical line is y = mx + b, where m is the slope and b is the y-intercept.
From two points (x₁, y₁) and (x₂, y₂):
- slope: m = (y₂ − y₁) ÷ (x₂ − x₁), the rise over the run
- intercept: b = y₁ − m × x₁, from putting the first point into y = mx + b
From a slope m and one point (x₁, y₁): b = y₁ − m × x₁.
The calculator also shows:
- the point-slope form, y − y₁ = m(x − x₁), through the first point
- the standard form Ax + By = C: multiply y = mx + b by the least common multiple L of the denominators of m and b to get (mL)x − Ly = −bL, then make A 0 or more (and B positive when A is 0) and divide out any common factor of A, B, and C
- the x-intercept, x = −b ÷ m, when m is not 0
- y at a chosen x: y = mx + b
Assumptions
- Every number is read exactly as typed, as a fraction: 0.1 is 1/10 and 2.5 is 5/2. So m and b are exact fractions in lowest terms, with no rounding.
- The two points must have different x values. If they have the same x, the line is vertical (x = c) and has no slope-intercept form. If the two points are the same, they do not set a line.
- The decimal slope, intercepts, and y are the exact fractions rounded to double precision.
- y at x is left out when it is larger than 10³⁰⁰ in size.
How the equations are written
- Fractions are in lowest terms, such as 7/3; a whole number has no denominator.
- A coefficient other than 1 is written before its letter, in brackets when it is a fraction: 2x, (7/3)x. A coefficient of 1 is left out (x, −x), and so is a term that is 0 (y = 2x, y = 5, and y = 0 for the x axis).
- Signs between terms are written " + " and " − " (the minus sign −). A negative first term starts with −: y = −(1/2)x + 3.
- Point-slope form: y − y₁ = m(x − x₁), with "y + 5" for y₁ = −5, "x" alone for x₁ = 0, and "y − 4 = 0" style for m = 0.
- Standard form: Ax + By = C with the same rules for the coefficients (7x − 3y = 9, x + 2y = 6, y = 5).
Worked examples by hand
Through (1, 3) and (3, 7). m = (7 − 3) ÷ (3 − 1) = 4 ÷ 2 = 2. b = 3 − 2 × 1 = 1. So y = 2x + 1. Point-slope: y − 3 = 2(x − 1). Standard: y = 2x + 1 becomes 2x − y = −1. The x-intercept is −1 ÷ 2 = −0.5.
Through (3, 4) and (0, −3) (OpenStax College Algebra 2e, section 2.2). m = (−3 − 4) ÷ (0 − 3) = −7 ÷ −3 = 7/3. b = 4 − (7/3) × 3 = 4 − 7 = −3. So y = (7/3)x − 3. Times 3: 3y = 7x − 9, so 7x − 3y = 9. The x-intercept is 3 ÷ (7/3) = 9/7 = 1.2857.
Slope −1/2 through (4, 1), read at x = 10. b = 1 − (−1/2) × 4 = 1 + 2 = 3, so y = −(1/2)x + 3. Times 2: 2y = −x + 6, so x + 2y = 6. The x-intercept is −3 ÷ (−1/2) = 6. At x = 10, y = −5 + 3 = −2.
Through (−2, 5) and (4, 5). m = (5 − 5) ÷ (4 − (−2)) = 0 ÷ 6 = 0, so the line is flat: y = 5.
Through (0.1, 0.2) and (0.3, 0.5). m = 0.3 ÷ 0.2 = 3/2. b = 0.2 − (3/2) × 0.1 = 0.2 − 0.15 = 0.05 = 1/20. So y = (3/2)x + 1/20.
Other questions people ask
How do I find y = mx + b from two points?
First find the slope, m = (y₂ − y₁) ÷ (x₂ − x₁). Then put one point into y = mx + b and solve for b: b = y₁ − m × x₁. For (1, 3) and (3, 7): m = 4 ÷ 2 = 2 and b = 3 − 2 × 1 = 1, so y = 2x + 1.
What do m and b mean?
m is the slope: how much y goes up when x goes up by 1 (a negative m means the line goes down). b is the y-intercept: the value of y where the line crosses the y axis, at x = 0.
How do I find the equation from the slope and one point?
Use b = y₁ − m × x₁. With slope −1/2 through (4, 1): b = 1 − (−1/2) × 4 = 3, so y = −(1/2)x + 3.
Why does the answer show fractions?
Slopes are often not whole numbers. The line through (3, 4) and (0, −3) has slope 7/3, which as a decimal is 2.333… and never ends. The fraction is exact; the decimal slope is shown too.
What if both points have the same x value?
Then the line is vertical, x = c. Its slope is undefined (the run x₂ − x₁ is 0), so it cannot be written as y = mx + b. The calculator says so instead of giving a number.
How do I convert y = mx + b to standard form?
Move the x term to the left and clear the fractions. y = (7/3)x − 3 becomes −(7/3)x + y = −3; multiplying by −3 gives 7x − 3y = 9. The calculator shows this form too.
How do I find the x-intercept?
Set y = 0 and solve: 0 = mx + b gives x = −b ÷ m. For y = 2x + 1 the line crosses the x axis at x = −0.5. A flat line (m = 0) has no x-intercept unless it is the x axis itself.