Post History
Sandbox
Compute the determinant
#4: Post edited
- ## Challenge
- A simple challenge: Given a two-dimensional matrix (an array of arrays) of real numbers, compute the determinant.
- The determinant of a matrix is a mathematical construct used in many applications, such as solving polynomial equations, identifying the invertibility of the matrix, and finding the scaling factor under a matrix transformation. For more information about it, see [this Wikipedia entry](https://en.wikipedia.org/wiki/Determinant).
- There are a couple of different ways to compute the determinant, and it is up to you how you implement it.
- For instance, you may compute it using the [Laplace expansion](https://en.wikipedia.org/wiki/Laplace_expansion), a recursive algorithm which goes
- 1. Pick a row or column.
- 2. Start with a sum of zero.
- 3. For each entry of the row/column:
- 1. Create a new matrix with the row **and** column of the entry removed. This new matrix is a square matrix of size one less that the original.
- 2. Compute the determinant of that smaller matrix.
- 3. Multiply that determinant by the entry.
- 4. If the row index plus the column index is even[^1], add it to the sum, otherwise, subtract it.
- 4. The final sum is the determinant.
- As an example, here is an ungolfed implementation along the first column.
- ```javascript
- function laplaceDet(matrix) {
- if (matrix.length === 1) return matrix[0][0];
- let sum = 0;
- for (let rowIndex = 0; rowIndex < matrix.length; ++rowIndex) {
- let minorMatrix = matrix.filter((_, index) => index !== rowIndex)
- .map(row => row.slice(1));
- sum += ((-1) ** rowIndex) * matrix[rowIndex][0] * laplaceDet(minorMatrix);
- }
- return sum;
- }
- ```
- [Try it online!](https://tio.run/##VVFRT4MwEH5uf8X5ZBmFgNucBtmTL5qoDz4SYggrswbaBTqdMfvt81rG2BpSet939/W761fxXXRlKzcmUHolDodqq0ojtYK62NRFKR6FYU1hWrnz4I8SWcExDGuh1uYT0jSF2INWmG2roOeyKMcvoZTUwkC3bSCFKKGk0i0wC7X650mtxM7hY/QAF9oJ@P7AududXCOVbl9cHpYfCypZG9Ey9sFB9unpsj/BFRo8qaAGgdMKm2LDkLPJ@Au7WpaCxZ6HXom17afAWIDtTSajBkyGNgfIdovo@chGk1ZsT8lxQKia0P2h1KozYERnOmwioyTLYg5RzimBLOIQ53h0aDjncNPjwZTDLJwPFEaLnsDSYHaqQJ0LqfPgQhqFOUx7bsYBL7rtgwWHOw73eU5zSt2jjX5BV71v9yIW17UIa71mz@9vr2GHLau1rH6ZTfLAh2sIlrj55@NxnGcH8Q8 "JavaScript (Node.js) – Try It Online")
- This is <a class="badge is-tag" href="/categories/49/tags/4274">code-golf</a>, so the program with the lowest byte-count wins!
- ## Test cases
- <p>$$
- \begin{aligned}
- \det\begin{bmatrix}1&0\\0&1\end{bmatrix}&=1 \\
\det\begin{bmatrix}1&2\\3&4\end{bmatrix}&=-2 \\- \det\begin{bmatrix}3&7\\1&-4\end{bmatrix}&=-19 \\
- \det\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}&=0
- \end{aligned}
- $$</p>
- In text form,
- ```
- [[1,0],[0,1]] -> 1
- [[1.5,2],[-3,4.5]] -> 12.75
- [[3,7],[1,-4]] -> -19
- [[1,0,0],[0,1,0],[0,0,1]] -> 1
- [[1,2,3],[4,5,6],[7,8,9]] -> 0
- ```
- ## Questions
- - Anything else I missed?
- [^1]: Note that it doesn't matter if it is 1-indexed or 0-indexed, as 1+1 and 0+0 are both the same parity.
- ## Challenge
- A simple challenge: Given a two-dimensional matrix (an array of arrays) of real numbers, compute the determinant.
- The determinant of a matrix is a mathematical construct used in many applications, such as solving polynomial equations, identifying the invertibility of the matrix, and finding the scaling factor under a matrix transformation. For more information about it, see [this Wikipedia entry](https://en.wikipedia.org/wiki/Determinant).
- There are a couple of different ways to compute the determinant, and it is up to you how you implement it.
- For instance, you may compute it using the [Laplace expansion](https://en.wikipedia.org/wiki/Laplace_expansion), a recursive algorithm which goes
- 1. Pick a row or column.
- 2. Start with a sum of zero.
- 3. For each entry of the row/column:
- 1. Create a new matrix with the row **and** column of the entry removed. This new matrix is a square matrix of size one less that the original.
- 2. Compute the determinant of that smaller matrix.
- 3. Multiply that determinant by the entry.
- 4. If the row index plus the column index is even[^1], add it to the sum, otherwise, subtract it.
- 4. The final sum is the determinant.
- As an example, here is an ungolfed implementation along the first column.
- ```javascript
- function laplaceDet(matrix) {
- if (matrix.length === 1) return matrix[0][0];
- let sum = 0;
- for (let rowIndex = 0; rowIndex < matrix.length; ++rowIndex) {
- let minorMatrix = matrix.filter((_, index) => index !== rowIndex)
- .map(row => row.slice(1));
- sum += ((-1) ** rowIndex) * matrix[rowIndex][0] * laplaceDet(minorMatrix);
- }
- return sum;
- }
- ```
- [Try it online!](https://tio.run/##VVFRT4MwEH5uf8X5ZBmFgNucBtmTL5qoDz4SYggrswbaBTqdMfvt81rG2BpSet939/W761fxXXRlKzcmUHolDodqq0ojtYK62NRFKR6FYU1hWrnz4I8SWcExDGuh1uYT0jSF2INWmG2roOeyKMcvoZTUwkC3bSCFKKGk0i0wC7X650mtxM7hY/QAF9oJ@P7AududXCOVbl9cHpYfCypZG9Ey9sFB9unpsj/BFRo8qaAGgdMKm2LDkLPJ@Au7WpaCxZ6HXom17afAWIDtTSajBkyGNgfIdovo@chGk1ZsT8lxQKia0P2h1KozYERnOmwioyTLYg5RzimBLOIQ53h0aDjncNPjwZTDLJwPFEaLnsDSYHaqQJ0LqfPgQhqFOUx7bsYBL7rtgwWHOw73eU5zSt2jjX5BV71v9yIW17UIa71mz@9vr2GHLau1rH6ZTfLAh2sIlrj55@NxnGcH8Q8 "JavaScript (Node.js) – Try It Online")
- This is <a class="badge is-tag" href="/categories/49/tags/4274">code-golf</a>, so the program with the lowest byte-count wins!
- ## Test cases
- <p>$$
- \begin{aligned}
- \det\begin{bmatrix}1&0\\0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1.5&2\\-3&4.5\end{bmatrix}&=12.75 \\
- \det\begin{bmatrix}3&7\\1&-4\end{bmatrix}&=-19 \\
- \det\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}&=0
- \end{aligned}
- $$</p>
- In text form,
- ```
- [[1,0],[0,1]] -> 1
- [[1.5,2],[-3,4.5]] -> 12.75
- [[3,7],[1,-4]] -> -19
- [[1,0,0],[0,1,0],[0,0,1]] -> 1
- [[1,2,3],[4,5,6],[7,8,9]] -> 0
- ```
- ## Questions
- - Anything else I missed?
- [^1]: Note that it doesn't matter if it is 1-indexed or 0-indexed, as 1+1 and 0+0 are both the same parity.
#3: Post edited
- ## Challenge
A simple challenge: Given a two-dimensional matrix (an array of arrays) of integers, compute the determinant.- The determinant of a matrix is a mathematical construct used in many applications, such as solving polynomial equations, identifying the invertibility of the matrix, and finding the scaling factor under a matrix transformation. For more information about it, see [this Wikipedia entry](https://en.wikipedia.org/wiki/Determinant).
- There are a couple of different ways to compute the determinant, and it is up to you how you implement it.
- For instance, you may compute it using the [Laplace expansion](https://en.wikipedia.org/wiki/Laplace_expansion), a recursive algorithm which goes
- 1. Pick a row or column.
- 2. Start with a sum of zero.
- 3. For each entry of the row/column:
- 1. Create a new matrix with the row **and** column of the entry removed. This new matrix is a square matrix of size one less that the original.
- 2. Compute the determinant of that smaller matrix.
- 3. Multiply that determinant by the entry.
- 4. If the row index plus the column index is even[^1], add it to the sum, otherwise, subtract it.
- 4. The final sum is the determinant.
- As an example, here is an ungolfed implementation along the first column.
- ```javascript
- function laplaceDet(matrix) {
- if (matrix.length === 1) return matrix[0][0];
- let sum = 0;
- for (let rowIndex = 0; rowIndex < matrix.length; ++rowIndex) {
- let minorMatrix = matrix.filter((_, index) => index !== rowIndex)
- .map(row => row.slice(1));
- sum += ((-1) ** rowIndex) * matrix[rowIndex][0] * laplaceDet(minorMatrix);
- }
- return sum;
- }
- ```
[Try it online!](https://tio.run/##XVHRToMwFH2mX3F9soxCwE2nQfbkiybqg4@EGMLKrCntUjqdMfv22VIYTNLQe8@5PT339rP8KttKsa0OhVzT47HeiUozKYCXW15W9IFq3JRasb0Pv8hjNfRpxKnY6A/IsgwSHxTVOyXAcXlcmJUi5HGqod01kEGcIq@WCrCFlPx@FGu67/Axu4cz7RSCYOC62zu5hgmpnrs6c7w/UDOuqcL4nQBz5dnKRXBhDJ5UjIYHpy9qyi02nC02W9RyVlGc@L7x6lnbQQYYh6a92WzUgNnQ5gDZbg06Hdlo0oodkNcPyKim6HCspGg1aNrq1jSRIy/PEwJxQZAHeUwgKUzYo1cOnRNYDKiJlw41fLiYFMdnKtPkvyqBueMWBK4J3LhkSeCWwF1RoAKh7r1GqyBrZ7l7DItLTiMuN/jp7fUlak23YsPqH2yLfAjgEsKV@QXTyXScb2fwBw "JavaScript (Node.js) – Try It Online")- This is <a class="badge is-tag" href="/categories/49/tags/4274">code-golf</a>, so the program with the lowest byte-count wins!
- ## Test cases
- <p>$$
- \begin{aligned}
- \det\begin{bmatrix}1&0\\0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1&2\\3&4\end{bmatrix}&=-2 \\
- \det\begin{bmatrix}3&7\\1&-4\end{bmatrix}&=-19 \\
- \det\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}&=0
- \end{aligned}
- $$</p>
- In text form,
- ```
- [[1,0],[0,1]] -> 1
[[1,2],[3,4]] -> -2- [[3,7],[1,-4]] -> -19
- [[1,0,0],[0,1,0],[0,0,1]] -> 1
- [[1,2,3],[4,5,6],[7,8,9]] -> 0
- ```
- ## Questions
- Are there any alternative inputs that should be allowed?- Should I expand it to all real numbers, not just integers?- - Anything else I missed?
- [^1]: Note that it doesn't matter if it is 1-indexed or 0-indexed, as 1+1 and 0+0 are both the same parity.
- ## Challenge
- A simple challenge: Given a two-dimensional matrix (an array of arrays) of real numbers, compute the determinant.
- The determinant of a matrix is a mathematical construct used in many applications, such as solving polynomial equations, identifying the invertibility of the matrix, and finding the scaling factor under a matrix transformation. For more information about it, see [this Wikipedia entry](https://en.wikipedia.org/wiki/Determinant).
- There are a couple of different ways to compute the determinant, and it is up to you how you implement it.
- For instance, you may compute it using the [Laplace expansion](https://en.wikipedia.org/wiki/Laplace_expansion), a recursive algorithm which goes
- 1. Pick a row or column.
- 2. Start with a sum of zero.
- 3. For each entry of the row/column:
- 1. Create a new matrix with the row **and** column of the entry removed. This new matrix is a square matrix of size one less that the original.
- 2. Compute the determinant of that smaller matrix.
- 3. Multiply that determinant by the entry.
- 4. If the row index plus the column index is even[^1], add it to the sum, otherwise, subtract it.
- 4. The final sum is the determinant.
- As an example, here is an ungolfed implementation along the first column.
- ```javascript
- function laplaceDet(matrix) {
- if (matrix.length === 1) return matrix[0][0];
- let sum = 0;
- for (let rowIndex = 0; rowIndex < matrix.length; ++rowIndex) {
- let minorMatrix = matrix.filter((_, index) => index !== rowIndex)
- .map(row => row.slice(1));
- sum += ((-1) ** rowIndex) * matrix[rowIndex][0] * laplaceDet(minorMatrix);
- }
- return sum;
- }
- ```
- [Try it online!](https://tio.run/##VVFRT4MwEH5uf8X5ZBmFgNucBtmTL5qoDz4SYggrswbaBTqdMfvt81rG2BpSet939/W761fxXXRlKzcmUHolDodqq0ojtYK62NRFKR6FYU1hWrnz4I8SWcExDGuh1uYT0jSF2INWmG2roOeyKMcvoZTUwkC3bSCFKKGk0i0wC7X650mtxM7hY/QAF9oJ@P7AududXCOVbl9cHpYfCypZG9Ey9sFB9unpsj/BFRo8qaAGgdMKm2LDkLPJ@Au7WpaCxZ6HXom17afAWIDtTSajBkyGNgfIdovo@chGk1ZsT8lxQKia0P2h1KozYERnOmwioyTLYg5RzimBLOIQ53h0aDjncNPjwZTDLJwPFEaLnsDSYHaqQJ0LqfPgQhqFOUx7bsYBL7rtgwWHOw73eU5zSt2jjX5BV71v9yIW17UIa71mz@9vr2GHLau1rH6ZTfLAh2sIlrj55@NxnGcH8Q8 "JavaScript (Node.js) – Try It Online")
- This is <a class="badge is-tag" href="/categories/49/tags/4274">code-golf</a>, so the program with the lowest byte-count wins!
- ## Test cases
- <p>$$
- \begin{aligned}
- \det\begin{bmatrix}1&0\\0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1&2\\3&4\end{bmatrix}&=-2 \\
- \det\begin{bmatrix}3&7\\1&-4\end{bmatrix}&=-19 \\
- \det\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}&=0
- \end{aligned}
- $$</p>
- In text form,
- ```
- [[1,0],[0,1]] -> 1
- [[1.5,2],[-3,4.5]] -> 12.75
- [[3,7],[1,-4]] -> -19
- [[1,0,0],[0,1,0],[0,0,1]] -> 1
- [[1,2,3],[4,5,6],[7,8,9]] -> 0
- ```
- ## Questions
- - Anything else I missed?
- [^1]: Note that it doesn't matter if it is 1-indexed or 0-indexed, as 1+1 and 0+0 are both the same parity.
#2: Post edited
- ## Challenge
- A simple challenge: Given a two-dimensional matrix (an array of arrays) of integers, compute the determinant.
There are a couple of different ways to compute the determinant, and it is up to you how you implement it. As an example, here is an ungolfed implementation using the [Laplace expansion](https://en.wikipedia.org/wiki/Determinant#Laplace_expansion) along the first column.- ```javascript
- function laplaceDet(matrix) {
- if (matrix.length === 1) return matrix[0][0];
- let sum = 0;
- for (let rowIndex = 0; rowIndex < matrix.length; ++rowIndex) {
- let minorMatrix = matrix.filter((_, index) => index !== rowIndex)
- .map(row => row.slice(1));
- sum += ((-1) ** rowIndex) * matrix[rowIndex][0] * laplaceDet(minorMatrix);
- }
- return sum;
- }
- ```
- [Try it online!](https://tio.run/##XVHRToMwFH2mX3F9soxCwE2nQfbkiybqg4@EGMLKrCntUjqdMfv22VIYTNLQe8@5PT339rP8KttKsa0OhVzT47HeiUozKYCXW15W9IFq3JRasb0Pv8hjNfRpxKnY6A/IsgwSHxTVOyXAcXlcmJUi5HGqod01kEGcIq@WCrCFlPx@FGu67/Axu4cz7RSCYOC62zu5hgmpnrs6c7w/UDOuqcL4nQBz5dnKRXBhDJ5UjIYHpy9qyi02nC02W9RyVlGc@L7x6lnbQQYYh6a92WzUgNnQ5gDZbg06Hdlo0oodkNcPyKim6HCspGg1aNrq1jSRIy/PEwJxQZAHeUwgKUzYo1cOnRNYDKiJlw41fLiYFMdnKtPkvyqBueMWBK4J3LhkSeCWwF1RoAKh7r1GqyBrZ7l7DItLTiMuN/jp7fUlak23YsPqH2yLfAjgEsKV@QXTyXScb2fwBw "JavaScript (Node.js) – Try It Online")
- This is <a class="badge is-tag" href="/categories/49/tags/4274">code-golf</a>, so the program with the lowest byte-count wins!
- ## Test cases
- <p>$$
- \begin{aligned}
- \det\begin{bmatrix}1&0\\0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1&2\\3&4\end{bmatrix}&=-2 \\
- \det\begin{bmatrix}3&7\\1&-4\end{bmatrix}&=-19 \\
- \det\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}&=0
- \end{aligned}
- $$</p>
- ## Questions
- - Are there any alternative inputs that should be allowed?
- - Should I expand it to all real numbers, not just integers?
- Anything else I missed?
- ## Challenge
- A simple challenge: Given a two-dimensional matrix (an array of arrays) of integers, compute the determinant.
- The determinant of a matrix is a mathematical construct used in many applications, such as solving polynomial equations, identifying the invertibility of the matrix, and finding the scaling factor under a matrix transformation. For more information about it, see [this Wikipedia entry](https://en.wikipedia.org/wiki/Determinant).
- There are a couple of different ways to compute the determinant, and it is up to you how you implement it.
- For instance, you may compute it using the [Laplace expansion](https://en.wikipedia.org/wiki/Laplace_expansion), a recursive algorithm which goes
- 1. Pick a row or column.
- 2. Start with a sum of zero.
- 3. For each entry of the row/column:
- 1. Create a new matrix with the row **and** column of the entry removed. This new matrix is a square matrix of size one less that the original.
- 2. Compute the determinant of that smaller matrix.
- 3. Multiply that determinant by the entry.
- 4. If the row index plus the column index is even[^1], add it to the sum, otherwise, subtract it.
- 4. The final sum is the determinant.
- As an example, here is an ungolfed implementation along the first column.
- ```javascript
- function laplaceDet(matrix) {
- if (matrix.length === 1) return matrix[0][0];
- let sum = 0;
- for (let rowIndex = 0; rowIndex < matrix.length; ++rowIndex) {
- let minorMatrix = matrix.filter((_, index) => index !== rowIndex)
- .map(row => row.slice(1));
- sum += ((-1) ** rowIndex) * matrix[rowIndex][0] * laplaceDet(minorMatrix);
- }
- return sum;
- }
- ```
- [Try it online!](https://tio.run/##XVHRToMwFH2mX3F9soxCwE2nQfbkiybqg4@EGMLKrCntUjqdMfv22VIYTNLQe8@5PT339rP8KttKsa0OhVzT47HeiUozKYCXW15W9IFq3JRasb0Pv8hjNfRpxKnY6A/IsgwSHxTVOyXAcXlcmJUi5HGqod01kEGcIq@WCrCFlPx@FGu67/Axu4cz7RSCYOC62zu5hgmpnrs6c7w/UDOuqcL4nQBz5dnKRXBhDJ5UjIYHpy9qyi02nC02W9RyVlGc@L7x6lnbQQYYh6a92WzUgNnQ5gDZbg06Hdlo0oodkNcPyKim6HCspGg1aNrq1jSRIy/PEwJxQZAHeUwgKUzYo1cOnRNYDKiJlw41fLiYFMdnKtPkvyqBueMWBK4J3LhkSeCWwF1RoAKh7r1GqyBrZ7l7DItLTiMuN/jp7fUlak23YsPqH2yLfAjgEsKV@QXTyXScb2fwBw "JavaScript (Node.js) – Try It Online")
- This is <a class="badge is-tag" href="/categories/49/tags/4274">code-golf</a>, so the program with the lowest byte-count wins!
- ## Test cases
- <p>$$
- \begin{aligned}
- \det\begin{bmatrix}1&0\\0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1&2\\3&4\end{bmatrix}&=-2 \\
- \det\begin{bmatrix}3&7\\1&-4\end{bmatrix}&=-19 \\
- \det\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}&=1 \\
- \det\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}&=0
- \end{aligned}
- $$</p>
- In text form,
- ```
- [[1,0],[0,1]] -> 1
- [[1,2],[3,4]] -> -2
- [[3,7],[1,-4]] -> -19
- [[1,0,0],[0,1,0],[0,0,1]] -> 1
- [[1,2,3],[4,5,6],[7,8,9]] -> 0
- ```
- ## Questions
- - Are there any alternative inputs that should be allowed?
- - Should I expand it to all real numbers, not just integers?
- - Anything else I missed?
- [^1]: Note that it doesn't matter if it is 1-indexed or 0-indexed, as 1+1 and 0+0 are both the same parity.
#1: Initial revision
Compute the determinant
## Challenge A simple challenge: Given a two-dimensional matrix (an array of arrays) of integers, compute the determinant. There are a couple of different ways to compute the determinant, and it is up to you how you implement it. As an example, here is an ungolfed implementation using the [Laplace expansion](https://en.wikipedia.org/wiki/Determinant#Laplace_expansion) along the first column. ```javascript function laplaceDet(matrix) { if (matrix.length === 1) return matrix[0][0]; let sum = 0; for (let rowIndex = 0; rowIndex < matrix.length; ++rowIndex) { let minorMatrix = matrix.filter((_, index) => index !== rowIndex) .map(row => row.slice(1)); sum += ((-1) ** rowIndex) * matrix[rowIndex][0] * laplaceDet(minorMatrix); } return sum; } ``` [Try it online!](https://tio.run/##XVHRToMwFH2mX3F9soxCwE2nQfbkiybqg4@EGMLKrCntUjqdMfv22VIYTNLQe8@5PT339rP8KttKsa0OhVzT47HeiUozKYCXW15W9IFq3JRasb0Pv8hjNfRpxKnY6A/IsgwSHxTVOyXAcXlcmJUi5HGqod01kEGcIq@WCrCFlPx@FGu67/Axu4cz7RSCYOC62zu5hgmpnrs6c7w/UDOuqcL4nQBz5dnKRXBhDJ5UjIYHpy9qyi02nC02W9RyVlGc@L7x6lnbQQYYh6a92WzUgNnQ5gDZbg06Hdlo0oodkNcPyKim6HCspGg1aNrq1jSRIy/PEwJxQZAHeUwgKUzYo1cOnRNYDKiJlw41fLiYFMdnKtPkvyqBueMWBK4J3LhkSeCWwF1RoAKh7r1GqyBrZ7l7DItLTiMuN/jp7fUlak23YsPqH2yLfAjgEsKV@QXTyXScb2fwBw "JavaScript (Node.js) – Try It Online") This is <a class="badge is-tag" href="/categories/49/tags/4274">code-golf</a>, so the program with the lowest byte-count wins! ## Test cases <p>$$ \begin{aligned} \det\begin{bmatrix}1&0\\0&1\end{bmatrix}&=1 \\ \det\begin{bmatrix}1&2\\3&4\end{bmatrix}&=-2 \\ \det\begin{bmatrix}3&7\\1&-4\end{bmatrix}&=-19 \\ \det\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}&=1 \\ \det\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}&=0 \end{aligned} $$</p> ## Questions - Are there any alternative inputs that should be allowed? - Should I expand it to all real numbers, not just integers? - Anything else I missed?