Skip to content
Others

Line Calculator

Line Calculator

Enter two points to get the slope, the equation y = mx + b, the distance, the midpoint, and the angle of the line.

x1
y1
x2
y2

Two points are enough to pin down a straight line completely, and once a line is pinned down, a family of questions can be answered about it: how steep it is, where it crosses the axes, how far apart the points are, what sits exactly between them, and at what angle it climbs. This line calculator answers all of them at once. Enter the coordinates of two points and it returns the slope, the equation in the form y = mx + b, the distance, the midpoint, and the angle, with a breakdown of every formula.

The special cases are handled honestly rather than hidden. If the two points share the same x value, the line is vertical, its slope is undefined, and its equation is simply x equals that value; the calculator says so in plain words. If the points share the same y value, the line is horizontal, its slope is zero, and its angle is zero degrees. Those edge cases are where hand working and lesser tools tend to divide by zero and give up, so they are worth meeting here in a friendly setting.

What This Calculator Does

From your two points, the calculator finds five results. The slope, usually called m, measures steepness as the change in y divided by the change in x. The y-intercept, called b, is where the line crosses the vertical axis, and together slope and intercept give the equation y = mx + b, which describes every point on the line, not just the two you entered.

It also computes the straight-line distance between the two points using the Pythagorean idea, the midpoint that lies exactly halfway between them, and the angle the line makes with the positive x-axis, measured in degrees. Together these five results cover the standard two-point questions in school mathematics, basic surveying and layout work, and the geometry inside many design and building tasks. The breakdown under the results restates each formula with your coordinates in place, so the method is visible, not just the answers.

How to Use This Calculator

Enter the first point as x1 and y1 and the second point as x2 and y2. Coordinates can be whole numbers, decimals, or negatives, and the order of the two points does not change the line, the distance, or the midpoint; it only flips the signs in the slope’s numerator and denominator together, leaving the slope itself the same. Press Calculate and read the equation first if you need to work with the line itself.

Check the slope’s sign against a mental sketch before trusting the numbers. If the second point is up and to the right from the first, the slope should be positive; down and to the right, negative. If your result disagrees with that sketch, a coordinate has almost certainly been typed into the wrong box, most often a y entered as an x. That two-second sketch check catches the majority of coordinate errors before they travel into homework, drawings, or measurements.

Slope, Intercept, and the Equation of a Line

The slope is m = (y2 – y1) / (x2 – x1). It is a rate: how much y changes for each single unit that x increases. A slope of 2 means the line climbs two units for every one unit across; a slope of -0.5 means it falls half a unit per unit across. The intercept follows once the slope is known: b = y1 – m x1, choosing the first point; the second point gives the same b, which is a built-in check on the arithmetic.

The equation y = mx + b then generates the whole line. Substitute any x and it returns the y on the line above or below that x, including points far beyond the segment between your two originals. A vertical line is the one exception to this form, because its x never changes and its slope would need division by zero. Its equation is written instead as x = the constant value shared by both points, which describes it perfectly.

Worked Example: The Points (1, 2) and (4, 6)

Take the points (1, 2) and (4, 6). Step 1, slope: m = (6 – 2) / (4 – 1) = 4 / 3 = 1.3333 to four places. Step 2, intercept: b = 2 – 1.3333 x 1 = 0.6667 to four places, so the equation is y = 1.3333x + 0.6667. Step 3, distance: the differences are 3 across and 4 up, so distance = the square root of (9 + 16) = the square root of 25 = 5.0000. Step 4, midpoint: ((1 + 4) / 2, (2 + 6) / 2) = (2.5000, 4.0000). Step 5, angle: the arctangent of the slope 1.3333 is 53.13 degrees.

That distance is worth noticing: a 3 across and 4 up move giving exactly 5 is the famous 3-4-5 right triangle hiding inside the calculation. Recognising such patterns is a strong check on your working; when the differences form a known Pythagorean triple, the distance should come out whole. The equation also checks itself: at x = 4 it gives y = 1.3333 x 4 + 0.6667 = 6.0000, the second point’s y, exactly as a correct line must.

A Second Example: A Vertical Line Through (3, 1) and (3, 5)

Now take (3, 1) and (3, 5), which share the x value 3. The slope formula would divide by (3 – 3) = 0, which is not allowed, so the calculator reports the slope as undefined and the equation as x = 3. The other results still work in the ordinary way: distance = the square root of (0 + 16) = 4.0000. Midpoint = ((3 + 3) / 2, (1 + 5) / 2) = (3.0000, 3.0000). Angle = 90.00 degrees, straight up.

Vertical lines are not failures of the method; they are a real family of lines that the y = mx + b form simply cannot express. The honest response is the one the calculator gives: name the case, give the correct equation form, and keep computing everything that still makes sense. A horizontal pair of points is the mirror case: slope 0, equation y = the shared y value, angle 0 degrees, and a distance equal to the plain difference in x.

How to Read Your Results

Read the slope as the line’s character in one number. Large positive values are steep climbs, small positives are gentle rises, zero is flat, negatives descend, and the size of a negative slope tells you how sharply it falls. The intercept tells you where the line crosses the y-axis, which is the starting value in any story the line models: an initial cost, a starting height, a value at time zero.

The distance and midpoint describe the segment between your two points rather than the endless line. Distance is the crow-flies separation, always positive, in the same units as your coordinates. The midpoint is the balance point of the segment, useful for finding centres, halving journeys on a grid, and placing something exactly between two known positions. The angle, between -90 and 90 degrees for ordinary slopes and exactly 90 for vertical lines, connects the algebra to a direction you could point along.

Lines in Everyday and Practical Work

The same five results appear wherever straight relationships are used. In building and layout, slope becomes pitch or gradient: a ramp, a drainage fall, and a roof angle are all slopes with safety and legal ranges. Distance between two coordinates becomes the true length of a diagonal brace or a boundary. The midpoint becomes the centre of a span, where a support or a fitting belongs.

In data and money, a line through two points becomes a simple model: two months of sales, two readings of a tank, two prices at two sizes. Its slope is the rate per unit, its intercept is the fixed starting amount, and its equation predicts the in-between and just-beyond values. Knowing that such models rest on exactly the arithmetic in this calculator, and knowing their limits, that a line extends its pattern whether reality does or not, makes you a sharper reader of charts, quotes, and plans.

Common Mistakes When Working With Two Points

The most common mistake is mixing the order inside the slope, using (y2 – y1) over (x1 – x2), which flips the slope’s sign and tilts the whole line the wrong way. Keep the same point order top and bottom. A second classic slip is entering coordinates swapped, y for x, which produces a different line entirely; the quick sketch check described earlier catches it.

Students also force vertical lines into the y = mx + b form and report infinite or zero slope, when the correct statement is undefined slope and the equation x = a constant. Another error is giving the distance a negative sign or forgetting its square root, returning 25 instead of 5 in the worked example. Finally, rounding the slope early and then computing the intercept from the rounded value drifts the equation; keep full precision through the steps, as this calculator does, and round only the displayed answers.

Frequently Asked Questions

1. How do you find the slope of a line from two points?

Divide the change in y by the change in x: m = (y2 – y1) / (x2 – x1). For (1, 2) and (4, 6) that is (6 – 2) / (4 – 1) = 4 / 3 = 1.3333.

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

Find the slope m, then the intercept with b = y1 – m x1, and write y = mx + b. For the worked example that gives y = 1.3333x + 0.6667. Vertical lines instead take the form x = a constant.

3. What is the distance between two points?

It is the square root of ((x2 – x1) squared + (y2 – y1) squared). Between (1, 2) and (4, 6) the differences are 3 and 4, so the distance is the square root of 25, exactly 5.

4. How do you find the midpoint of two points?

Average the x values and average the y values: ((x1 + x2) / 2, (y1 + y2) / 2). Between (1, 2) and (4, 6) the midpoint is (2.5, 4), the point exactly halfway along the segment.

5. What does a slope of zero mean?

The line is horizontal: y does not change as x changes. Its equation is y = the shared y value of the points, its angle is 0 degrees, and the distance is just the difference in x.

6. What is the slope of a vertical line?

It is undefined, because the slope formula would divide by zero when x1 equals x2. The line’s equation is x = the shared x value, its angle is 90 degrees, and distance and midpoint still calculate normally.

7. What does the y-intercept mean?

It is the y value where the line crosses the vertical axis, at x = 0. In practical models it is often the starting amount: the fixed cost before any per-unit charge, or the value at time zero.

8. Does the order of the two points matter?

Not for the results. Swapping the points flips the signs in both the top and bottom of the slope fraction, leaving the slope unchanged, and the distance, midpoint, and equation are identical either way.

9. How is the angle of a line calculated?

The angle to the positive x-axis is the arctangent of the slope, converted to degrees. A slope of 1.3333 gives about 53.13 degrees. Vertical lines are 90 degrees and horizontal lines are 0 degrees.

10. Can coordinates be negative or decimal?

Yes. The formulas work for any real coordinates, including negatives and decimals. Just enter each number in the right box, and use the sketch check on the slope’s sign if the points sit in different quadrants.

11. What if the two points are identical?

Then no line is defined, and the calculator asks for two different points. A single point lies on infinitely many lines, so a second, distinct point is essential for every result on this page.

12. How can I check an equation I calculated?

Substitute the second point’s x into the equation and see whether you get its y. The worked example gives 1.3333 x 4 + 0.6667 = 6.0000, matching the point (4, 6), which confirms the line.

13. What is a negative slope?

It means the line falls as x increases, dropping by the slope’s size for each unit across. A slope of -2 falls two units per unit across. Its angle is negative, measured below the x-axis direction.

14. Where are two-point line calculations used?

In gradients and pitches for ramps and roofs, in rates such as cost per unit or speed, in finding centres between two positions, and in any simple straight-line model built from two known readings.

15. What is the difference between the line and the segment?

The line is endless in both directions and is described by the equation. The segment is just the part between your two points; the distance and midpoint describe the segment, while the slope and equation describe the whole line.

Final Thoughts

Two points, five answers, and every step visible: slope from the changes in y and x, the equation from the slope and a point, distance from Pythagoras, the midpoint from two averages, and the angle from the slope. This calculator runs that complete set in one pass and treats vertical and horizontal lines honestly. Sketch the points, check the slope’s sign, and the geometry of straight lines becomes a tool you can trust anywhere.