{
  "category": "Math and trigonometry functions",
  "display_name": "MUNIT",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.MUNIT",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 13 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 13 recorded answers",
    "workbook_corpus": {
      "cells": 13,
      "matched": 13
    }
  },
  "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#L233-L247"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/math.rs#L233-L247",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 13 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.MUNIT.json",
  "name": "MUNIT",
  "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- **[MMULT](FUNC.MMULT.md)** — the operation `MUNIT` is the unit of. `MMULT(A, MUNIT(n))` should\n  return *A* entry for entry, and because every dot product involved is a sum of exact zeros and\n  one exact copy, **any deviation is a defect rather than a rounding difference**. This makes\n  `MUNIT` the family's calibration standard.\n- **[MINVERSE](FUNC.MINVERSE.md)** — `MMULT(A, MINVERSE(A))` against `MUNIT(n)` is the residual\n  test. Read the caution on the `MINVERSE` page: a small residual does not certify an accurate\n  inverse.\n- **[MDETERM](FUNC.MDETERM.md)** — det(MUNIT(n)) = 1 for every n, an exactness check that costs one\n  cell.\n- **`SEQUENCE`** — the other pure generator in the modern surface. `MUNIT(n)` is expressible as\n  `--(SEQUENCE(n)=TRANSPOSE(SEQUENCE(n)))`, which is worth knowing both as a fallback and as an\n  independent implementation to compare against.\n- **`IDENTITY`** does not exist in Excel; `MUNIT` is the name, and it is easy to miss when\n  searching.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\n`MUNIT` has **no numerical content**. Both 0 and 1 are exactly representable in binary64, there is\nno arithmetic, and there is exactly one correct answer for each input. It cannot lose precision,\ncannot overflow, and admits no algorithmic variation.\n\nThat is precisely what makes it valuable, and it is worth saying why explicitly:\n\n**`MUNIT` is the family's exact anchor.** Every other member has an accumulation order, a pivot\nchoice, or a division that puts its last bits in question. `MUNIT` has none. So in any test of this\nfamily, `MUNIT` is the term that is known to be right, and any discrepancy in a residual\n`MMULT(A, MINVERSE(A)) − MUNIT(n)` is attributable entirely to the other two surfaces. A test\ndesign that instead builds its identity by hand, or by `SEQUENCE` comparison, gives up that\ncertainty for nothing.\n\nThe two genuine engineering considerations are about **size**, not accuracy:\n\n2. **The identity should rarely be materialised at all.** In numerical practice one applies the\n   identity implicitly; forming it and multiplying by it costs O(n³) to achieve nothing. That is a\n   remark about linear-algebra practice (Golub and Van Loan, *Matrix Computations*, chapter 1)\n   rather than about Excel, but a worksheet that computes `MMULT(A, MUNIT(n))` in production is\n   doing the same wasteful thing.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Array` of `Number`.\n\n- **Zero and negative dimensions** produce `#VALUE!`, exactly as documented.\n- **A subnormal positive dimension** produces `#VALUE!` — it truncates to zero, and zero is\n  rejected. Consistent.\n- **The largest finite double** produces `#VALUE!`. A dimension that large cannot be materialised;\n  the rejection is sensible and is not documented.\n- **A logical argument** is **accepted**, producing a 1×1 identity, and **numeric text** is\n  **accepted and truncated**, producing the identity at the truncated size. This is a striking\n  contrast with the rest of the family: [MDETERM](FUNC.MDETERM.md),\n  [MINVERSE](FUNC.MINVERSE.md) and [MMULT](FUNC.MMULT.md) all refuse logicals and numeric text,\n  while `MUNIT` converts them like an ordinary scalar math function. **The four surfaces share one\n  implementation module and do not share one coercion policy.** That is a real finding about the\n  family's internal consistency, and it is worth checking against Excel because there is no\n  documented reason for the split.\n\n\n\n### Errors\n\n\n| Error | Documented condition |\n|---|---|\n| `#VALUE!` | \"If dimension is a value that's equal to or smaller than zero (0), MUNIT returns the #VALUE! error value.\" |\n\nThat is the whole of the documented error surface. Note that it is `#VALUE!` and not `#NUM!`,\nwhich is unusual — a dimension of −1 is a *domain* failure, and `#NUM!` is Excel's conventional\nanswer for those. `MUNIT` uses the kind-failure error for a domain failure, and the documentation\nis explicit about it, so this is one of the rarer cases where the documented behaviour is both\nsurprising and unambiguous.\n\n",
    "sources": "- Microsoft, \"MUNIT function\" —\n  <https://support.microsoft.com/en-us/office/munit-function-c9fe916a-dc26-4105-997d-ba22799853a3>.\n  Retrieved for this page: the syntax, the dimension argument description including \"greater than\n  zero\" and the statement that it returns an array, the `#VALUE!` remark for non-positive\n  dimensions, the 3×3 example, and the dynamic-array versus legacy-array entry mechanics. The page\n  as retrieved says nothing about non-integer dimensions, about a size ceiling, or about array\n  arguments.\n- G. H. Golub and C. F. Van Loan, *Matrix Computations*, 4th edition, chapter 1 — why the identity\n  is applied implicitly rather than formed.\n- Handbook, [MMULT](FUNC.MMULT.md), [MINVERSE](FUNC.MINVERSE.md), [MDETERM](FUNC.MDETERM.md) — the\n  rest of the family and the tests `MUNIT` anchors;\n  [coercion and lifting](../model/02-coercion-and-lifting.md) — the lifting policy the strangest\n  battery row exercises; [the value universe](../model/01-value-universe.md) — the array and\n  publication boundaries.\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`MUNIT(dimension)` returns the **identity matrix** of the given size: the square matrix with ones\non the main diagonal and zeros everywhere else.\n\n    Iₙ = (δᵢⱼ),   δᵢⱼ = 1 if i = j, else 0\n\nδ is the Kronecker delta, and `MUNIT` is simply its tabulation over an n×n grid.\n\nThe identity is the multiplicative unit of the matrix algebra, and every property a reader needs\nfollows from that:\n\n- **AI = IA = A** for every conformable *A*. This is the defining property, and it is the reason\n  `MUNIT` is useful in a worksheet at all.\n- **I⁻¹ = I**, **Iᵀ = I**, **I² = I** — the identity is its own inverse, its own transpose, and\n  idempotent.\n- **det I = 1** (this is the normalisation in the determinant's defining characterisation — see\n  [MDETERM](FUNC.MDETERM.md)), **trace I = n**, and every eigenvalue is 1 with the whole space as\n  eigenspace.\n- Iₙ is the unique matrix with these properties at each size, so `MUNIT` has exactly one correct\n  answer per argument and no implementation freedom whatever.\n\n**Domain and range.** Domain: the positive integers. Range: the identity matrices. This is the\nonly member of the matrix family that is a *generator* rather than an operator — it consumes a\nscalar and produces a grid — which puts it closer in spirit to `SEQUENCE` and `RANDARRAY` than to\nits three siblings.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Required |\n|---|---|---|\n| `dimension` | \"An integer specifying the dimension of the unit matrix that you want to return.\" | Yes |\n\nMicrosoft's page adds two facts in the same sentence: \"It returns an array\" and \"The dimension has\nto be greater than zero.\"\n\nExactly one argument; the declared arity is one to one.\n\n**Result shape and entry.** The result is a *dimension* × *dimension* array. Microsoft's page gives\nthe mechanics: in current Microsoft 365 the formula spills from a single cell; in earlier versions\nthe output range must be selected first and the formula confirmed with Ctrl+Shift+Enter.\n\n\n"
  },
  "signature": {
    "display": "MUNIT(dimension)",
    "parameters": [
      {
        "description": null,
        "name": "dimension",
        "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": "None",
        "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": "Identity matrix of a given size",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the unit matrix or the specified dimension",
        "microsoft_url": "https://support.microsoft.com/en-us/office/munit-function-c9fe916a-dc26-4105-997d-ba22799853a3"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "MUNIT"
        },
        {
          "locale": "bg-BG",
          "name": "MUNIT"
        },
        {
          "locale": "cs-CZ",
          "name": "MUNIT"
        },
        {
          "locale": "da-DK",
          "name": "MENHED"
        },
        {
          "locale": "de-DE",
          "name": "MUNIT"
        },
        {
          "locale": "el-GR",
          "name": "MUNIT"
        },
        {
          "locale": "en-AU",
          "name": "MUNIT"
        },
        {
          "locale": "en-GB",
          "name": "MUNIT"
        },
        {
          "locale": "en-US",
          "name": "MUNIT"
        },
        {
          "locale": "es-ES",
          "name": "M.UNIDAD"
        },
        {
          "locale": "et-EE",
          "name": "MUNIT"
        },
        {
          "locale": "fi-FI",
          "name": "YKSIKKÖM"
        },
        {
          "locale": "fr-FR",
          "name": "MATRICE.UNITAIRE*"
        },
        {
          "locale": "he-IL",
          "name": "MUNIT"
        },
        {
          "locale": "hr-HR",
          "name": "MUNIT"
        },
        {
          "locale": "hu-HU",
          "name": "MMÁTRIX"
        },
        {
          "locale": "id-ID",
          "name": "MUNIT"
        },
        {
          "locale": "it-IT",
          "name": "MUNIT"
        },
        {
          "locale": "ja-JP",
          "name": "MUNIT"
        },
        {
          "locale": "ko-KR",
          "name": "MUNIT"
        },
        {
          "locale": "lt-LT",
          "name": "MUNIT"
        },
        {
          "locale": "lv-LV",
          "name": "MUNIT"
        },
        {
          "locale": "nb-NO",
          "name": "MUNIT"
        },
        {
          "locale": "nl-NL",
          "name": "EENHEIDMAT"
        },
        {
          "locale": "pl-PL",
          "name": "MACIERZ.JEDNOSTKOWA"
        },
        {
          "locale": "pt-BR",
          "name": "MUNIT"
        },
        {
          "locale": "pt-PT",
          "name": "UNIDM"
        },
        {
          "locale": "ro-RO",
          "name": "MUNIT"
        },
        {
          "locale": "ru-RU",
          "name": "МЕДИН"
        },
        {
          "locale": "sk-SK",
          "name": "MUNIT"
        },
        {
          "locale": "sl-SI",
          "name": "MUNIT"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "MUNIT"
        },
        {
          "locale": "sv-SE",
          "name": "MENHET"
        },
        {
          "locale": "th-TH",
          "name": "MUNIT"
        },
        {
          "locale": "tr-TR",
          "name": "BİRİMMATRİS"
        },
        {
          "locale": "uk-UA",
          "name": "MUNIT"
        },
        {
          "locale": "vi-VN",
          "name": "MUNIT"
        },
        {
          "locale": "zh-CN",
          "name": "MUNIT"
        },
        {
          "locale": "zh-HK",
          "name": "MUNIT"
        },
        {
          "locale": "zh-TW",
          "name": "MUNIT"
        }
      ],
      "signature": {
        "display": "MUNIT(dimension)",
        "parameters": [
          {
            "description": null,
            "name": "dimension",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "MUNIT",
      "version_marker": null,
      "xlcall": {
        "code": "582",
        "symbol": "xlfMunit"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/munit-function-c9fe916a-dc26-4105-997d-ba22799853a3"
  },
  "try_it": {
    "formula": "=MUNIT({2,3})"
  },
  "url": "https://handbook.dnacalc.com/functions/MUNIT.html",
  "variants": [],
  "versions": []
}