Skip to content

Equation of a line calculator: y = mx + c

Free TutorAura tool · no sign-up · Updated

Enter two points, or one point and the gradient, and the calculator writes the equation of the straight line in the form:

y=mx+cy = mx + c

where mm is the gradient (how steep the line is) and cc is the y-intercept (where it crosses the y-axis). In the US this is often written y=mx+by = mx + b.

Loading the tool

Method: from two points

  1. Find the gradient: m=y2−y1x2−x1m = \dfrac{y_2 - y_1}{x_2 - x_1}.
  2. Substitute one point into y=mx+cy = mx + c and solve for cc.
  3. Write the equation.

Example: (1,2)(1, 2) and (5,10)(5, 10). m=8÷4=2m = 8 \div 4 = 2. Then 2=2×1+c2 = 2 \times 1 + c, so c=0c = 0. The line is y=2xy = 2x.

From a point and the gradient

Through (2,7)(2, 7) with gradient 3: 7=3×2+c7 = 3 \times 2 + c, so c=1c = 1 and the line is y=3x+1y = 3x + 1.

Through (0,4)(0, 4) with gradient −0.5-0.5: the point is on the y-axis, so c=4c = 4 straight away: y=−0.5x+4y = -0.5x + 4.

Parallel and perpendicular lines

A line parallel to y=3x+1y = 3x + 1 has gradient 3 too. A line perpendicular to it has gradient −13-\tfrac{1}{3}, because perpendicular gradients multiply to −1-1. To find a perpendicular line through a point, use that gradient with the point method above.

Other forms

Equations may be given as ax+by=cax + by = c, like 2x+y=82x + y = 8. Rearrange to y=mx+cy = mx + c to read the gradient and intercept: y=−2x+8y = -2x + 8, so the gradient is −2-2 and it crosses the y-axis at 8. To find where a line crosses the x-axis, set y=0y = 0.

Common mistakes

  • Using (x,y)(x, y) the wrong way round when substituting.
  • Getting the sign of cc wrong when moving terms.
  • Writing y=2x+0y = 2x + 0: just write y=2xy = 2x.

Practise with our straight-line graphs questions, and find the gradient alone with the gradient calculator.

Exam tips

  • Check your equation with the second point: it should work for both.
  • If the question asks for the form ax+by+c=0ax + by + c = 0, rearrange at the end and use whole numbers.
  • On the SAT, lines are often written y=mx+by = mx + b: same idea.

Checking points and intercepts

  • Is a point on the line? Substitute its x-coordinate. For y=3x+1y = 3x + 1, the point (4,13)(4, 13) is on the line because 3×4+1=133 \times 4 + 1 = 13, but (4,12)(4, 12) is not.
  • x-intercept: set y=0y = 0. For y=3x+1y = 3x + 1, 0=3x+10 = 3x + 1 gives x=−13x = -\tfrac{1}{3}.
  • Where two lines cross: set their equations equal and solve, or use our simultaneous equations calculator.

Frequently asked questions

How do you find the equation of a line from two points?

Find the gradient (change in y ÷ change in x), substitute one point into y = mx + c to find c, then write y = mx + c.

What does c mean in y = mx + c?

The y-intercept: the value of y where the line crosses the y-axis (when x = 0).

What is the gradient of a perpendicular line?

The negative reciprocal: if a line has gradient m, a perpendicular line has gradient −1/m.

Is anything I type sent to a server?

No. The calculation runs in your browser and nothing is stored.

Sources

  1. GCSE mathematics: subject content and assessment objectives. Department for Education.
  2. Cambridge IGCSE Mathematics 0580 syllabus. Cambridge International.