MUNIT Function (Gnumeric)
Create identity matrices with Gnumeric MUNIT, enter the full array result and check fractional dimensions, size guards and neutral transformations.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: =MUNIT(3) returns the 3-by-3 identity matrix: ones on the main diagonal and zeroes elsewhere. It is an array result, so reserve a three-row, three-column output range.
Availability and evidence
- Introduction: Gnumeric 1.9.11: NEWS explicitly names MUNIT among the added functions. The size guards described below are from 1.12.62, not an assertion about every earlier release.
- Source support: Registered in the Gnumeric 1.12.62 plugin. No retirement is established. The last functioning application version is unverified for this guide.
- Evidence dates: Official 1.12.62 source was retained October 13–14, 2026 and reviewed October 15. Exact string and rational-matrix reference checks are independent calculations, not native Gnumeric, headless application or GUI execution.
Syntax and dimension rules
=MUNIT(n)
The single required numeric argument specifies the dimension of a square identity matrix. There is no default size and no second argument. For a positive accepted input, the callback casts n to an integer after validating the original numeric value. Thus 2.9 produces a 2-by-2 matrix, while 0.9 fails the lower-bound guard rather than becoming an empty matrix.
In the examined 1.12.62 source, n below 1, n above 5000, or n*n greater than or equal to G_MAXINT produces #NUM!. The upper guards are implementation protection, not a recommendation to create a large matrix. Because validation precedes truncation, 5000.1 is rejected; it is not first reduced to 5000. No large allocation was performed for this guide.
The constructor creates a zero-filled array and the callback replaces each diagonal element with one. The result is the identity matrix, not a matrix containing ones everywhere. In mathematical terminology the identity is unitary, but most unitary matrices are not identity matrices; MUNIT constructs this specific one.
Reproducible three-by-three worksheet
Create Identity and select A2:C4. Enter =MUNIT(3) using the array-entry procedure in the pinned Gnumeric manual: select the whole output range, type the formula, and confirm with Ctrl+Shift+Enter. This is a documented workflow, not a freshly observed GUI interaction. Do not assume another spreadsheet’s automatic-spill behavior.
The independently expected cells are:
| Row | A | B | C |
|---|---|---|---|
| 2 | 1 | 0 | 0 |
| 3 | 0 | 1 | 0 |
| 4 | 0 | 0 | 1 |
For a changed-size control, create a separate 2-by-2 output range E2:F3 and enter =MUNIT(2). Its rows are 1,0 and 0,1. Changing the input changes the required array shape; prepare the corresponding output range rather than assuming the old region resizes itself.
Size and boundary controls
| Control | Independent reference result |
|---|---|
=MUNIT(1) |
[1] |
=MUNIT(2) |
[1,0; 0,1] |
=MUNIT(3) |
[1,0,0; 0,1,0; 0,0,1] |
=MUNIT(2.9) |
[1,0; 0,1] |
=MUNIT(0.9) |
#NUM! |
=MUNIT(0) |
#NUM! |
=MUNIT(-1) |
#NUM! |
=MUNIT(5000.1) |
#NUM! |
=MUNIT(5001) |
#NUM! |
The rejected large sizes are verified by reading the guards only. The small matrix contents are exact mathematical references. The output contains n*n cells for integer n; doubling a dimension quadruples its cell count. Keep practical arrays small unless the workbook and available resources justify more.
Advanced: verify a neutral transformation
On NeutralCheck, enter this numeric 2-by-2 matrix in A2:B3: first row 2,3, second row 5,7. Select D2:E3 and enter =MMULT(A2:B3,MUNIT(2)) as an array formula. The reference result is the original matrix, 2,3;5,7. Repeat in G2:H3 with =MMULT(MUNIT(2),A2:B3); left multiplication by the correctly sized identity also preserves it.
For the first result’s top-left cell, the calculation is 21+30=2. Its top-right cell is 20+31=3. This exposes what identity multiplication actually does rather than relying only on the matrix name.
In a copy change B2 from 3 to 4. Both products become 2,4;5,7. If the unchanged baseline appears instead, check the referenced source range and recalculation before investigating rounding. If you replace MUNIT(2) with MUNIT(3), the inner dimensions no longer match and the multiplication returns #VALUE!.
Advanced: distinguish identity, scaling and a diagonal adjustment
For a scalar control, multiplying the 2-by-2 identity by 3 gives the diagonal matrix 3,0;0,3. As an array expression, =3*MUNIT(2) describes that transformation. Its product with the original A matrix gives 6,9;15,21, so it scales every component by three rather than leaving the input unchanged.
An additive diagonal adjustment is different. The array expression =A2:B3+2*MUNIT(2) gives 4,3;5,9 for the original matrix. Only the diagonal increases. This pattern can be useful when inspecting a model with a separately justified diagonal penalty, but the function does not choose that penalty or guarantee a well-conditioned inverse.
Errors and practical checks
A source error in the required numeric argument propagates through the function dispatcher. Prefer an explicit numeric size rather than locale-sensitive numeric text. Negative and zero sizes are invalid; positive fractional sizes are truncated only after passing the guards. Do not rely on the precise memory failure behavior of a technically permitted huge array.
When only one value appears, check array entry and selected output dimensions first. When a multiplication fails, compare the matrix’s column count with the identity’s row count. When the output has unexpected nonzero off-diagonal values, verify that the displayed range belongs to this formula rather than to an adjacent calculation.
No native rendering, large-allocation benchmark, export behavior or floating-point backend was exercised. The 0/1 matrices and small arithmetic controls are exact reference calculations.