MUNIT Function in LibreOffice Calc — Tested Examples
Create a full identity matrix with LibreOffice MUNIT. Enter a 3-by-3 array, check dimension limits and reproduce matrix-multiplication identities.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: MUNIT(n) builds an n-by-n identity matrix. Select the full square destination and confirm an array formula to display every entry.
Availability and version history
- Introduced: Documented by LibreOffice 26.8.1.1; original introduction not established.
- Availability: Supported in LibreOffice 26.8.1.1, verified against its function registry. This identifies a supported release, not a final working version.
- Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
- Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.
Returns the unitary square array of a certain size. An identity matrix has ones on the diagonal and zeros everywhere else. The two INDEX expressions inspect specific cells of MUNIT output.
Syntax and arguments
=MUNIT(Dimensions)
LibreOffice Calc formulas generally separate arguments with semicolons (;).
| Argument | Explanation |
|---|---|
Dimensions |
The size of the unitary array. |
Worked examples
Full array output: MUNIT uses an appropriately sized array-formula output range, as shown in the full 3-by-3 example below. The two earlier examples immediately below return scalar results that were tested directly.
Example 1: Return the center diagonal value of an identity matrix
=INDEX(MUNIT(3);2;2)
Expected result: 1. This value was returned in the LibreOffice Calc 25.2 test.
Example 2: Off-diagonal cells of an identity matrix are zero
=INDEX(MUNIT(2);1;2)
Expected result: 0. This value was returned in the LibreOffice Calc 25.2 test.
How to interpret the result
An identity matrix has ones on the diagonal and zeros everywhere else. The two INDEX expressions inspect specific cells of MUNIT output.
Mistakes and troubleshooting
- Check inputs and assumptions: To display the whole matrix instead of one selected element, use a properly sized array-formula output range.
- Check argument order and format: Strings go in quotes, cell references do not. Functions that return arrays may require special entry.
- Verify your own data: Reproduce the example first. If your formula returns an error, inspect the referenced cells and individual argument values.
Additional worked application and edge cases
One dimension specifies both rows and columns
Dimensions is the single required input. A dimension of n requests an n-by-n identity matrix: entries are one where row and column numbers match and zero elsewhere. It is not an all-ones matrix, a unit conversion function or a request for an arbitrary unitary matrix.
Use a positive whole number for a deliberate matrix size. The pinned implementation converts the input to an unsigned integer and rejects a resulting zero dimension. For example, 3.9 is converted to dimension 3, while 0.9 becomes zero and is rejected. Zero and negative integer dimensions are invalid. Use intentional integers rather than relying on truncation near boundaries.
Stepwise example: place all nine entries
- Make sure B2:D4 is empty and available.
- Select the entire B2:D4 range, three rows and three columns.
- Enter
=MUNIT(3). - Confirm as an array formula with Ctrl+Shift+Enter on Windows/Linux or Command+Shift+Enter on macOS. Alternatively use the Function Wizard with its Array checkbox selected.
The independently expected output is:
| Output row | B | C | D |
|---|---|---|---|
| 2 | 1 | 0 | 0 |
| 3 | 0 | 1 | 0 |
| 4 | 0 | 0 | 1 |
The diagonal runs from B2 through C3 to D4. Let Calc add any array-formula braces; do not type braces yourself. This workflow follows the documented selected-range array entry and does not assume another application’s automatic spill behavior.
Advanced application: preserve a matrix under multiplication
Enter a separate 2-by-3 matrix in F2:H3 with first row 1, 2, 3 and second row 4, 5, 6. Select J2:L3 and array-enter:
=MMULT(F2:H3;MUNIT(3))
The expected output is the same two rows 1, 2, 3 and 4, 5, 6. A 3-by-3 identity works on the right because the input has three columns. Each output cell selects the matching original column through a dot product with one identity column.
For left multiplication, select J6:L7 and array-enter =MMULT(MUNIT(2);F2:H3). The expected output is again unchanged. This time the identity has dimension 2 because the input has two rows. Using MUNIT(2) on the right of this 2-by-3 input would create incompatible inner dimensions; an identity matrix must have the correct size for its position.
Additional independent checks
=MDETERM(MUNIT(3)) has mathematical result 1, and =SUM(MUNIT(3)) has result 3. The determinant check does not depend on adding all entries; the sum equals three because exactly three diagonal entries are one. These are additional expectations, not extensions of the two historical native-tested INDEX examples above.
Array editing and size limits
Select and edit the whole output array if Calc prevents changing one member cell. Choosing a dimension of four does not automatically make a previously selected 3-by-3 destination show all sixteen entries. Resize or recreate the array output deliberately and keep it clear of its own inputs.
The implementation checks whether the square matrix can be allocated. Memory, matrix-size limits and worksheet placement can constrain large requests; this guide does not promise a universal maximum dimension. The number of entries grows as n squared, so doubling n quadruples the matrix size. Start with small verified dimensions before using a large model.
Troubleshooting and evidence
If only one value appears, check array entry and the selected output size. If MMULT errors, verify both input dimensions and ensure the example’s source cells are numeric. Text labels should remain outside that numeric multiplication range. A nonnumeric dimension or an upstream error is not repaired by selecting a bigger destination.
The dimension conversion, zero rejection and diagonal construction are visible in ScEMat and MEMat in the versioned Calc source, with integer conversion in interpr4.cxx. These checks establish source behavior rather than a new native execution.
Verification scope for this addition: These added results were independently calculated or derived from the cited documentation/source. They were not newly tested in LibreOffice Calc. The original example-specific Calc 25.2.3.2 claims elsewhere on this page remain historical and apply only to those original examples. The cited 26.8.1.1 source tag is a code reference, not a claim of a new run in that release.
Related functions
Tested version and primary reference
2 example(s) on this page passed real calculations in LibreOffice Calc 25.2.3.2. This is not a claim about every possible input or other spreadsheet applications.