{
  "id": "interpolation",
  "version": "287d45da8d66",
  "status": "published",
  "name": "Interpolation Calculator",
  "question": "What is the linear interpolation?",
  "summary": "Finds a value between (or beyond) two known points by linear interpolation, y = y₁ + (x − x₁)(y₂ − y₁) ÷ (x₂ − x₁), or any one of the six numbers from the other five.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/interpolation-calculator",
  "markdown": "https://www.acalculator.org/math/interpolation-calculator.md",
  "kind": "formulas",
  "method": "y = y₁ + (x − x₁)(y₂ − y₁) ÷ (x₂ − x₁): the straight line through (x₁, y₁) and (x₂, y₂), read at x.",
  "assumptions": [
    "The value changes along a straight line between the two known points (linear interpolation).",
    "An x outside x₁ to x₂ gives an extrapolated value along the same line.",
    "Each number typed is between −10¹² and 10¹².",
    "Solving for any other number uses the same line through the two points that are fully known. There is no answer when those two points share an x value (or, reading x from y, a y value)."
  ],
  "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
      },
      "y": {
        "title": "y",
        "description": "The y value on the line at x: the interpolated value.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      }
    }
  },
  "solve": {
    "fillAny": 5,
    "variables": [
      "x1",
      "y1",
      "x2",
      "y2",
      "x",
      "y"
    ],
    "inputsOnly": []
  },
  "outputs": {
    "x1": {
      "label": "x₁",
      "description": "The x value of the first known point.",
      "format": "number"
    },
    "y1": {
      "label": "y₁",
      "description": "The y value of the first known point.",
      "format": "number"
    },
    "x2": {
      "label": "x₂",
      "description": "The x value of the second known point. It must differ from x₁.",
      "format": "number"
    },
    "y2": {
      "label": "y₂",
      "description": "The y value of the second known point.",
      "format": "number"
    },
    "x": {
      "label": "x",
      "description": "The x value to read the line at.",
      "format": "number"
    },
    "y": {
      "label": "y",
      "description": "The y value on the line at x: the interpolated value.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "x1": 2,
      "y1": 4,
      "x2": 3,
      "y2": 9,
      "x": 2.5
    },
    "outputs": {
      "y": 6.5
    },
    "text": "The line through (2, 4) and (3, 9) passes through (2.5, 6.5)."
  },
  "examples": [
    {
      "given": {
        "x1": 2,
        "y1": 4,
        "x2": 3,
        "y2": 9,
        "x": 2.5
      },
      "expect": {
        "y": 6.5
      },
      "source": "hand calculation in content.mdx: 4 + (2.5 − 2)(9 − 4) ÷ (3 − 2) = 6.5"
    },
    {
      "given": {
        "x1": 2,
        "y1": 4,
        "x2": 3,
        "y2": 9,
        "x": 4
      },
      "expect": {
        "y": 14
      },
      "source": "hand calculation in content.mdx: 4 + (4 − 2) × 5 ÷ 1 = 14 (extrapolation beyond x₂)"
    },
    {
      "given": {
        "x1": 2,
        "y1": 4,
        "x2": 3,
        "y2": 9,
        "y": 6
      },
      "expect": {
        "x": 2.4
      },
      "source": "hand calculation in content.mdx: x = 2 + (6 − 4)(3 − 2) ÷ (9 − 4) = 2.4"
    },
    {
      "given": {
        "x1": -1,
        "y1": 5,
        "x2": 4,
        "y2": -5,
        "x": 0
      },
      "expect": {
        "y": 3
      },
      "source": "hand calculation in content.mdx: 5 + (0 + 1)(−5 − 5) ÷ (4 + 1) = 5 − 2 = 3"
    },
    {
      "given": {
        "x1": 0,
        "y1": 0,
        "x2": 10,
        "x": 4,
        "y": 2
      },
      "expect": {
        "y2": 5
      },
      "source": "hand calculation in content.mdx: the line through (0, 0) and (4, 2) has slope 0.5, so at x = 10, y₂ = 5"
    }
  ],
  "sources": [
    "NIST Digital Library of Mathematical Functions, §3.3(i) Lagrange Interpolation, equation 3.3.1 (the two-point case, n = 1, is the straight line through the two points). https://dlmf.nist.gov/3.3",
    "OpenStax, College Algebra 2e, §2.2 Linear Equations in One Variable (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and the point-slope form y − y₁ = m(x − x₁)). https://openstax.org/books/college-algebra-2e/pages/2-2-linear-equations-in-one-variable"
  ],
  "related": [
    "slope-intercept",
    "midpoint"
  ],
  "changelog": [
    {
      "date": "2026-09-28",
      "note": "y with x₁ = x₂ names the rule."
    }
  ]
}
