Line Equation Calculator
Get y = mx + b from two points.
Result
How it is calculated
A straight line through two points (x1, y1) and (x2, y2) is written y = mx + b. The slope is m = (y2 − y1) ÷ (x2 − x1), the rise over the run, and the y-intercept is b = y1 − m × x1. The tool shows the slope, the intercept and the finished equation, each rounded to two decimals. If both points have the same x, the line is vertical, the slope is undefined and the tool returns no result; that line is written x = constant instead.
Worked example
Points (1, 3) and (4, 9). Slope: (9 − 3) ÷ (4 − 1) = 6 ÷ 3 = 2.00. Intercept: 3 − 2 × 1 = 1.00. Equation: y = 2.00x + 1.00. Check with the second point: 2 × 4 + 1 = 9, as required.
Common mistakes
- Subtracting in a different order in numerator and denominator, such as y2 − y1 over x1 − x2. That flips the sign of the slope.
- Swapping x and y in a pair, so the line is mirrored across the diagonal.
- Entering two points with the same x and expecting an equation. Vertical lines have no slope-intercept form.
- Reading the two-decimal rounding as exact. If the slope is 1/3, the printed 0.33 and the intercept are approximations.
Sources
About this calculator
Given two points, this calculator finds the slope (m = (y₂−y₁)/(x₂−x₁)) and then solves for the y-intercept to produce the full line equation in slope-intercept form, y = mx + b. Two points with the same x form a vertical line (undefined slope), which gives no result; a horizontal line simply shows a slope of zero.
It's used by students working through algebra and coordinate geometry homework, and by anyone who needs to fit a quick linear trend line through two data points by hand — for example estimating a rate of change between two measurements without pulling up spreadsheet software.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
When you use the line to estimate a third value, plug in the rounded slope and intercept only for a rough guess, since they are shown to two decimals and the error grows the further you extrapolate. A negative intercept is written with a minus sign, so y = 2.00x − 3.00 means y = 2x minus 3. What kind of two measurements are you joining with a line?