Use this free line calculator to enter two points and get the slope, the full y = mx + b equation, the midpoint and the distance between the points, with steps shown.
Line Calculator
Two points in, the whole line out: slope, equation, midpoint and distance, each with its working shown.
Enter your values
Fill in the fields below — the result appears with every step shown.
Your result will appear here
Enter your values above, then press Calculate — or press Enter in any field.TinyExe · Line Result
Calculated locally in your browser
—
Name
—
First point x
—
First point y
—
Second point x
—
How this was calculated
What to do next
TinyExe PDF & PNG exports carry the TinyExe logo and tinyexe.com header & footer.
Runs 100% in your browser — your numbers never leave this tab; nothing is uploaded or stored.
The short answer
The slope of the line through two points is the change in y divided by the change in x. Through the points one, two and three, six, the slope is six minus two over three minus one, which equals two, and the equation of the line is y equals 2x plus zero.
- Slope m = (y2 - y1) / (x2 - x1)
- A vertical line has undefined slope
- Distance uses the Pythagorean theorem on the coordinate differences
Slope types
Reference values for this calculator.
| Slope | Line behaviour | Example points |
|---|---|---|
| Positive | Rises left to right | (1,2) to (3,6): m = 2 |
| Zero | Horizontal | (0,4) to (5,4): m = 0 |
| Negative | Falls left to right | (0,4) to (4,0): m = -1 |
| Undefined | Vertical | x values equal - no slope |
The formula
The exact formula this calculator uses — every variable in it is explained in the card below.
The formula
Ideas enhancement: from just two points it returns the full line toolkit in one run - slope, slope-intercept equation, midpoint and the distance between the points - instead of slope alone.
Worked examples
Worked examples with the full working shown — try them in the calculator to check.
Example 1
Rising line through two points
(1, 2) and (3, 6)
| Calculation | Steps |
|---|---|
| m = (6 - 2) / (3 - 1) = 4 / 2 = 2. b = 2 - 2 x 1 = 0, so y = 2x. Distance = sqrt(4 + 16) = 4.4721. | Slope 2, equation y = 2x, midpoint (2, 4). |
Result
Example 2
Horizontal line
(0, 0) and (5, 0)
| Calculation | Steps |
|---|---|
| m = (0 - 0) / (5 - 0) = 0. b = 0. The line is the x-axis itself. | Slope 0 - a perfectly level line, distance 5. |
Result
Example 3
Falling line
(-2, 3) and (2, -1)
| Calculation | Steps |
|---|---|
| m = (-1 - 3) / (2 - (-2)) = -4 / 4 = -1. b = 3 - (-1)(-2) = 1, so y = -x + 1. | Slope -1, equation y = -x + 1, midpoint (0, 1). |
Result
How to use this calculator
Step 1
Enter the x and y of the first point.
Step 2
Enter the x and y of the second point.
Step 3
Press Calculate to get the slope as the headline result.
Step 4
Read the equation, midpoint and distance in the detail cards.
Frequently asked questions
What is the slope of a line?
Slope measures steepness: the vertical change (rise) divided by the horizontal change (run) between two points. A slope of 2 means the line climbs 2 units for every 1 unit across.
What if the line is vertical?
A vertical line has equal x values, so the run is zero and the slope is undefined - division by zero. The calculator tells you this instead of inventing a number.
How do I get the equation of the line?
Find the slope m, then the intercept b = y1 - m x1 using either point. The equation is y = mx + b, and this calculator shows it directly.
What is the midpoint used for?
The midpoint ((x1+x2)/2, (y1+y2)/2) is the point exactly halfway between the two points - used in geometry, mapping and dividing segments.
Does the order of the points matter?
No. Swapping the points negates both rise and run, leaving the slope unchanged; distance and midpoint are also identical.
About this calculator
A line calculator takes two points on a coordinate grid and works out everything about the straight line through them: the slope as the headline result, plus the slope-intercept equation, the midpoint and the distance between the points.
Slope is a rate: rise over run. It is the same idea whether the axes are metres and seconds on a physics graph (when slope is speed) or dollars and months on a budget chart (when slope is monthly spend). Getting comfortable reading slope from two points transfers directly to all of those.
The equation y = mx + b turns two points into a machine for predicting: once m and b are known, any x gives its y on the line. The intercept b is the value where the line crosses the y-axis, found by running the first point backwards through b = y1 - m x1.
Distance and midpoint complete the segment's story. Distance is Pythagoras applied to the coordinate differences; midpoint is just the average of the xs and the average of the ys. Both are shown because line questions in exams and in surveying rarely ask for slope alone.
Use it for coordinate-geometry homework, for gradients in science graphs, for roof pitches and ramps described by two surveyed points, and anywhere a rate of change between two plotted points is needed.
How to calculate it yourself
Step 1
Subtract the y values to get the rise and the x values to get the run.
Step 2
Divide rise by run for the slope m.
Step 3
Use b = y1 - m x1 with either point to get the intercept.
Step 4
Write the equation y = mx + b; average the coordinates for the midpoint, and use Pythagoras on the differences for the distance.
Real-life examples
Garden ramp gradient
A landscaper measures a ramp dropping from 3 metres height at one end to -1 on the survey's datum 4 metres along, plotted as (-2, 3) and (2, -1) relative to the centre.
Slope = (-1 - 3) / (2 - (-2)) = -1, a 45-degree fall - far too steep for a wheelchair ramp, which needs about 1 in 12.
Slope -1 confirms the design must be lengthened dramatically.
Science graph rate
A student plots temperature readings at (1, 2) and (3, 6) - minutes and degrees - for a heating experiment.
Slope = (6 - 2) / (3 - 1) = 2 degrees per minute.
The mixture is heating at 2 degrees per minute over that interval.
Ideas & use cases
- Check a roof pitch: enter eave and ridge points from a drawing to get the gradient as a decimal slope to compare with building guidance.
- Predict with the equation: once you have y = mx + b, test x values beyond your two points to extrapolate a trend - carefully, since real data rarely stays linear forever.
- Split a journey leg: the midpoint gives the halfway coordinates for a rest stop between two mapped points.
Limitations & sources
- Works with two points in the Cartesian plane only; it does not fit a line of best fit to many points, handle 3D lines, or accept the points in fraction form.
Sources: Standard coordinate geometry: slope, slope-intercept form and distance formula (any analytic geometry text, e.g. OpenStax Algebra and Trigonometry)
