Matrix Multiplication and Inversion in LibreOffice Calc
LibreOffice Calc includes powerful built-in functions designed for
linear algebra operations, specifically MMULT for
multiplying matrices and MINVERSE for inverting square
matrices. Because matrix operations produce results spanning multiple
cells, both functions operate as array formulas, requiring specific
input dimensions and execution methods to return accurate mathematical
outputs.
Matrix Multiplication: MMULT
The MMULT function calculates the matrix product of two
arrays. For multiplication to be valid, the number of columns in the
first matrix must equal the number of rows in the second matrix.
- Syntax:
=MMULT(Array1; Array2) - Array1: The first matrix (range of cells).
- Array2: The second matrix (range of cells).
How to Use MMULT:
- Identify the dimensions of the result. If Matrix A is \(m \times k\) and Matrix B is \(k \times n\), the resulting matrix will be \(m \times n\).
- Select an empty range of cells matching the \(m \times n\) output dimensions.
- Type the formula referencing your two ranges, for example:
=MMULT(A1:B3; D1:E2). - Press Ctrl + Shift + Enter to apply the formula as
an array function. LibreOffice Calc will enclose the formula in curly
braces
{}and populate the selected range.
Matrix Inversion: MINVERSE
The MINVERSE function computes the inverse of a given
matrix. The target matrix must be a square matrix (equal number of rows
and columns) and must have a non-zero determinant (non-singular).
- Syntax:
=MINVERSE(Array) - Array: The square matrix range to invert.
How to Use MINVERSE:
- Determine the size of the square matrix (e.g., \(n \times n\)).
- Select an empty destination range of the exact same size (\(n \times n\)).
- Enter the formula referencing the source matrix, for example:
=MINVERSE(A1:C3). - Press Ctrl + Shift + Enter to evaluate the array formula.
Essential Rules and Error Handling
- Array Execution: Always use Ctrl + Shift + Enter instead of standard Enter. Standard entry will only display the first scalar value of the result array in a single cell.
- #VALUE! Error: Occurs if Matrix A’s column count
does not match Matrix B’s row count in
MMULT, or if any cell within the referenced matrices contains text instead of numbers. - #NUM! Error: Occurs in
MINVERSEif the matrix is singular (its determinant is zero) and therefore mathematically cannot be inverted.