Slope Calculator
Slope Calculator. Free online calculator with formula, examples and step-by-step guide.
Slope Calculator: Find the Slope and Equation of a Line Through Two Points
What is Slope?
Slope measures the steepness and direction of a line, representing the rate at which y changes with respect to x. Mathematically, slope equals "rise over run"—the vertical change divided by the horizontal change between any two points on the line. A positive slope rises from left to right, while a negative slope falls.
Consider two points: (2, 3) and (8, 15). Moving from the first point to the second, you rise 12 units (from y = 3 to y = 15) and run 6 units (from x = 2 to x = 8). The slope is 12/6 = 2. This means for every 1 unit you move right, the line rises 2 units. The steepness is consistent everywhere along a straight line.
Slope appears throughout mathematics and real life. In physics, velocity is the slope of a position-time graph. In economics, marginal cost is the slope of the total cost curve. In construction, roof pitch and ramp incline are slopes. In data analysis, the slope of a trend line shows how one variable changes with another. Understanding slope unlocks linear relationships everywhere.
Four slope types exist: positive (rising line), negative (falling line), zero (horizontal line), and undefined (vertical line). A horizontal line like y = 5 has slope 0—no rise regardless of run. A vertical line like x = 3 has undefined slope—division by zero since run equals zero. These special cases appear frequently in coordinate geometry.
How It Works: Slope and Line Equation Formulas
Two fundamental formulas govern linear relationships: the slope formula and the slope-intercept equation.
The Slope Formula: Given two points (x₁, y₁) and (x₂, y₂), slope m = (y₂ - y₁) / (x₂ - x₁). For points (2, 3) and (8, 15): m = (15 - 3) / (8 - 2) = 12 / 6 = 2. The order matters—be consistent. If you subtract y₁ from y₂, you must subtract x₁ from x₂. Reversing one but not the other flips the sign.
Slope-Intercept Form: The equation y = mx + b describes any non-vertical line, where m is the slope and b is the y-intercept (where the line crosses the y-axis). For a line with slope 2 passing through (0, -1): y = 2x - 1. The y-intercept b equals the y-value when x = 0, making it easy to graph.
Finding the Y-Intercept: When you know the slope and one point, substitute into y = mx + b and solve for b. For slope m = 2 and point (3, 7): 7 = 2(3) + b, so 7 = 6 + b, giving b = 1. The equation is y = 2x + 1. Verify with the point: 2(3) + 1 = 7 ✓.
Point-Slope Form: An alternative equation form is y - y₁ = m(x - x₁), useful when you know a point and the slope but not the y-intercept. For m = 2 and point (3, 7): y - 7 = 2(x - 3). Expand to get y - 7 = 2x - 6, then y = 2x + 1. All three forms (slope-intercept, point-slope, standard) describe the same line.
Step-by-Step Guide: Calculating Slope and Line Equations
Step 1: Identify and Label Your Two Points
Write down both points clearly and assign coordinates. For this guide, use (4, 5) and (10, 17). Label them: (x₁, y₁) = (4, 5) and (x₂, y₂) = (10, 17). Consistent labeling prevents mixing up which coordinate belongs to which point. Order doesn't affect the final slope, but consistency matters within the calculation.
Step 2: Calculate the Rise (Change in y)
Subtract the y-coordinates: y₂ - y₁ = 17 - 5 = 12. This is the vertical change. If you went from the second point to the first, you'd get 5 - 17 = -12. Either works as long as you're consistent with the run calculation. The rise tells you how much the line moves vertically between your two points.
Step 3: Calculate the Run (Change in x)
Subtract the x-coordinates: x₂ - x₁ = 10 - 4 = 6. This is the horizontal change. Using the same order as step 2: 10 - 4 = 6. If you reversed the points, you'd get 4 - 10 = -6. The run must use the same point order as the rise to maintain the correct slope sign.
Step 4: Compute the Slope
Divide rise by run: m = 12 / 6 = 2. The slope is 2, meaning the line rises 2 units for every 1 unit moved right. If the result were negative (like -2), the line would fall 2 units per 1 unit right. A fraction like 3/4 means rise 3 for every run 4. Simplify the fraction if possible.
Step 5: Find the Y-Intercept
Use y = mx + b with your slope and either point. Using (4, 5) and m = 2: 5 = 2(4) + b, so 5 = 8 + b, giving b = -3. Using the other point (10, 17) as a check: 17 = 2(10) + b, so 17 = 20 + b, giving b = -3 ✓. Both points yield the same y-intercept, confirming the calculation.
Step 6: Write the Complete Equation
Substitute m and b into y = mx + b. With m = 2 and b = -3: y = 2x - 3. Verify with both original points: for (4, 5): 2(4) - 3 = 5 ✓; for (10, 17): 2(10) - 3 = 17 ✓. The equation correctly describes the line passing through both points. Graph it to visualize: start at (0, -3) and rise 2, run 1 repeatedly.
Real-World Examples with Complete Calculations
Example 1: Road Grade Calculation
A mountain road climbs from elevation 1,200 ft at mile marker 5 to elevation 3,800 ft at mile marker 12. What's the average grade? Points: (5, 1200) and (12, 3800). Slope m = (3800 - 1200) / (12 - 5) = 2600 / 7 ≈ 371.4 ft/mile. Convert to percentage: 371.4 / 5280 ≈ 0.0704 = 7.04%. This steep grade requires truck warning signs and escape ramps.
Example 2: Linear Depreciation
A car worth $28,000 when new is worth $16,000 after 4 years. What's the depreciation rate and value equation? Points: (0, 28000) and (4, 16000). Slope m = (16000 - 28000) / (4 - 0) = -12000 / 4 = -3000. The car loses $3,000 per year. Y-intercept b = 28000. Equation: V = -3000t + 28000, where V is value and t is years. After 6 years: V = -3000(6) + 28000 = $10,000.
Example 3: Water Tank Filling Rate
A tank contains 150 gallons at 2:00 PM and 390 gallons at 5:00 PM. What's the fill rate and when will it reach 500 gallons? Points: (2, 150) and (5, 390) using 24-hour time. Slope m = (390 - 150) / (5 - 2) = 240 / 3 = 80 gallons/hour. Equation: G = 80t + b. Using (2, 150): 150 = 80(2) + b, so b = -10. G = 80t - 10. For G = 500: 500 = 80t - 10, so t = 510/80 = 6.375 = 6:22 PM.
Example 4: Temperature Conversion Line
Water freezes at 0°C = 32°F and boils at 100°C = 212°F. Find the conversion formula. Points: (0, 32) and (100, 212). Slope m = (212 - 32) / (100 - 0) = 180 / 100 = 9/5 = 1.8. Y-intercept b = 32 (from the first point). Equation: F = 1.8C + 32. Verify with boiling: 1.8(100) + 32 = 212 ✓. For body temperature 37°C: F = 1.8(37) + 32 = 98.6°F.
Example 5: Cell Phone Plan Comparison
Plan A costs $40/month plus $0.10 per GB. Plan B costs $60/month with unlimited data. At what usage do they cost the same? Plan A: C = 0.10G + 40 (slope 0.10, intercept 40). Plan B: C = 60 (horizontal line, slope 0). Set equal: 0.10G + 40 = 60, so 0.10G = 20, giving G = 200 GB. Below 200 GB, Plan A is cheaper; above 200 GB, Plan B saves money.
Common Mistakes to Avoid
Mistake 1: Reversing the Subtraction Order
Computing (y₁ - y₂) / (x₂ - x₁) instead of (y₂ - y₁) / (x₂ - x₁) flips the sign. For points (2, 3) and (8, 15): wrong calculation gives (3 - 15) / (8 - 2) = -12 / 6 = -2, but correct slope is +2. Always subtract in the same order: second point minus first point for both coordinates. Write it as (y₂ - y₁) / (x₂ - x₁) explicitly to avoid confusion.
Mistake 2: Swapping x and y Coordinates
Using x-values where y-values belong (or vice versa) produces incorrect slopes. For (4, 5) and (10, 17), a student might compute (10 - 4) / (17 - 5) = 6 / 12 = 0.5 instead of (17 - 5) / (10 - 4) = 12 / 6 = 2. Remember: y is vertical (rise), x is horizontal (run). The formula is "change in y over change in x," not the reverse.
Mistake 3: Forgetting Vertical Lines Have Undefined Slope
For points (3, 5) and (3, 12), applying the formula gives (12 - 5) / (3 - 3) = 7 / 0. Division by zero is undefined, not zero. A vertical line has undefined slope, not zero slope. Horizontal lines have slope 0; vertical lines have undefined slope. This distinction matters: zero means flat, undefined means infinitely steep.
Mistake 4: Misidentifying the Y-Intercept
The y-intercept occurs where x = 0, not where y = 0. For y = 2x + 6, the y-intercept is 6 (point (0, 6)), not -3 (point (-3, 0), which is the x-intercept). When finding b from y = mx + b, substitute a point's full coordinates. If the line doesn't cross the y-axis in your graph's visible range, calculate b algebraically—don't estimate from the graph.
Pro Tips for Slope Calculations
Tip 1: Use the Slope Triangle Visual
Draw a right triangle connecting your two points. The vertical leg is the rise; the horizontal leg is the run. Count grid squares if working on graph paper. For points (1, 2) and (5, 10): draw a triangle rising 8 units and running 4 units. Slope = 8/4 = 2. This visual approach catches sign errors—if your triangle goes down as you move right, slope is negative.
Tip 2: Recognize Parallel and Perpendicular Relationships
Parallel lines have identical slopes. If one line has slope 3, any parallel line also has slope 3. Perpendicular lines have slopes that are negative reciprocals: if m₁ = 3, then m₂ = -1/3. The product of perpendicular slopes equals -1. Use this to verify: 3 × (-1/3) = -1 ✓. This shortcut helps find perpendicular line equations without recalculating from points.
Tip 3: Check Slope Reasonableness
Estimate before calculating. For (2, 3) and (10, 19): x increases by 8, y increases by 16, so slope should be about 16/8 = 2. If your calculator shows 0.5 or -2, you've swapped coordinates or reversed subtraction. A slope between 0 and 1 means the line rises less than it runs (gentle incline). Slope greater than 1 means steep rise.
Tip 4: Handle Fractions in Coordinates Carefully
When coordinates include fractions, find a common denominator before subtracting. For (1/2, 3/4) and (5/6, 7/8): convert to twelfths: (6/12, 9/12) and (10/12, 10.5/12). Rise = 10.5/12 - 9/12 = 1.5/12 = 1/8. Run = 10/12 - 6/12 = 4/12 = 1/3. Slope = (1/8) / (1/3) = 3/8. Alternatively, use decimals: 0.375.
Tip 5: Use Point-Slope Form for Integer Arithmetic
When the y-intercept would be a fraction, use point-slope form to avoid messy arithmetic. For slope 2/3 through (5, 7): y - 7 = (2/3)(x - 5). Multiply by 3: 3y - 21 = 2x - 10. Rearrange: 2x - 3y = -11 (standard form with integers). This avoids b = 7 - 10/3 = 11/3, keeping calculations cleaner until the final step.
Frequently Asked Questions
Slope 0 means a horizontal line—y stays constant regardless of x. The equation is y = b (like y = 5). Undefined slope means a vertical line—x stays constant regardless of y. The equation is x = a (like x = 3). Horizontal lines have zero steepness; vertical lines have infinite steepness. Zero is a number; undefined is not a number at all.
Yes, negative slope means the line falls from left to right. As x increases, y decreases. Real-world examples: a car's fuel level over time (negative slope as you drive), demand curves in economics (lower price = higher quantity demanded), or a ball's height after reaching its peak. Negative slope indicates an inverse relationship between variables.
No, the slope is the same either way. For (2, 3) and (8, 15): using first point as (x₁, y₁) gives (15-3)/(8-2) = 12/6 = 2. Using second point as (x₁, y₁) gives (3-15)/(2-8) = -12/-6 = 2. The key is consistency: whichever point you subtract from, use it for both x and y. Mixing orders flips the sign incorrectly.
Rewrite the equation in slope-intercept form y = mx + b. The coefficient of x is the slope. For 3x + 2y = 12: solve for y to get 2y = -3x + 12, then y = (-3/2)x + 6. The slope is -3/2. For vertical lines (x = 5), slope is undefined. For horizontal lines (y = 7), slope is 0. Standard form Ax + By = C has slope -A/B.