{
  "id": "slope",
  "version": "45876901b81b",
  "status": "published",
  "name": "Slope Calculator",
  "question": "What is the slope of a line?",
  "summary": "Finds the slope of the line through two points, with its angle, distance, y-intercept and equation, or a missing coordinate from the slope.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/slope-calculator",
  "markdown": "https://www.acalculator.org/math/slope-calculator.md",
  "kind": "formulas",
  "method": "m = (y₂ − y₁) ÷ (x₂ − x₁): the rise between two points divided by the run.",
  "assumptions": [
    "The two points must have different x-coordinates: a vertical line has no slope.",
    "The angle is arctan m, measured from the positive x-axis, between −90° and 90°.",
    "Coordinates are plain numbers from −10¹⁰⁰ to 10¹⁰⁰, in one unit; a coordinate worked out beyond that has no answer."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "x1": {
        "title": "x₁",
        "description": "The x-coordinate of the first point.",
        "type": "number",
        "minimum": -1e+100,
        "maximum": 1e+100
      },
      "y1": {
        "title": "y₁",
        "description": "The y-coordinate of the first point.",
        "type": "number",
        "minimum": -1e+100,
        "maximum": 1e+100
      },
      "x2": {
        "title": "x₂",
        "description": "The x-coordinate of the second point.",
        "type": "number",
        "minimum": -1e+100,
        "maximum": 1e+100
      },
      "y2": {
        "title": "y₂",
        "description": "The y-coordinate of the second point.",
        "type": "number",
        "minimum": -1e+100,
        "maximum": 1e+100
      },
      "m": {
        "title": "Slope (m)",
        "description": "Rise over run: how much y changes for each 1 that x increases.",
        "type": "number"
      }
    }
  },
  "solve": {
    "fillAny": 4,
    "variables": [
      "x1",
      "y1",
      "x2",
      "y2",
      "m"
    ],
    "inputsOnly": []
  },
  "outputs": {
    "x1": {
      "label": "x₁",
      "description": "The x-coordinate of the first point.",
      "format": "number"
    },
    "y1": {
      "label": "y₁",
      "description": "The y-coordinate of the first point.",
      "format": "number"
    },
    "x2": {
      "label": "x₂",
      "description": "The x-coordinate of the second point.",
      "format": "number"
    },
    "y2": {
      "label": "y₂",
      "description": "The y-coordinate of the second point.",
      "format": "number"
    },
    "m": {
      "label": "Slope (m)",
      "description": "Rise over run: how much y changes for each 1 that x increases.",
      "format": "number"
    },
    "equation": {
      "label": "Equation of the line",
      "description": "The line through both points in slope-intercept form, y = mx + b.",
      "format": "text"
    },
    "intercept": {
      "label": "y-intercept (b)",
      "description": "Where the line crosses the y-axis: b = y₁ − m × x₁.",
      "format": "number"
    },
    "angle": {
      "label": "Angle of incline",
      "description": "The angle between the line and the x-axis: arctan m, from −90° to 90°.",
      "format": "quantity",
      "unit": "deg"
    },
    "grade": {
      "label": "Grade",
      "description": "The slope as a percent: m × 100.",
      "format": "percent"
    },
    "rise": {
      "label": "Rise (Δy)",
      "description": "The change in y: y₂ − y₁.",
      "format": "number"
    },
    "run": {
      "label": "Run (Δx)",
      "description": "The change in x: x₂ − x₁.",
      "format": "number"
    },
    "distance": {
      "label": "Distance between the points",
      "description": "The length of the segment: √(Δx² + Δy²).",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "x1": 1,
      "y1": 2,
      "x2": 5,
      "y2": 8
    },
    "outputs": {
      "m": 1.5,
      "equation": "y = 1.5x + 0.5",
      "intercept": 0.5,
      "angle": 0.982793723247329,
      "grade": 150,
      "rise": 6,
      "run": 4,
      "distance": 7.211102550927979
    },
    "text": "The line through (1, 2) and (5, 8) has a slope of 1.5."
  },
  "examples": [
    {
      "given": {
        "x1": 1,
        "y1": 2,
        "x2": 5,
        "y2": 8
      },
      "expect": {
        "m": 1.5,
        "intercept": 0.5,
        "equation": "y = 1.5x + 0.5",
        "angle": 0.982793723247329,
        "grade": 150,
        "rise": 6,
        "run": 4,
        "distance": 7.211102550927978
      },
      "source": "hand calculation in content.mdx: m = (8 − 2) ÷ (5 − 1) = 1.5; Python 3: math.atan(1.5) = 0.982793723247329, math.hypot(4, 6) = 7.211102550927978"
    },
    {
      "given": {
        "x1": -2,
        "y1": 3,
        "x2": 4,
        "y2": -9
      },
      "expect": {
        "m": -2,
        "intercept": -1,
        "equation": "y = -2x - 1",
        "distance": 13.416407864998739
      },
      "source": "hand calculation in content.mdx: m = −12 ÷ 6 = −2, b = 3 − (−2)(−2) = −1; Python 3: math.hypot(6, 12) = 13.416407864998739"
    },
    {
      "given": {
        "x1": 0,
        "y1": 4,
        "x2": 7,
        "y2": 4
      },
      "expect": {
        "m": 0,
        "equation": "y = 4",
        "angle": 0,
        "grade": 0
      },
      "source": "hand calculation in content.mdx: a horizontal line has rise 0, so m = 0"
    },
    {
      "given": {
        "x1": 2,
        "y1": 1,
        "x2": 10,
        "m": 0.75
      },
      "expect": {
        "y2": 7,
        "intercept": -0.5
      },
      "source": "hand calculation in content.mdx: y₂ = 1 + 0.75 × (10 − 2) = 7"
    },
    {
      "given": {
        "x1": 1,
        "y1": 1,
        "y2": 4,
        "m": 1
      },
      "expect": {
        "x2": 4,
        "equation": "y = x",
        "angle": 0.7853981633974483
      },
      "source": "hand calculation in content.mdx: x₂ = 1 + (4 − 1) ÷ 1 = 4; arctan 1 = 45°"
    }
  ],
  "sources": [
    "OpenStax, Elementary Algebra 2e, section 4.4 Understand Slope of a Line: https://openstax.org/books/elementary-algebra-2e/pages/4-4-understand-slope-of-a-line",
    "OpenStax, Elementary Algebra 2e, section 4.5 Use the Slope-Intercept Form of an Equation of a Line: https://openstax.org/books/elementary-algebra-2e/pages/4-5-use-the-slope-intercept-form-of-an-equation-of-a-line"
  ],
  "related": [
    "midpoint",
    "quadratic-formula"
  ],
  "changelog": [
    {
      "date": "2026-09-28",
      "note": "A vertical line says its slope is undefined."
    }
  ]
}
