To calculate the matrix determinant of a square matrix we can use the MDETERM function in Google Sheets. It’s categorized under the Array functions.
The MDETERM function takes only one argument and that’s the ‘square_matrix’.
From the argument itself, we can understand that the matrix must have the same number of rows as columns (square matrix).
Before going to the syntax as well as formula, let’s understand the basics (calculation explanation) of the matrix determinant of a matrix.
Here are two examples in that the first one is using a 2×2 matrix that is easy to understand.
1 | 2 |
3 | 4 |
The calculation of the matrix determinant of this 2×2 matrix is as below.
=(1*4)-(2*3)=-2
What about a 3×3 matrix (3-row and 3-column array)?
1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | 9 |
In such case the matrix determinant would be calculated as below.
=1*(5*9-8*6)-4*(2*9-8*3)+7*(2*6-5*3)=0
Manually calculating the determinant of a matrix may be tough. So better we can use the MDETERM function in Google Sheets or Excel for this. The usage is the same in these applications.
Syntax and Argument of the MDETERM Function in Google Sheets
Syntax:
MDETERM(square_matrix)
Argument:
square_matrix – A numeric range (array) with equal number of rows and columns.
Example (MDETERM Formula)
=MDETERM(B2:D4)
In the above example, the ‘square_matrix’ has been specified as a cell range. You can specify it as an array constant too. Here is that example.
=MDETERM({1,2,3;4,5,6;7,8,9})
Common Formula Errors in Determinant Calculation
You may happen to see two types of errors in the use of the MDETERM array function in Google Sheets. They are VALUE! error and N/A! error. The latter is not common though.
VALUE! – appears when a cell(s) is blank or text/string in the square matrix.
If this is the case you can solve the error by wrapping the array/range with the N function that would covert the blank cell or string to 0.
=ArrayFormula(MDETERM(n(B2:D4)))
The ArrayFormula function is a must (with the formula) in this type of usage as N is a non-array Google Sheets function.
Another reason for the VALUE! error is the use of a non-square matrix as the argument.
N/A! – If you see this error in the MDETERM function in Google Sheets, it may be because of the use of matrices (multiple arguments). You are only permitted to use one argument in this function.
That’s all about the determinant calculation using MDETERM formula in Google Sheets. Enjoy!