Straight Line Graph Calculator (y = mx + c)
Enter two points to find the gradient and the equation of the straight line through them in the form y = mx + c. You also get the midpoint, the distance between the points and the perpendicular gradient, with full working.
Line through both points
Equation
y = 3x − 1
Gradient
3
Midpoint
(2, 5)
Distance
2√10 ≈ 6.32
How it works
Find the gradient
Gradient = change in y ÷ change in x = 6 ÷ 2 = 3.
Result:m = 3Find the y-intercept
Substitute the point (1, 2) into y = mx + c and solve for c.
Result:c = −1Write the equation
Put m = 3 and c = −1 into y = mx + c.
Result:y = 3x − 1Perpendicular gradient
Perpendicular lines have gradients that multiply to −1. The perpendicular gradient is −1/3.
Find the midpoint
Add the x-coordinates and halve, then do the same for y. Midpoint of (1, 2) and (3, 8) is (2, 5).
Result:(2, 5)Find the distance
Use Pythagoras on the change in x (2) and the change in y (6).
Result:2√10 ≈ 6.32
Equation of a straight line
Example substitution
Find the gradient, substitute one point to find c, then write y = mx + c.
Worked examples
Find the equation of the line through (2, 3) and (6, 11)
- 1Gradient: (11 − 3) ÷ (6 − 2) = 8 ÷ 4 = 2
- 2Substitute (2, 3): 3 = 2 × 2 + c, so c = −1
Find the equation of the line through (−1, 4) and (3, −4)
- 1Gradient: (−4 − 4) ÷ (3 − (−1)) = −8 ÷ 4 = −2
- 2Substitute (−1, 4): 4 = −2 × (−1) + c, so c = 2
Find the distance between (1, 1) and (4, 5)
- 1Change in x and y: 3 and 4
- 2Pythagoras: √(3² + 4²) = √25
Frequently asked questions
How do you find the gradient between two points?+
Gradient = change in y ÷ change in x = (y₂ − y₁)/(x₂ − x₁). From (1, 2) to (3, 8): (8 − 2)/(3 − 1) = 6/2 = 3.
How do you find the equation of a line from two points?+
Find the gradient m, then substitute one point into y = mx + c to find c. For (1, 2) and (3, 8): m = 3, and 2 = 3 × 1 + c gives c = −1, so the line is y = 3x − 1.
How do you find the midpoint of two points?+
Average the coordinates: ((x₁ + x₂)/2, (y₁ + y₂)/2). The midpoint of (1, 2) and (3, 8) is (2, 5).
How do you find the distance between two points?+
Use Pythagoras: d = √((x₂ − x₁)² + (y₂ − y₁)²). From (1, 2) to (3, 8): √(2² + 6²) = √40 = 2√10 ≈ 6.32.
What is the gradient of a perpendicular line?+
Perpendicular gradients multiply to −1, so flip the fraction and change the sign. A line with gradient 3 has a perpendicular gradient of −1/3.