{
  "category": "Statistical functions",
  "display_name": "INTERCEPT",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.INTERCEPT",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20131"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 4,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 4,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 4 in the answer bank and 7 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 11 recorded answers",
    "workbook_corpus": {
      "cells": 7,
      "matched": 7
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/statistics.rs#L374-L376",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/paired_stats_common.rs#L85-L89"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "ported/paired_stats_common::means",
        "ported/paired_stats_common::slope_from_pairs"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/statistics.rs#L374-L376",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 11 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.INTERCEPT.json",
  "name": "INTERCEPT",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n\n- **[SLOPE](FUNC.SLOPE.md)** — the other half of the same fit. The two are computed from the\n  same three centred sums, and evidence record `EV-MISC-0008` names them together for exactly\n  that reason.\n- **[FORECAST.LINEAR](FUNC.FORECAST.LINEAR.md)** and the legacy\n  **[FORECAST](FUNC.FORECAST.md)** — the fitted line evaluated at a chosen `x`. The identity\n  `INTERCEPT(y, x) = FORECAST(0, y, x)` holds mathematically; whether the two surfaces return\n  identical bits is a separate question that requires evidence, and the Handbook has none.\n- **[LINEST](FUNC.LINEST.md)** — the general form. For a single predictor, `LINEST` returns\n  the slope and the intercept together as a two-cell array, with the intercept in the\n  *rightmost* cell. `INTERCEPT` is the scalar convenience wrapper.\n- **[RSQ](FUNC.RSQ.md)**, **[PEARSON](FUNC.PEARSON.md)**, **[STEYX](FUNC.STEYX.md)** — the\n  goodness-of-fit companions built from the same centred sums.\n- **Confused with:** [TREND](FUNC.TREND.md), which returns fitted values rather than\n  coefficients, and with the intercept of a *chart* trendline, which Excel computes on the\n  chart's own plotted series and can therefore disagree with a worksheet `INTERCEPT` over a\n  different range.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\n`INTERCEPT` is the arithmetically trivial member of a numerically delicate family. There are\ntwo distinct hazards and they are usually confused with each other.\n\n**1. Cancellation in the centred sums.** The textbook \"computational\" formulas\n\n    Sxy = Σ xᵢyᵢ − n·x̄·ȳ        Sxx = Σ xᵢ² − n·x̄²\n\nare one-pass and catastrophically unstable: when the data are far from the origin, both terms\nare large and nearly equal, and the difference loses most of its significant digits. The\nclassical remedy is the two-pass centred form `Σ(xᵢ − x̄)(yᵢ − ȳ)`, or a numerically stable\nupdating formula. The reference analysis is Chan, Golub and LeVeque, *Algorithms for\nComputing the Sample Variance: Analysis and Recommendations* (1983), and the error bounds are\nworked in Higham, *Accuracy and Stability of Numerical Algorithms*, chapter 1. The relevant\ndata-dependent quantity is the coefficient of variation of the `x` sample: the naive formula\nloses roughly `log₁₀(1 + x̄²/Sxx)` decimal digits.\n\n**2. Leverage in the intercept itself.** Even with perfectly computed centred sums, `b` is\nrecovered as `ȳ − a·x̄`. If `x̄` is large, an error `δ` in the slope becomes an error `x̄·δ`\nin the intercept, and the subtraction of two large nearly-equal quantities cancels again.\nThis is why the intercept of a regression on calendar years is a far worse-conditioned number\nthan the slope of the same regression, and why standard practice is to centre the predictor\nbefore fitting and add the shift back afterwards. `INTERCEPT` offers no way to do that; the\ncaller must subtract a reference year from the `x` column themselves.\n\nA careful implementation therefore: accumulates the centred sums in one stable pass or two\npasses rather than the one-pass difference form; forms the slope first and the intercept from\nthe centroid identity; and — if it wants the last bits — accumulates the centred products in\nextended precision or with a compensated (Kahan/Neumaier) sum, since the sums are the only\nplace error can enter. Beyond that there is nothing to get wrong: two divisions and a\nmultiply-subtract.\n\nThe published critique literature on Excel's regression surfaces is worth naming here even\nthough it targets [LINEST](FUNC.LINEST.md) rather than `INTERCEPT`: McCullough and Wilson's\nseries *On the accuracy of statistical procedures in Microsoft Excel* used the NIST\nStatistical Reference Datasets (Longley, Filip, Wampler) precisely to expose the\nnormal-equations conditioning problem, and Morten Welinder's work on Gnumeric's statistical\nfunctions documents the same class of defect from the reimplementer's side. Neither says\nanything about `INTERCEPT` specifically, and neither is a Handbook measurement.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number`.\n\n- **Two points.** With `n = 2` and distinct `x`, the fit is exact: the line through the two\n  points, and the residual sum of squares is zero.\n- **A single point.** Degenerate for the same reason: one point has zero `x`-variance.\n- **Error values** in either argument propagate.\n- **Perfectly collinear data** is not an edge case at all; it is the easy case.\n\n\n\n### Errors\n\nAnyone relying on the exact error code for the mismatched-length case should read Microsoft's\npage directly. Nobody has checked any of these against Excel within the Handbook's record.\n\n\n",
    "sources": "- Chan, Golub and LeVeque, *Algorithms for Computing the Sample Variance: Analysis and\n  Recommendations*, The American Statistician 37 (1983) — the stability analysis of the\n  one-pass versus centred forms.\n- Higham, *Accuracy and Stability of Numerical Algorithms*, 2nd ed., chapter 1 — error bounds\n  for summation and for the sample-variance formulas.\n- McCullough and Wilson, *On the accuracy of statistical procedures in Microsoft Excel*\n  (Computational Statistics & Data Analysis, 1999 and successors) — the NIST StRD critique of\n  Excel's regression lane. Named as literature about the family, not as evidence about this\n  surface.\n- Morten Welinder's work on Gnumeric's statistical functions — the reimplementer's record of\n  Excel statistical accuracy problems.\n- Handbook evidence record `EV-MISC-0008` (subjects `FUNC.INTERCEPT`, `FUNC.SLOPE`).\n- Handbook [Coercion and lifting](../model/02-coercion-and-lifting.md) and\n  [The value universe](../model/01-value-universe.md).\n- Handbook projections `data/functions/FUNC.INTERCEPT.json` (arity 2, `xlfIntercept`,\n  `ValuesOnlyPreAdapter`) and `data/presence/FUNC.INTERCEPT.json` (implementing module\n  `intercept_fn.rs`).\n\n",
    "version-differences": "The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 20131 | Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics | 4 |\n\nThe record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.INTERCEPT.json).",
    "what-it-does": "\n`INTERCEPT(known_y's, known_x's)` returns `b` in the ordinary least-squares line\n\n    y = a·x + b\n\nfitted to the paired sample `(x₁, y₁) … (xₙ, yₙ)`.\n\nThe least-squares problem is to minimise the sum of squared vertical residuals\n\n    S(a, b) = Σᵢ ( yᵢ − a·xᵢ − b )²\n\nSetting `∂S/∂a = ∂S/∂b = 0` gives the normal equations, whose solution is\n\n    a = Σᵢ (xᵢ − x̄)(yᵢ − ȳ) / Σᵢ (xᵢ − x̄)²\n    b = ȳ − a·x̄\n\nwith `x̄` and `ȳ` the arithmetic means. `INTERCEPT` returns `b`; [SLOPE](FUNC.SLOPE.md)\nreturns `a`.\n\nTwo structural facts follow directly from that pair of formulas and are worth stating,\nbecause both are load-bearing for the rest of the page:\n\n1. **The fitted line passes through the centroid `(x̄, ȳ)`.** The second formula *is* that\n   statement rearranged. `b` is therefore not an independent quantity: it is `ȳ` shifted by\n   the slope times the horizontal distance from the origin to the centroid.\n2. **`b` is an extrapolation to `x = 0`.** When the `x` data sit far from zero — years like\n   2024, temperatures in kelvin, prices in cents — the intercept is the value of the fitted\n   line at a point that is nowhere near the data. That is a statement about the estimand,\n   not about any implementation, and it is the root of the conditioning problem discussed\n   under Numerical notes.\n\n**Domain.** Defined for `n ≥ 2` paired points with `Σ(xᵢ − x̄)² > 0`, i.e. the `x` values\nare not all equal. The vertical-line case has no least-squares line of the form `y = ax + b`\nand the denominator above is exactly zero. **Range:** any real number.\n\nThe regression is asymmetric in its arguments: `INTERCEPT(y, x)` and `INTERCEPT(x, y)` fit\ndifferent lines, because the criterion minimises vertical, not perpendicular, distance.\nThe first argument is the response.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Admissible values |\n|---|---|---|\n| `known_y's` | The dependent values `y₁ … yₙ` | Array or reference; required |\n| `known_x's` | The independent values `x₁ … xₙ` | Array or reference; required |\n\nThe two arguments must contain the same number of values; pairing is positional. Both slots\nare array/reference slots rather than scalar slots, so the shared range-scan policy applies\nto values reached inside them — see [Coercion and lifting](../model/02-coercion-and-lifting.md).\nWhether a value that is skipped in one argument causes the *corresponding* value in the other\nto be skipped as well — pairwise deletion — is a real question for any regression surface and\nis on the probe list below.\n\n\n"
  },
  "signature": {
    "display": "INTERCEPT(known_ys, known_xs)",
    "parameters": [
      {
        "description": null,
        "name": "known_ys",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "known_xs",
        "optional": false,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 2,
        "min": 2
      },
      "category": "Statistical functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Where the least-squares line through the known points crosses the y-axis",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the intercept of the linear regression line",
        "microsoft_url": "https://support.microsoft.com/en-us/office/intercept-function-2a9b74e2-9d47-4772-b663-3bca70bf63ef"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "INTERCEPT"
        },
        {
          "locale": "bg-BG",
          "name": "INTERCEPT"
        },
        {
          "locale": "cs-CZ",
          "name": "INTERCEPT"
        },
        {
          "locale": "da-DK",
          "name": "SKÆRING"
        },
        {
          "locale": "de-DE",
          "name": "INTERCEPT"
        },
        {
          "locale": "el-GR",
          "name": "INTERCEPT"
        },
        {
          "locale": "en-AU",
          "name": "INTERCEPT"
        },
        {
          "locale": "en-GB",
          "name": "INTERCEPT"
        },
        {
          "locale": "en-US",
          "name": "INTERCEPT"
        },
        {
          "locale": "es-ES",
          "name": "INTERSECCION.EJE"
        },
        {
          "locale": "et-EE",
          "name": "INTERCEPT"
        },
        {
          "locale": "fi-FI",
          "name": "LEIKKAUSPISTE"
        },
        {
          "locale": "fr-FR",
          "name": "ORDONNEE.ORIGINE*"
        },
        {
          "locale": "he-IL",
          "name": "INTERCEPT"
        },
        {
          "locale": "hr-HR",
          "name": "INTERCEPT"
        },
        {
          "locale": "hu-HU",
          "name": "METSZ"
        },
        {
          "locale": "id-ID",
          "name": "INTERCEPT"
        },
        {
          "locale": "it-IT",
          "name": "INTERCEPT"
        },
        {
          "locale": "ja-JP",
          "name": "INTERCEPT"
        },
        {
          "locale": "ko-KR",
          "name": "INTERCEPT"
        },
        {
          "locale": "lt-LT",
          "name": "INTERCEPT"
        },
        {
          "locale": "lv-LV",
          "name": "INTERCEPT"
        },
        {
          "locale": "nb-NO",
          "name": "SKJÆRINGSPUNKT"
        },
        {
          "locale": "nl-NL",
          "name": "SNIJPUNT"
        },
        {
          "locale": "pl-PL",
          "name": "ODCIĘTA"
        },
        {
          "locale": "pt-BR",
          "name": "INTERCEPT"
        },
        {
          "locale": "pt-PT",
          "name": "INTERCETAR"
        },
        {
          "locale": "ro-RO",
          "name": "INTERCEPT"
        },
        {
          "locale": "ru-RU",
          "name": "ОТРЕЗОК"
        },
        {
          "locale": "sk-SK",
          "name": "INTERCEPT"
        },
        {
          "locale": "sl-SI",
          "name": "INTERCEPT"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "INTERCEPT"
        },
        {
          "locale": "sv-SE",
          "name": "SKÄRNINGSPUNKT"
        },
        {
          "locale": "th-TH",
          "name": "INTERCEPT"
        },
        {
          "locale": "tr-TR",
          "name": "KESMENOKTASI işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "INTERCEPT"
        },
        {
          "locale": "vi-VN",
          "name": "INTERCEPT"
        },
        {
          "locale": "zh-CN",
          "name": "INTERCEPT"
        },
        {
          "locale": "zh-HK",
          "name": "INTERCEPT"
        },
        {
          "locale": "zh-TW",
          "name": "INTERCEPT"
        }
      ],
      "signature": {
        "display": "INTERCEPT(known_ys, known_xs)",
        "parameters": [
          {
            "description": null,
            "name": "known_ys",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "known_xs",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "INTERCEPT",
      "version_marker": null,
      "xlcall": {
        "code": "311",
        "symbol": "xlfIntercept"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/intercept-function-2a9b74e2-9d47-4772-b663-3bca70bf63ef"
  },
  "try_it": {
    "formula": "=INTERCEPT({3;5;7},{1;2;3})"
  },
  "url": "https://handbook.dnacalc.com/functions/INTERCEPT.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "4 captured inputs are indexed for this environment. Capture dates: 2026-07-12 to 2026-07-12. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20131",
      "platform": "Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.INTERCEPT.json"
      ]
    }
  ]
}