Math

Slope Calculator

Calculate the slope, y-intercept, line equation, distance, and midpoint between two points. Handles vertical, horizontal, and diagonal lines.

Quick Answer

The slope of a line through two points (x, y) and (x, y) is m = (y - y) / (x - x). A positive slope rises left to right, a negative slope falls, zero is horizontal, and undefined means vertical.

Enter Two Points

Provide coordinates for Point 1 and Point 2 to calculate slope and more.

m = (y - y) / (x - x)

Point 1 (x, y)

Point 2 (x, y)

Results

Slope (m)
1.333333
Y-Intercept (b)
0.666667
Angle
53.130102°
Line Equation
y = 1.333333x + 0.666667
Distance
5
((x-x)² + (y-y)²)
Midpoint
(2.5, 4)
((x+x)/2, (y+y)/2)

Step-by-Step Solution

Step 1: Identify the points

Point 1 = (1, 2), Point 2 = (4, 6)

Step 2: Calculate the slope

m = (6 - 2) / (4 - 1) = 4 / 3 = 1.333333

Step 3: Find the y-intercept

b = y - m × x = 2 - 1.333333 × 1 = 0.666667

Step 4: Write the equation

y = 1.333333x + 0.666667

Step 5: Calculate the distance

d = ((4 - 1)² + (6 - 2)²) = (9 + 16) = 25 = 5

Step 6: Find the midpoint

M = ((1 + 4)/2, (2 + 6)/2) = (2.5, 4)

Line Visualization

M(1, 2)(4, 6)

About This Tool

The Slope Calculator is a comprehensive coordinate geometry tool that computes every essential property of a line defined by two points. Enter the coordinates of Point 1 (x, y) and Point 2 (x, y), and the calculator instantly returns the slope, y-intercept, line equation in slope-intercept form, the distance between the two points, and the midpoint of the segment connecting them. It handles all edge cases including vertical lines (undefined slope), horizontal lines (zero slope), and lines passing through the origin. This tool is indispensable for algebra students, engineers, data analysts, and anyone working with linear relationships.

Understanding Slope

Slope measures how steep a line is and in which direction it tilts. Formally, slope is the ratio of the vertical change (rise) to the horizontal change (run) between any two distinct points on a line: m = (y - y) / (x - x). A positive slope means the line rises from left to right. A negative slope means it falls. A slope of zero produces a perfectly horizontal line. When x equals x, the denominator becomes zero and the slope is undefined, indicating a vertical line. Slope is constant everywhere on a straight line, which is what distinguishes linear functions from curves.

Slope-Intercept Form: y = mx + b

The most common way to express a linear equation is slope-intercept form: y = mx + b, where m is the slope and b is the y-intercept (the y-value where the line crosses the y-axis, i.e., where x = 0). Once you know the slope m, you can find b by substituting either point into the equation: b = y - m × x. This form makes it easy to graph a line and to understand its behavior at a glance. Vertical lines cannot be expressed in slope-intercept form; they use the equation x = k instead, where k is the constant x-coordinate.

Distance Between Two Points

The distance formula is derived directly from the Pythagorean theorem. Given two points, the horizontal distance |x - x| and vertical distance |y - y| form the legs of a right triangle, and the straight-line distance is the hypotenuse: d = ((x - x)² + (y - y)²). This formula works in any quadrant and for any pair of points, including those with negative coordinates. The distance is always a non-negative value and equals zero only when the two points are identical.

Midpoint of a Line Segment

The midpoint is the point exactly halfway between two endpoints. It is calculated by averaging the x-coordinates and the y-coordinates separately: M = ((x + x)/2, (y + y)/2). The midpoint always lies on the line segment connecting the two points. In practical applications, finding midpoints is useful in construction (centering objects), computer graphics (interpolation), and navigation (halfway points on routes). The midpoint formula extends naturally to three dimensions by also averaging the z-coordinates.

Special Cases and Edge Conditions

This calculator gracefully handles several special cases. Vertical lines (where x = x) have undefined slope and are displayed as x = k rather than y = mx + b. Horizontal lines (where y = y) have a slope of exactly zero. Lines passing through the origin have a y-intercept of zero, simplifying the equation to y = mx. When the two points are identical, the calculator alerts you since a unique line cannot be determined from a single point. Understanding these edge cases is critical for writing robust mathematical software and for avoiding division-by-zero errors in spreadsheets and code.

Real-World Applications of Slope

Slope appears everywhere in science and daily life. In physics, velocity is the slope of a position-time graph, and acceleration is the slope of a velocity-time graph. In economics, marginal cost is the slope of the total cost curve. Civil engineers use slope to design roads and drainage systems (often expressed as a percentage grade: a 6% grade means the road rises 6 feet for every 100 feet of horizontal distance). Roof pitch, wheelchair ramp specifications, and ski trail ratings are all defined by slope. In data analysis, the slope of a best-fit line (linear regression) reveals the rate of change between two variables and is fundamental to predictive modeling.

Frequently Asked Questions

What does it mean when the slope is undefined?
An undefined slope occurs when the two points have the same x-coordinate (x1 = x2), making the line perfectly vertical. In the slope formula m = (y2 - y1) / (x2 - x1), the denominator becomes zero, and division by zero is undefined. Vertical lines are expressed as x = k rather than y = mx + b. This is not an error — it simply means the line goes straight up and down.
What is the difference between positive and negative slope?
A positive slope means the line rises as you move from left to right — for every unit you move right, you move up by the slope amount. A negative slope means the line falls as you move from left to right. A slope of +2 means the line rises 2 units for every 1 unit to the right. A slope of -3 means the line drops 3 units for every 1 unit to the right. The steeper the absolute value, the more dramatic the rise or fall.
How do I find the equation of a line from two points?
First, calculate the slope: m = (y2 - y1) / (x2 - x1). Then find the y-intercept by plugging one point into y = mx + b and solving for b: b = y1 - m * x1. The final equation is y = mx + b. For example, with points (1, 2) and (4, 6): m = (6-2)/(4-1) = 4/3, then b = 2 - (4/3)(1) = 2/3, giving y = (4/3)x + 2/3.
Does the order of the two points matter?
No. Whether you call (1, 2) Point 1 and (4, 6) Point 2, or vice versa, the slope, equation, distance, and midpoint are identical. Swapping the points negates both the numerator and denominator of the slope formula, so the result is the same. The distance formula uses squared differences, making it order-independent. The midpoint averages coordinates, which is commutative.
What is the slope of a horizontal line?
A horizontal line has a slope of exactly zero. Since all points on a horizontal line share the same y-coordinate, the numerator of the slope formula (y2 - y1) is zero, making m = 0. The equation of a horizontal line is simply y = b, where b is the constant y-value. For example, the line through (2, 5) and (8, 5) has slope 0 and equation y = 5.
How is slope related to angle?
The slope of a line equals the tangent of the angle it makes with the positive x-axis: m = tan(theta). To find the angle from the slope, use the inverse tangent: theta = arctan(m). A 45-degree line has slope 1, a -45-degree line has slope -1, and a horizontal line (0 degrees) has slope 0. Vertical lines correspond to 90 degrees, where tangent is undefined — matching the undefined slope.

Was this tool helpful?