Linear algebra and system modelling frequently require computing matrix determinants and matrix inverses. Google Sheets provides two specialised mathematical functions for these exact operations: MDETERM and MINVERSE. While MDETERM calculates the scalar determinant of a given square matrix, MINVERSE computes the multiplicative inverse matrix, which is indispensable for solving simultaneous linear equations using matrix multiplication (MMULT).
Understanding Matrix Inverses and Determinants in Spreadsheets
Before implementing these functions, it is essential to understand the structural prerequisites of matrix mathematics within Google Sheets:
- Square Matrix Requirement: Both
MDETERMandMINVERSEstrictly require a square matrix, meaning the selected range must possess an equal number of rows and columns (such as 2×2, 3×3, or 4×4). Supplying a rectangular array (such as 2×3) triggers an immediate#VALUE!error. - Singular Matrices: A matrix whose determinant equals zero is defined as a singular (or degenerate) matrix. Singular matrices cannot be inverted. If you attempt to evaluate
MINVERSEon a matrix with a determinant of zero, Google Sheets returns a#NUM!calculation error. - Dynamic Array Spilling: Unlike legacy Excel versions that required manual array formulas (Ctrl+Shift+Enter), Google Sheets automatically spills the full inverse matrix across neighbouring empty cells.
Syntax and Argument Structure
The syntax for both functions is straightforward, accepting a single array or contiguous cell range:
=MDETERM(square_matrix)
=MINVERSE(square_matrix)
| Parameter | Type | Description | Validation Requirement |
|---|---|---|---|
square_matrix |
Range / Array | The cell range or array literal containing numerical entries. | Must be an N×N range containing exclusively numeric values. |
How to Calculate Matrix Determinants with MDETERM
Calculating the determinant provides vital insight into whether a system of linear equations has a unique solution. Follow these steps to compute the determinant of a 3×3 coefficient matrix:
- Open your spreadsheet in Google Sheets and populate your numeric matrix in cells A1:C3. For example:
- Row 1 (A1:C1):
4, 2, 1 - Row 2 (A2:C2):
3, 5, 2 - Row 3 (A3:C3):
1, 2, 6
- Row 1 (A1:C1):
- Select an empty target cell, such as E1.
- Enter the formula:
=MDETERM(A1:C3) - Press Enter. Google Sheets instantly evaluates the algebraic product and difference of minors, displaying the scalar determinant result.
How to Calculate the Inverse Matrix with MINVERSE
Once you confirm that the determinant is non-zero (proving the matrix is non-singular), you can safely calculate its inverse:
- Ensure there is an unoccupied range matching the dimensions of your source matrix (e.g., a clear 3×3 block starting at cell E3). If neighbouring cells contain text or formulas, the formula will generate a
#REF!spill collision error. - Click in cell E3.
- Type the inverse formula:
=MINVERSE(A1:C3) - Press Enter. The inverse matrix instantly populates across the 3×3 area from E3 to G5.
Solving Systems of Linear Equations Using MINVERSE and MMULT
The primary real-world application of MINVERSE is solving a system of simultaneous equations represented in matrix form as A · X = B, where A is the coefficient matrix, X is the column vector of unknown variables, and B is the vector of constants. Algebraically, the solution is obtained by X = A⁻¹ · B.
To execute this solution directly in Google Sheets:
- Enter the coefficient matrix in A1:C3.
- Enter the constants column vector in D1:D3 (e.g.,
14, 23, 20). - In cell F1, enter the combined formula using
MMULT:=MMULT(MINVERSE(A1:C3), D1:D3) - Press Enter. Google Sheets returns a 3×1 column vector containing the exact algebraic solutions for all three variables simultaneously.
Troubleshooting Common MDETERM and MINVERSE Errors
| Error Code | Root Cause | Resolution Strategy |
|---|---|---|
#VALUE! |
The source matrix is non-square (unequal rows and columns) or contains text labels. | Confirm that the range dimensions match exactly (e.g., 3 rows by 3 columns) and verify that all cells contain purely numeric values. |
#NUM! |
The matrix determinant is zero, meaning the matrix is singular and cannot be inverted. | Check whether any row is a direct linear multiple of another row. Such matrices cannot yield a mathematical inverse. |
#REF! |
The output array cannot spill because existing data occupies adjacent destination cells. | Clear all cells below and to the right of your formula to provide sufficient empty space for the array output. |