{
  "category": "Math and trigonometry functions",
  "display_name": "MDETERM",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.MDETERM",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 4 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 4 recorded answers",
    "workbook_corpus": {
      "cells": 4,
      "matched": 4
    }
  },
  "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/math.rs#L218-L221",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/matrix_family.rs#L4-L48"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/math::matrix"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/math.rs#L218-L221",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 4 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.MDETERM.json",
  "name": "MDETERM",
  "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- **[MMULT](FUNC.MMULT.md)** — det(AB) = det A · det B gives the cheapest available metamorphic\n  test for all three functions at once, needing no oracle table.\n- **[MUNIT](FUNC.MUNIT.md)** — det(I) = 1, the normalisation in the determinant's defining\n  characterisation.\n- **`SUMPRODUCT`** — for a 2×2 or 3×3 matrix the determinant is a small explicit expression, and\n  writing it out is often *more* accurate than calling `MDETERM`, because it avoids the pivoting\n  and the divisions. Microsoft's own 3×3 formula is the expression to use.\n- **`LINEST`**, **`TREND`**, and the regression family — they solve normal equations whose\n  singularity `MDETERM` is sometimes (wrongly) used to test. See the warning below.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\n### Never compute the determinant by its definition\n\nThe Leibniz sum has n! terms; cofactor expansion is the same cost. For a 10×10 matrix that is over\nthree million products, for 15×15 it is over a trillion. Every practical implementation instead\nfactors the matrix — LU with partial pivoting, O(n³) — and takes\n\n    det A = (−1)^(number of row interchanges) · Π pivots\n\n### The determinant overflows and underflows long before the matrix is remarkable\n\nBecause det scales as cⁿ, a 20×20 matrix with entries of order 100 has a determinant of order\n10⁴⁰, and one with entries of order 0.01 has a determinant of order 10⁻⁴⁰. Overflow and underflow\nare reached at modest sizes with entirely ordinary data. The standard remedy in numerical libraries\nis to return **log|det| and a sign** rather than the determinant itself (LAPACK-based codes and R's\n`determinant()` do this), which stays in range for any matrix the factorisation can handle. Excel\npublishes no such surface, so `MDETERM` inherits the full dynamic-range problem. For a large matrix\n`MDETERM` may return zero, or an overflow condition, for a matrix that is perfectly well\nconditioned.\n\n### The determinant is a bad test for singularity\n\nThis is the single most important practical fact on the page, and it is not in any documentation.\n\n- A matrix can have a **tiny determinant and be perfectly well conditioned**: 0.01·I on 20×20 has\n  a determinant of 10⁻⁴⁰ and a condition number of exactly 1. Nothing is wrong with it.\n- A matrix can have a **determinant of 1 and be catastrophically ill conditioned**: any unimodular\n  matrix with wildly different singular values.\n\nThe determinant is not scale-invariant and does not measure distance to singularity; the condition\nnumber does. The classic statements of this are in Forsythe and Moler, *Computer Solutions of\nLinear Algebraic Systems*, and in Higham, *Accuracy and Stability of Numerical Algorithms*, chapter\n14, both of which say plainly that `det` should not be used to detect near-singularity. A worksheet\nthat tests `IF(MDETERM(A)=0, …)` before calling `MINVERSE` is doing something that looks careful\nand is not.\n\n### Error growth\n\nThe computed determinant from LU with partial pivoting satisfies a backward-error result: it is the\nexact determinant of a nearby matrix. The *forward* error — how far the number is from the true\ndeterminant — is bounded by roughly the condition number times the unit roundoff times n, so it\ngrows with both size and conditioning. For an ill-conditioned matrix the leading digits of\n`MDETERM`'s answer can be wrong, and the documentation's \"approximately 16 digits\" does not warn\nabout it. Higham chapter 14 gives the analysis; Golub and Van Loan, *Matrix Computations*,\nsection 3.2, gives the pivoting theory.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number`.\n\n- **A 1×1 matrix** — a bare scalar — returns that scalar. The determinant of a 1×1 matrix is its\n  single entry, so this is right, and it is also the degenerate case where the matrix machinery\n  disappears entirely.\n- **A logical argument** produces `#VALUE!`, and **numeric text** produces `#VALUE!`. This is the\n  family's distinguishing coercion behaviour: unlike the scalar math functions in this category,\n  which convert logicals and numeric text happily, the matrix family **refuses** them. Microsoft's\n  page documents the refusal for text (\"Any cells in array are empty or contain text\") but says\n  nothing about logicals.\n- **An inline 2×2 array** returns the determinant, and that specific value is one of the four\n  pinned by the structural COM probe recorded in this page's second evidence record.\n- **An empty range** produces `#VALUE!`, consistent with the documented empty-cell rule.\n- **The largest finite double** as a 1×1 matrix is returned unchanged.\n\nThe battery contains **no non-square case**, **no singular case beyond the trivial**, and **no\nmatrix above 2×2**, so it does not exercise the elimination at all.\n\n\n\n### Errors\n\n\n| Error | Documented condition |\n|---|---|\n| `#VALUE!` | \"Any cells in array are empty or contain text.\" |\n| `#VALUE!` | \"Array does not have an equal number of rows and columns.\" |\n\nError values in the array propagate under the shared discipline\n([coercion and lifting](../model/02-coercion-and-lifting.md)); the family declares a reduction\nerror-collapse profile, meaning competing errors inside the grid are folded rather than each\nsurfacing independently.\n\nMicrosoft's page documents **no `#NUM!`** for `MDETERM`. That is worth contrasting with\n[MINVERSE](FUNC.MINVERSE.md), which does document `#NUM!` for a singular matrix — a determinant of\nzero is a perfectly good *answer*, whereas an inverse of a singular matrix does not exist. The\nasymmetry is mathematically correct and is a useful check on any implementation: `MDETERM` should\nnever refuse a well-formed square numeric matrix.\n\n**A note on the accuracy remark.** Microsoft's page states:\n\n> \"MDETERM is calculated with an accuracy of approximately 16 digits, which may lead to a small\n> numeric error when the calculation is not complete.\"\n\nRead carefully, this is not an error bound. \"Approximately 16 digits\" describes binary64 precision\ngenerally, not this function's accuracy on any particular matrix, and \"when the calculation is not\ncomplete\" names no determinable condition. The genuine statement — that the relative error in a\ncomputed determinant is governed by the conditioning of the matrix and can be arbitrarily large —\nis in \"Numerical notes\" below, and is considerably less reassuring than the documentation.\n\n\n",
    "sources": "- Microsoft, \"MDETERM function\" —\n  <https://support.microsoft.com/en-us/office/mdeterm-function-e7bfa857-3834-422b-b871-0ffd03717020>.\n  Retrieved for this page: the syntax, the array argument description, the two `#VALUE!` conditions,\n  the accuracy remark quoted above, the 3×3 cofactor formula, and the worked examples.\n- Handbook evidence record `EV-MISC-0005` — the recorded absence of any numeric `MDETERM`-versus-\n  Excel comparison, the identification of the shared LU elimination as an internals fact, and the\n  prohibition on inheriting `MINVERSE`'s figures.\n- Handbook evidence record `EV-STRUCT-0012` — provisional structural COM probe over the matrix\n  family, pinned values, no count, no named build.\n- G. E. Forsythe and C. B. Moler, *Computer Solutions of Linear Algebraic Systems* — the classic\n  statement that the determinant is not a measure of near-singularity.\n- N. J. Higham, *Accuracy and Stability of Numerical Algorithms*, 2nd edition, chapter 14 — error\n  analysis of LU factorisation and of computed determinants.\n- G. H. Golub and C. F. Van Loan, *Matrix Computations*, 4th edition, section 3.2 — partial\n  pivoting and its stability.\n- Handbook, [MINVERSE](FUNC.MINVERSE.md), [MMULT](FUNC.MMULT.md), [MUNIT](FUNC.MUNIT.md) — the\n  rest of the family; [coercion and lifting](../model/02-coercion-and-lifting.md) — error\n  propagation and the reduction fold.\n\n\n",
    "version-differences": "No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.",
    "what-it-does": "\n`MDETERM(array)` returns the **determinant** of a square matrix.\n\nThe determinant is the unique function of a square matrix that is multilinear in the rows,\nalternating (it changes sign when two rows are swapped, and vanishes when two rows are equal), and\nequal to 1 on the identity. That characterisation determines it completely, and it yields the\nLeibniz formula\n\n    det A = Σ_{σ ∈ Sₙ} sgn(σ) · Π_{i=1..n} a_{i,σ(i)}\n\na sum over all n! permutations. Microsoft's page gives the 3×3 instance of the same thing by\ncofactor expansion:\n\n> `MDETERM(A1:C3) equals A1*(B2*C3-B3*C2) + A2*(B3*C1-B1*C3) + A3*(B1*C2-B2*C1)`\n\n**What it means.** det A is the signed volume scaling factor of the linear map *A*: it multiplies\noriented n-volumes, and its sign records whether orientation is preserved. Hence the two facts\nevery reader needs:\n\n- **det A = 0 exactly when *A* is singular** — the map collapses space, the columns are linearly\n  dependent, no inverse exists.\n- **det(AB) = det A · det B**, and det(Aᵀ) = det A, and det(cA) = cⁿ · det A for an n×n matrix.\n\nFurther properties worth having: det of a triangular matrix is the product of its diagonal; det of\na permutation matrix is its sign; det(A⁻¹) = 1/det A. The last connects this page directly to\n[MINVERSE](FUNC.MINVERSE.md), and the family's shared implementation exploits the same connection\nfrom the other side — the LU factorisation that inverts a matrix also hands you its determinant as\nthe product of the pivots.\n\n**Domain and range.** Domain: square numeric matrices. Range: all reals (any real is the\ndeterminant of some matrix). The function is a polynomial in the entries, hence continuous and\ninfinitely differentiable — there are no poles and no branch cuts. Every difficulty on this page is\nnumerical, not analytic.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Required |\n|---|---|---|\n| `array` | \"A numeric array with an equal number of rows and columns.\" | Yes |\n\nExactly one argument; the declared arity is one to one. The array may be given as a cell range, an\narray constant, or a name.\n\nThe argument preparation profile declared for this function makes references visible to the\nadapter rather than resolving them to values first, which is the shape one expects of a function\nthat consumes a whole grid rather than a scalar.\n\n\n"
  },
  "signature": {
    "display": "MDETERM(array)",
    "parameters": [
      {
        "description": null,
        "name": "array",
        "optional": false,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 1,
        "min": 1
      },
      "category": "Math and trigonometry functions",
      "classification": {
        "arg_preparation_profile": "RefsVisibleInAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "ReductionFold",
        "fec_dependency_profile": "RefOnly",
        "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": "Determinant of a square matrix",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the matrix determinant of an array",
        "microsoft_url": "https://support.microsoft.com/en-us/office/mdeterm-function-e7bfa857-3834-422b-b871-0ffd03717020"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "MDETERM"
        },
        {
          "locale": "bg-BG",
          "name": "MDETERM"
        },
        {
          "locale": "cs-CZ",
          "name": "DETERMINANT"
        },
        {
          "locale": "da-DK",
          "name": "MDETERM"
        },
        {
          "locale": "de-DE",
          "name": "MDETERM"
        },
        {
          "locale": "el-GR",
          "name": "MDETERM"
        },
        {
          "locale": "en-AU",
          "name": "MDETERM"
        },
        {
          "locale": "en-GB",
          "name": "MDETERM"
        },
        {
          "locale": "en-US",
          "name": "MDETERM"
        },
        {
          "locale": "es-ES",
          "name": "MDETERM"
        },
        {
          "locale": "et-EE",
          "name": "MDETERM"
        },
        {
          "locale": "fi-FI",
          "name": "MDETERM"
        },
        {
          "locale": "fr-FR",
          "name": "DETERMAT*"
        },
        {
          "locale": "he-IL",
          "name": "MDETERM"
        },
        {
          "locale": "hr-HR",
          "name": "MDETERM"
        },
        {
          "locale": "hu-HU",
          "name": "MDETERM"
        },
        {
          "locale": "id-ID",
          "name": "MDETERM"
        },
        {
          "locale": "it-IT",
          "name": "MDETERM"
        },
        {
          "locale": "ja-JP",
          "name": "MDETERM"
        },
        {
          "locale": "ko-KR",
          "name": "MDETERM"
        },
        {
          "locale": "lt-LT",
          "name": "MDETERM"
        },
        {
          "locale": "lv-LV",
          "name": "MDETERM"
        },
        {
          "locale": "nb-NO",
          "name": "MDETERM"
        },
        {
          "locale": "nl-NL",
          "name": "DETERMINANTMAT"
        },
        {
          "locale": "pl-PL",
          "name": "WYZNACZNIK.MACIERZY"
        },
        {
          "locale": "pt-BR",
          "name": "MDETERM"
        },
        {
          "locale": "pt-PT",
          "name": "MATRIZ.DETERM"
        },
        {
          "locale": "ro-RO",
          "name": "MDETERM"
        },
        {
          "locale": "ru-RU",
          "name": "МОПРЕД"
        },
        {
          "locale": "sk-SK",
          "name": "MDETERM"
        },
        {
          "locale": "sl-SI",
          "name": "MDETERM"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "MDETERM"
        },
        {
          "locale": "sv-SE",
          "name": "MDETERM"
        },
        {
          "locale": "th-TH",
          "name": "MDETERM"
        },
        {
          "locale": "tr-TR",
          "name": "DETERMİNANT işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "MDETERM"
        },
        {
          "locale": "vi-VN",
          "name": "MDETERM"
        },
        {
          "locale": "zh-CN",
          "name": "MDETERM"
        },
        {
          "locale": "zh-HK",
          "name": "MDETERM"
        },
        {
          "locale": "zh-TW",
          "name": "MDETERM"
        }
      ],
      "signature": {
        "display": "MDETERM(array)",
        "parameters": [
          {
            "description": null,
            "name": "array",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "MDETERM",
      "version_marker": null,
      "xlcall": {
        "code": "163",
        "symbol": "xlfMdeterm"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/mdeterm-function-e7bfa857-3834-422b-b871-0ffd03717020"
  },
  "try_it": {
    "formula": "=MDETERM({1,2;3,4})"
  },
  "url": "https://handbook.dnacalc.com/functions/MDETERM.html",
  "variants": [],
  "versions": []
}