{
  "id": "linear-interpolation",
  "version": "db7712478701",
  "status": "published",
  "name": "Linear Interpolation Calculator",
  "question": "What is the linear interpolation at x?",
  "summary": "Finds y at x on the straight line through two points, y = y₁ + (x − x₁)(y₂ − y₁) ÷ (x₂ − x₁), with the slope and every step.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/linear-interpolation-calculator",
  "markdown": "https://www.acalculator.org/math/linear-interpolation-calculator.md",
  "kind": "function",
  "method": "m = (y₂ − y₁) ÷ (x₂ − x₁); y = y₁ + m (x − x₁). Worked in exact fractions of the typed decimals, rounded once.",
  "assumptions": [
    "The value changes along a straight line between the two known points.",
    "An x outside x₁ to x₂ gives an extrapolated value along the same line.",
    "Each number is from −10¹² to 10¹². x₁ and x₂ must differ."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "x1": {
        "title": "x₁",
        "description": "The x value of the first known point.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "y1": {
        "title": "y₁",
        "description": "The y value of the first known point.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "x2": {
        "title": "x₂",
        "description": "The x value of the second known point. It must differ from x₁.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "y2": {
        "title": "y₂",
        "description": "The y value of the second known point.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "x": {
        "title": "x",
        "description": "The x value to read the line at.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      }
    }
  },
  "outputs": {
    "y": {
      "label": "y at x",
      "description": "The value on the line at x: the interpolated value.",
      "format": "number"
    },
    "slope": {
      "label": "Slope m",
      "description": "The rise per unit of x: (y₂ − y₁) ÷ (x₂ − x₁).",
      "format": "number"
    },
    "share": {
      "label": "Position t",
      "description": "How far x is from x₁ toward x₂: (x − x₁) ÷ (x₂ − x₁). 0 at x₁, 1 at x₂.",
      "format": "number"
    },
    "kind": {
      "label": "Interpolation or extrapolation",
      "description": "Interpolation when x is from x₁ to x₂; extrapolation when it is outside.",
      "format": "text"
    },
    "steps": {
      "label": "Steps",
      "description": "The slope, then y read from the first point.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "x1": 2,
      "y1": 4,
      "x2": 3,
      "y2": 9,
      "x": 2.5
    },
    "outputs": {
      "y": 6.5,
      "slope": 5,
      "share": 0.5,
      "kind": "Interpolation: x is between x₁ and x₂",
      "steps": "m = (y₂ − y₁) ÷ (x₂ − x₁) = (9 − 4) ÷ (3 − 2) = 5; y = y₁ + m × (x − x₁) = 4 + 5 × (2.5 − 2) = 6.5"
    },
    "text": "The line through (2, 4) and (3, 9) gives y = 6.5 at x = 2.5."
  },
  "examples": [
    {
      "given": {
        "x1": 2,
        "y1": 4,
        "x2": 3,
        "y2": 9,
        "x": 2.5
      },
      "expect": {
        "y": 6.5,
        "slope": 5,
        "share": 0.5,
        "kind": "Interpolation: x is between x₁ and x₂"
      },
      "source": "hand calculation in content.mdx: 4 + (2.5 − 2)(9 − 4) ÷ (3 − 2) = 6.5; OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and point-slope form y − y₁ = m(x − x₁)), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions"
    },
    {
      "given": {
        "x1": 2,
        "y1": 4,
        "x2": 3,
        "y2": 9,
        "x": 4
      },
      "expect": {
        "y": 14,
        "share": 2,
        "kind": "Extrapolation: x is outside x₁ to x₂"
      },
      "source": "hand calculation in content.mdx: 4 + (4 − 2) × 5 = 14, beyond x₂; OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and point-slope form y − y₁ = m(x − x₁)), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions"
    },
    {
      "given": {
        "x1": 0.1,
        "y1": 0.2,
        "x2": 0.3,
        "y2": 0.4,
        "x": 0.2
      },
      "expect": {
        "y": 0.3,
        "slope": 1,
        "share": 0.5
      },
      "source": "hand calculation in content.mdx: m = 0.2 ÷ 0.2 = 1, y = 0.2 + 1 × 0.1 = 0.3 exactly; OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and point-slope form y − y₁ = m(x − x₁)), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions"
    },
    {
      "given": {
        "x1": 20,
        "y1": 2.339,
        "x2": 25,
        "y2": 3.169,
        "x": 22
      },
      "expect": {
        "y": 2.671,
        "slope": 0.166,
        "share": 0.4
      },
      "source": "hand calculation in content.mdx: m = (3.169 − 2.339) ÷ 5 = 0.166, y = 2.339 + 0.166 × 2 = 2.671; OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and point-slope form y − y₁ = m(x − x₁)), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions"
    },
    {
      "given": {
        "x1": -1,
        "y1": 5,
        "x2": 4,
        "y2": -5,
        "x": 0
      },
      "expect": {
        "y": 3,
        "slope": -2
      },
      "source": "hand calculation in content.mdx: m = −10 ÷ 5 = −2, y = 5 − 2 × 1 = 3; OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and point-slope form y − y₁ = m(x − x₁)), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions"
    }
  ],
  "sources": [
    "OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁); point-slope form y − y₁ = m(x − x₁)). https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions (retrieved 2026-10-01)",
    "NIST Digital Library of Mathematical Functions, §3.3(i) Lagrange Interpolation, equation 3.3.1 (the two-point case is the straight line through the two points). https://dlmf.nist.gov/3.3 (retrieved 2026-10-01)"
  ],
  "related": [
    "slope",
    "slope-intercept",
    "midpoint"
  ],
  "changelog": []
}
