Contact

MUNIT in Google Sheets: Build and Check an Identity Matrix

Math Intermediate Google Sheets

Create Sheets identity matrices with explicit output dimensions, matrix multiplication controls and documented dimension errors.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: MUNIT returns a square identity matrix. =MUNIT(3) has a 3×3 output with ones down the main diagonal and zeros elsewhere. It takes a dimension, not a matrix to invert or a table to summarize.

Availability and version history

  • Introduced: first service launch date is not established by the official history reviewed; no numbered desktop introduction is assigned.
  • Availability: documented in the rolling Google Sheets service. Examples target ordinary web-spreadsheet cells; mobile clients and imported file modes are not separately certified.
  • Checked: October 14, 2026; official MUNIT reference. Documentation and independently calculated examples, without native Sheets execution.

Syntax and dimensions

=MUNIT(dimension)

Google requires an integer dimension greater than zero and documents #VALUE! when the dimension is less than one. The result is an array whose row and column counts both equal the dimension.

Use a clear output area with enough rows and columns. The examples use ordinary Sheets web formulas; they do not import a desktop spreadsheet’s legacy array-entry shortcut or certify every mobile/imported-file workflow.

Example 1: create a three-by-three identity

Enter =MUNIT(3) in A2, with A2:C4 available for the result. The following labels identify output columns; they are explanatory and are not an extra generated row:

A B C
1 0 0
0 1 0
0 0 1

There are nine output cells, including three ones and six zeros. The main diagonal runs from the upper-left to the lower-right corner. This is not a column of three ones or a row of three values.

A useful numeric control is =SUM(A2:C4), whose expected result is 3 once the matrix occupies that range. A total of three alone does not prove every entry is in the correct position, so inspect the diagonal too.

Example 2: compare small dimensions

=MUNIT(1) returns the single value 1. =MUNIT(2) returns two rows 1,0 and 0,1. A dimension of four requests 16 cells, including four ones and 12 zeros.

The number of cells grows as dimension squared, while the number of diagonal ones grows as dimension. Increasing the dimension from two to four therefore quadruples the output area rather than merely doubling it.

Keep each example in a separate clear location. Placing a larger output over a previous matrix or other data is a placement problem, not evidence that an identity matrix has a different definition.

Advanced example: preserve a numeric matrix by multiplication

Enter H2:I3 as follows:

H I
2 5
-1 4

In separate clear output areas, use:

=MMULT(H2:I3,MUNIT(2))
=MMULT(MUNIT(2),H2:I3)

Both independently expected arrays reproduce the original rows 2,5 and -1,4. MUNIT(2) supplies an identity compatible with the two-by-two source matrix.

Google documents MMULT as matrix multiplication, with the first matrix column count matching the second matrix row count. Each diagonal one preserves a corresponding contribution, while the off-diagonal zeros remove the other cross terms. This is different from ordinary cell-by-cell multiplication of two arrays.

Advanced example: use different identity sizes for a rectangle

Enter K2:M3 with rows 2,5,7 and -1,4,6. This matrix has two rows and three columns.

=MMULT(MUNIT(2),K2:M3)
=MMULT(K2:M3,MUNIT(3))

Both expected outputs preserve the same two-by-three source. The left identity size matches the source row count; the right identity size matches the source column count. Interchanging those sizes would not satisfy the intended matrix-product dimensions.

This control explains why identity size is determined by the side of multiplication, rather than by choosing whichever dimension appears largest.

Advanced example: scale the diagonal

=ARRAYFORMULA(2*MUNIT(3))

ARRAYFORMULA makes the elementwise scaling explicit. The expected array has diagonal 2,2,2 and zeros elsewhere. This is a scaled identity, not the original identity. Multiplying a compatible source matrix by it doubles every entry.

For H2:I3, =MMULT(H2:I3,ARRAYFORMULA(2*MUNIT(2))) has expected rows 4,10 and -2,8. By contrast, =MMULT(MUNIT(3),MUNIT(3)) has the same expected three-by-three identity as the original MUNIT(3).

Errors and verification boundaries

=MUNIT(0) and =MUNIT(-2) have the vendor-documented expected error #VALUE!. Supply a genuine positive integer; the current page does not establish every fractional/text conversion behavior or a maximum practical matrix size.

When the displayed array looks incomplete, check the requested shape and the output cells before changing the formula. This article does not promise a particular native obstruction error code, universal array-entry behavior or extreme-size performance. All matrix products above were independently computed from explicit finite inputs.

For inspecting output dimensions, see ROWS and COLUMNS. A dimension check and an entry-by-entry check answer different questions.

References and verification

Inputs are fictional. Approximate answers are independent mathematical expectations rounded to nine places, not captured native results. Complete type/error matrices, extreme-magnitude accuracy and cross-client behavior remain untested.