[Question]
  [
Given a square integer matrix as input, output the determinant of the matrix.
## Rules
* You may assume that all elements in the matrix, the determinant of the matrix, and the total number of elements in the matrix are within the representable range of integers for your language.
* Outputting a decimal/float value with a fractional part of 0 is allowed (e.g. `42.0` instead of `42`).
* Builtins are allowed, but you are encouraged to include a solution that does not use builtins.
## Test Cases
```
[[42]] -> 42
[[2, 3], [1, 4]] -> 5
[[1, 2, 3], [4, 5, 6], [7, 8, 9]] -> 0
[[13, 17, 24], [19, 1, 3], [-5, 4, 0]] -> 1533
[[372, -152, 244], [-97, -191, 185], [-53, -397, -126]] -> 46548380
[[100, -200, 58, 4], [1, -90, -55, -165], [-67, -83, 239, 182], [238, -283, 384, 392]] -> 571026450
[[432, 45, 330, 284, 276], [-492, 497, 133, -289, -28], [-443, -400, 56, 150, -316], [-344, 316, 92, 205, 104], [277, 307, -464, 244, -422]] -> -51446016699154
[[416, 66, 340, 250, -436, -146], [-464, 68, 104, 471, -335, -442], [159, -407, 310, -489, -248, 370], [62, 277, 446, -325, 47, -193], [460, 460, -418, -28, 234, -374], [249, 375, 489, 172, -423, 125]] -> 39153009069988024
[[-246, -142, 378, -156, -373, 444], [186, 186, -23, 50, 349, -413], [216, 1, -418, 38, 47, -192], [109, 345, -356, -296, -47, -498], [-283, 91, 258, 66, -127, 79], [218, 465, -420, -326, -445, 19]] -> -925012040475554
[[-192, 141, -349, 447, -403, -21, 34], [260, -307, -333, -373, -324, 144, -190], [301, 277, 25, 8, -177, 180, 405], [-406, -9, -318, 337, -118, 44, -123], [-207, 33, -189, -229, -196, 58, -491], [-426, 48, -24, 72, -250, 160, 359], [-208, 120, -385, 251, 322, -349, -448]] -> -4248003140052269106
[[80, 159, 362, -30, -24, -493, 410, 249, -11, -109], [-110, -123, -461, -34, -266, 199, -437, 445, 498, 96], [175, -405, 432, -7, 157, 169, 336, -276, 337, -200], [-106, -379, -157, -199, 123, -172, 141, 329, 158, 309], [-316, -239, 327, -29, -482, 294, -86, -326, 490, -295], [64, -201, -155, 238, 131, 182, -487, -462, -312, 196], [-297, -75, -206, 471, -94, -46, -378, 334, 407, -97], [-140, -137, 297, -372, 228, 318, 251, -93, 117, 286], [-95, -300, -419, 41, -140, -205, 29, -481, -372, -49], [-140, -281, -88, -13, -128, -264, 165, 261, -469, -62]] -> 297434936630444226910432057
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
L≈í!√∞≈ícI·π†;·ªã"P√∞‚Ç¨S
```
[Try it online!](https://tio.run/##y0rNyan8/9/n6CTFwxuOTkr2fLhzgfXD3d1KAYc3PGpaE/z////oaEMDAx0FXSMQaWqho2ASq6MQbQgUsQQJm5oCCUMzU5Cgrpk5kGNhrKNgZGypo2BoYQQSNTK2AGkHCRtbmAAJS6PYWAA "Jelly ‚Äì Try It Online")
## How it works
```
L≈í!√∞≈ícI·π†;·ªã"P√∞‚Ç¨S   input
L                 length
 ≈í!               all_permutations
   √∞        √∞‚Ç¨    for each permutation:
    ≈íc                take all unordered pairs
      I               calculate the difference between
                      the two integers of each pair
       ·π†              signum of each difference
                      (positive -> 1, negative -> -1)
        ;             append:
         ·ªã"             the list of elements generated by taking
                        each row according to the index specified
                        by each entry of the permutation
           P          product of everything
              S   sum
```
## Why it works -- mathy version
The operator **det** takes a matrix and returns a scalar. An *n*-by-*n* matrix can be thought of as a collection of *n* vectors of length *n*, so **det** is really a function that takes *n* vectors from ‚Ñ§*n* and returns a scalar.
Therefore, I write **det**(*v*1, *v*2, *v*3, ..., *v**n*) for **det** [*v*1 *v*2 *v*3 ... *v*n].
Notice that **det** is linear in each argument, i.e. **det**(*v*1 + Œª*w*1, *v*2, *v*3, ..., *v**n*) = **det**(*v*1, *v*2, *v*3, ..., *v**n*) + Œª **det**(*w*1, *v*2, *v*3, ..., *v**n*). Therefore, it is a linear map from (‚Ñ§*n*)‚äó*n* to ‚Ñ§.
It suffices to determine the image of the basis under the linear map. The basis of (‚Ñ§*n*)‚äó*n* consists of *n*-fold tensor products of the basis elements of ‚Ñ§*n*, i.e. e.g. e5 ‚äó e3 ‚äó e1 ‚äó e5 ‚äó e1. Tensor products that include identical tensors must be sent to zero, since the determinant of a matrix in which two columns are identical is zero. It remains to check what the tensor products of distinct basis elements are sent to. The indices of the vectors in the tensor product form a bijection, i.e. a permutation, in which even permutations are sent to 1 and odd permutations are sent to -1.
For example, to find the determinant of [[1, 2], [3, 4]]: note that the columns are [1, 3] and [2, 4]. We decompose [1, 3] to give (1 e1 + 3 e2) and (2 e1 + 4 e2). The corresponding element in the tensor product is (1 e1 ‚äó 2 e1 + 1 e1 ‚äó 4 e2 + 3 e2 ‚äó 2 e1 + 3 e2 ‚äó 4 e2), which we simplify to (2 e1 ‚äó e1 + 4 e1 ‚äó e2 + 6 e2 ‚äó e1 + 12 e2 ‚äó e2). Therefore:
**det** [[1, 2], [3, 4]]   
= **det**(1 e1 + 3 e2, 2 e1 + 4 e2)   
= **det**(2 e1 ‚äó e1 + 4 e1 ‚äó e2 + 6 e2 ‚äó e1 + 12 e2 ‚äó e2)   
= **det**(2 e1 ‚äó e1) + **det**(4 e1 ‚äó e2) + **det**(6 e2 ‚äó e1) + **det**(12 e2 ‚äó e2)   
= 2 **det**(e1 ‚äó e1) + 4 **det**(e1 ‚äó e2) + 6 **det**(e2 ‚äó e1) + 12 **det**( e2 ‚äó e2)   
= 2 (0) + 4 (1) + 6 (-1) + 12 (0)   
= 4 - 6   
= -2
Now it remains to prove that the formula for finding the parity of the permutation is valid. What my code does is essentially find the number of inversions, i.e. the places where an element on the left is bigger than an element on the right (not necessarily consecutively).
For example, in the permutation 3614572, there are 9 inversions (31, 32, 61, 64, 65, 62, 42, 52, 72), so the permutation is odd.
The justification is that each transposition (swapping two elements) either adds one inversion or takes away one inversion, swapping the parity of the number of inversions, and the parity of the permutation is the parity of the number of transpositions needed to achieve the permutation.
Therefore, in conclusion, our formula is given by:
## Why it works -- non-mathy version
![](https://i.stack.imgur.com/pfOYs.gif)
where œÉ is a permutation of ùïä*n* the group of all permutations on *n* letters, and **sgn** is the sign of the permutation, AKA (-1) raised to the parity of the permutation, and *a**ij* is the (*ij*)th entry in the matrix (*i* down, *j* across).
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~16~~ ~~15~~ ~~12~~ 10 bytes
```
·∏¢√óZ√ü-∆§$·πö·∏Ö-
```
Uses [Laplace expansion](https://en.wikipedia.org/wiki/Laplace_expansion "Laplace expansion - Wikipedia"). *Thanks to @miles for golfing off ~~3~~ 5 bytes!*
[Try it online!](https://tio.run/##PVNLit1ADNznFD6AG7ol9e8oifEym2EuMNuBEMgFAtkEQpZzgJf1g9zj5SKOqmTP4jW23FUqVek9fX5@fjmOx@3bp/vP9Pf3/fvj9uvx58fj9iUd96//Xt8@Hse2bSb7vn5Ytk3WRfd12cq62Fnyx6tq61LXpeGxr8tYl3nd0XUpXhIjePrbCUkOcFg@L2p3rlSq4C4vp9lRmQ4oowbE2ZJGXdrVImd/F5x1QF2oTBPlWnG3BbwBOJxDFEKGoCo6AEdZhwvSeY1s6mLMCVSdSvBROmdMNvEJQooq4ZNnfDSUjIKa36gQoiWQauhRvA4KyU5fMjVLdzrN0GjNaAMe5V0OQM1/apBDVtOG@exUBVgbZHR5HS6owgEzzlrqpDI0KsSHbnOM9owrDaqgxAzUKogpgoikm@N4JCvhHPyEVO0xh02wAQf2wmBNsAhSz1m8ZQjHAvXB5NmuKzpHhgPm4UgAY1416i9UIvCjXDqQ4qkzRs1QgfSSklomTl6xGUExdOyXYHEaFYlf6DP4QdlonzBCIQM4y7XfaOevRquhzqJD5lZg18MTGhbhKjeGkzqlAW3UTf81lzMAOE9n8FIGbM@xx5YhZHKrMLpybsolk8QfTJgz2pSIWSb7tPijuA0l6DCXMUuHMy5uV4ForfMkw16FD6NCHYYTueZ2X8a@7/8B "Jelly ‚Äì Try It Online")
### How it works
```
·∏¢√óZ√ü-∆§$·πö·∏Ö-  Main link. Argument: M (matrix / 2D array)
·∏¢           Head; pop and yield the first row of M.
      $     Combine the two links to the left into a monadic chain.
  Z         Zip/transpose the matrix (M without its first row).
   √ü-∆§      Recursively map the main link over all outfixes of length 1, i.e., over
            the transpose without each of its rows.
            This yields an empty array if M = [[x]].
 √ó          Take the elementwise product of the first row and the result on the
            right hand. Due to Jelly's vectorizer, [x] √ó [] yields [x].
       ·πö    Reverse the order of the products.
        ·∏Ö-  Convert from base -1 to integer.
                [a]          -> (-1)**0*a
                [a, b]       -> (-1)**1*a + (-1)**0*b = b - a
                [a, b, c]    -> (-1)**2*a + (-1)**1*b + (-1)**0*c = c - b + a
                etc.
```
[Answer]
# [R](https://www.r-project.org/), 3 bytes
*Trivial Solution*
```
det
```
[Try it online!](https://tio.run/##K/r/PyW15P9/AA "R ‚Äì Try It Online")
# [R](https://www.r-project.org/), ~~94~~ ~~92~~ 89 bytes
*re-implemented solution*
*outgolfed by [Jarko Dubbeldam](https://codegolf.stackexchange.com/questions/147668/determinant-of-an-integer-matrix/147797#147797)*
```
d=function(m)"if"(x<-nrow(m),m[,1]%*%sapply(1:x,function(y)(-1)^y*-d(m[-y,-1,drop=F])),1)
```
[Try it online!](https://tio.run/##PcrLCoMwEEbhdxGEGflnMamrUrd9CbEgBiFgLqSWJk@fuuryfJzcmp32T9hOFwN57tzeUXlIyPF7JfwMXfqhf68pHZX0XvC/K5Mov@oglvwsFaKwOabpuTBDuV28ntkV2shAccPIMDDM7Qc "R ‚Äì Try It Online")
Recursively uses expansion by minors down the first column of the matrix.
```
f <- function(m){
 x <- nrow(m)                 # number of rows of the matrix
 if(sum(x) > 1){              # when the recursion reaches a 1x1, it has 0 rows
                              # b/c [] drops attributes
  minor <- function(y){
   m[y] * (-1)^y *
   -d(m[-y,-1])                # recurse with the yth row and first column dropped
   }
  minors <- sapply(1:x,minor) # call on each row
  sum(minors)                 # return the sum
 } else {
  m                           # return the 1x1 matrix
 }
}
```
[Answer]
# [Haskell](https://www.haskell.org/), 71 bytes
*-3 bytes thanks to Lynn. Another one bytes the dust thanks to Craig Roy.*
```
f[]=1
f(h:t)=foldr1(-)[v*f[take i l++drop(i+1)l|l<-t]|(i,v)<-zip[0..]h]
```
[Try it online!](https://tio.run/##VVTRjhMxDHznK/LYcptTYnuzCeI@AfEBVR8qoFx1BU7HiQfEt1M841ZaKjXazcbjsWecx8PPpy/n8@Vy3O0f6pvj5vHd6/bh@OP8@aVu8nb36@1x93p4@pJO6Xx39/nlx/PmdFe35z/n9/l1/2dzmn5t3@ffp@ddub/fP@4v3w6n7@khfTs8f0ib55fT99d0n47bN8l/u7Tbmez3fJn8Raake3@oU7LVtr/evtiU5ik1PC5T6lMa63M6perbYgQZ/nYNyx7koWV1WBfHzHUWnGdAHgt2hgfVPkeYI2aNfWnrVKX4nmCdO9gG6zywPc843wKiIbg7jigIdcGuaEc4trU7MR3rNpg6KXMQVYcTHJCFNWcb@ARCVZUQg2t8NGwZSTU/MYOM1ohUQ57q@4CQ4vC1kLcsDqcFPK0Z24FH@Y8SApv/1UCJyKYNddqVGUJbJ6pTXNANVXTCjDXXeZAdklXGB3fzGF0KjjQwAxszQKtAthAl1G8exyVbjQ6ir6CrS9RiA2iIA3qlyCYwhsyrejxtkIexlk4nMOWiyB56djQRSwYAalZjDZVsBD2pNy5Q9Mo1yi1gAhWzEloGVh6xEYLRAPCbwESNjMQPLCPwAdnYQqGUQgRg1rXvkdK3jC0HQ4sshQ7BDERv2LgQWukeVuuwhmgjd@qgpV6FgALsDl5qR/tL@NoKyAw6DOUraydlIkkMnlBvpKkhtwzmaTE43ooacKjNqKmHUza6rIK0zuMKBn9FL/oMdihO5Fa396av@gK6dJ02HilXdE8KlWFC@sVpYymRpNKcVThLLXqKQMhTB7MoLQqTDVxBHIC6UCjMFec3o2EzlgYGnBWf4lun/OqIbCVsRxpz@AfGZXral7oq2lbRMb3S5ChnXioqRCS1jhEaINzbzTLGW0kGhWssprBiXFS8iqry0uOw9LgI2LGK/FGfx@MDqxSQjhFnqpjWhTbA8NNiY4kCje1E0YHAi1cwuTQONcwQpPLu7pFtcHBKjDosTcIWty5oR7X1BuiartIJP3Q6l40UOgu1VwyUUFeDMrn5PZf2l7@fjufD15@X/PEf "Haskell ‚Äì Try It Online") *Added `-O` flag for optimization purposes. It is not necessary.*
## Explanation (outdated)
`f` recursively implements cofactor expansion.
```
f[[x]]=x
```
This line covers the base case of a **1** √ó **1** matrix, in which case the determinant is `mat[0, 0]`.
```
f(h:t)=
```
This uses Haskell's *pattern matching* to break the matrix into a *head* (the first row) and a *tail* (the rest of the matrix).
```
          [                                     |(i,v)<-zip[0..]h]
```
Enumerate the head of the matrix (by zipping the infinite list of whole numbers and the head) and iterate over it.
```
           (-1)*i*v
```
Negate the result based on whether its index is even since the calculation of the determinant involves alternating addition and subtraction.
```
                     [take i l++drop(i+1)l|l<-t]
```
This essentially removes the **ith** column of the tail by taking **i** elements and concatenating it with the row with the first **(i + 1)th** elements dropped for every row in the tail.
```
                   *f
```
Calculate the determinant of the result above and multiply it with the result of `(-1)*i*v`.
```
       sum
```
Sum the result of the list above and return it.
[Answer]
## [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), between 14 and 42 bytes
We've had a [3-byte built-in](https://codegolf.stackexchange.com/a/147671/66104) and a [53-byte solution](https://codegolf.stackexchange.com/a/147752/66104) that completely avoids built-ins, so here are some weirder solutions somewhere in between.
The Wolfram Language has [a lot of](http://reference.wolfram.com/language/guide/MatrixDecompositions.html) very intense functions for decomposing matrices into products of other matrices with simpler structure. One of the simpler ones (meaning I've heard of it before) is Jordan decomposition. Every matrix is similar to a (possibly complex-valued) upper triangular matrix made of diagonal blocks with a specific structure, called the Jordan decomposition of that matrix. Similarity preserves determinants, and the determinant of a triangular matrix is the product of the diagonal elements, so we can compute the determinant with the following **42 bytes**:
```
1##&@@Diagonal@Last@JordanDecomposition@#&
```
The determinant is also equal to the product of the eigenvalues of a matrix, with multiplicity. Luckily, Wolfram's eigenvalue function keeps track of multiplicity (even for non-diagonalisable matrices), so we get the following **20 byte** solution:
```
1##&@@Eigenvalues@#&
```
The next solution is kind of cheating and I'm not really sure why it works. The Wronskian of a list of *n* functions is the determinant of the matrix of the first *n*-1 derivatives of the functions. If we give the `Wronskian` function a matrix of integers and say that the variable of differentiation is 1, somehow it spits out the determinant of the matrix. It's weird, but it doesn't involve the letters "`Det`" and it's only **14 bytes**‚Ä¶
```
#~Wronskian~1&
```
(The Casoratian determinant works as well, for 1 more byte: `#~Casoratian~1&`)
In the realm of abstract algebra, the determinant of an *n*¬†x¬†*n* matrix (thought of as the map k ‚Üí k that is multiplication by the determinant) is the *n*th exterior power of the matrix (after picking an isomorphism k ‚Üí ‚ãÄn kn). In Wolfram language, we can do this with the following **26 bytes**:
```
HodgeDual[TensorWedge@@#]&
```
And here's a solution that works for positive determinants only. If we take an *n*-dimensional unit hypercube and apply a linear transformation to it, the *n*-dimensional "volume" of the resulting region is the absolute value of the determinant of the transformation. Applying a linear transformation to a cube gives a parallelepiped, and we can take its volume with the following **39 bytes** of code:
```
RegionMeasure@Parallelepiped[Last@#,#]&
```
[Answer]
# [Haskell](https://www.haskell.org/), 59 bytes
```
p%(l:r)=l!!0*f(tail<$>p++r)-(p++[l])%r
[]%_=1
p%_=0
f=([]%)
```
[Try it online!](https://tio.run/##VVTRihsxDHzPV2yhB0lvXWxJ67VL0z8o/YAQSihNezR3hNx9f1PNKIHtwTm7Xms00oz8@/D65@fpdL2eH9anT5fN9vTuXf5wXL8dnk6f3385Pz5eNmntP7vTfvNwWe32D9@3ZXX2Na@O27W/b67Ph6eXYTs8H85fh/X58vTyNnwcjpvV4H@7Ybcz2e/5MvqLjIPu/aGMgy22/fX@xcZhGoeKx3kc2jj05Tkdh@LbYgTp/nYLSx7koXlxWGfHTGUSnGdA6jN2ugeVNkWYIyaNfanLVDn7nmCdGtgG69SxPU04XwOiIrg5jigINcGuaEM4trU5Me3LNpg6KXMQVYcTHJCZNSfr@ARCRZUQnWt8NGwZSVU/MYGMlohUQ57i@4CQ7PAlk7fMDqcZPK0a24FH@Y8SAqv/q4ESkU0r6rQbM4TWRlSnOKMbquiEGWsuUyc7JCuMD@7mMTpnHKlgBjZmgFaBbCFKqF89jkuyEh1EX0FX56jFOtAQB/RCkU1gDJkW9XjaIA9jzY1OYMpZkT30bGgilgQA1KzGGgrZCHpS7lyg6I1rlJvBBComJbR0rDxiPQSjAeA3gYkqGYkfmHvgA7KyhUIphQjALEvfI6VvGVsOhhZZMh2CGYjesHEhtNI9rNZhDdFG7tRBc7kJAQXYHbyUhvbn8LVlkOl0GMpX1k7KRJIYPKHeSFNCbunMU2NwvBUl4FCbUVMPp2x0WQFpnfoNDP6KXrQJ7FCcyL1u701b9AV06TqtPJJv6J4UKsOE9IvTxpIjSaE5i3CWavQUgZCndGZRWhQm67iCOABlplCYK85vQsMmLBUMOCs@xfdO@dUR2XLYjjSm8A@My/S0L3VVtK2gY3qjyVFOvFRUiEhqDSPUQbjVu2WMt5J0CldZTGbFuKh4FRXlpcdhaXERsGMF@aM@j8cHVikgHSPOVDGtM22A4afF@hwFGtuJogOBF69gcmkcapggSOHd3SJb5@DkGHVYmoQtbl3QjmrLHdA1XaQTfmh0LhspdBZqLxgooa4GZVL1e27YX//@OJ4Ov16v6ds/ "Haskell ‚Äì Try It Online")
[Answer]
# [Proton](https://github.com/alexander-liao/proton), 98 bytes
```
f=m=>(l=len(m))-1?sum((-1)**i*m[0][i]*f([[m[k][j]for k:1..l]for j:0..l if j-i])for i:0..l):m[0][0]
```
[Try it online!](https://tio.run/##HYxBCsMgEEWvMktHNGiTUirYHmSYZQVNjMGm57fR3fsP3j9qOcveWvDZv8Tmt88uMqK27@8vC6EtShllJsMUWQZBlGllShxKhdXZadoGJmcuhBgg6cjYVRwK3YgNt6PG/RT9ws4K7EPBbWEFZJ/XUjB31ncFiwLDjNj@ "Proton ‚Äì Try It Online")
-3 bytes thanks to Mr. Xcoder  
-3 bytes thanks to Erik the Outgolfer  
-1 byte thanks to S.S. Anne 
Expansion over the first row
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 24 bytes
```
≈ìcL‚Äô$·πö√ë‚Ç¨
J-*√ó·∏¢‚Ç¨√ó√áS¬µ·∏¢·∏¢$·πñ?
```
[Try it online!](https://tio.run/##y0rNyan8///o5GSfRw0zVR7unHV44qOmNVxeulqHpz/csQjIPjz9cHvwoa1ADhABVUyz////f3S0obGOgqG5joKRSayOQrShJZCno2AMYuua6iiY6CgYxMYCAA "Jelly ‚Äì Try It Online")
# Explanation
```
≈ìcL‚Äô$·πö√ë‚Ç¨         Helper Link; get the next level of subdeterminants (for Laplace Expansion)
≈ìc               Combinations without replacement of length:
  L‚Äô$            Length of input - 1 (this will get all submatrices, except it's reversed)
     ·πö           Reverse the whole thing
      √ë‚Ç¨         Get the determinant of each of these
J-*√ó·∏¢‚Ç¨√ó√áS¬µ·∏¢·∏¢$·πñ?  Main Link
              ?  If the next value is truthy
             ·πñ   Remove the last element (truthy if the matrix was at least size 2)
J-*√ó·∏¢‚Ç¨√ó√áS¬µ       Then expand
          ·∏¢·∏¢$    Otherwise, get the first element of the first element (m[0][0] in Python)
J                [1, 2, ..., len(z)]
 -*              (-1 ** z) for each z in the length range
   √ó             Vectorizing multiply with
    ·∏¢‚Ç¨           The first element of each (this gets the first column); modifies each row (makes it golfier yay)
      √ó√á         Vectorizing multiply with the subdeterminants
        S        Sum
```
-2 bytes thanks to user202729's solution
[Answer]
# [R](https://www.r-project.org/), 32 bytes
```
function(m)Re(prod(eigen(m)$va))
```
Uses Not a Tree's algorithm of taking the eigenvalues of the matrix and taking the real part of their product.
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jVzMoVaOgKD9FIzUzPRXEVylL1NT8n2ubm1hSlFmhUZyYW5CTqmFoYGCgowAkNUEkCGtyFRRl5pVopKSWAHXBeGkg9n8A "R ‚Äì Try It Online")
[Answer]
# C, ~~¬†176¬†~~ 125 bytes
*Thanks to @ceilingcat for golfing 42 bytes, and thanks to both @Lynn and @Jonathan Frech for saving a byte each!*
```
d(M,n)int*M;{int i=n--,s=*M*!n,c,T[n*n];for(;i--;s+=M[i]*(1-i%2*2)*d(T,n))for(c=n*n;c--;T[c]=M[n-~c+c/n+(c%n>=i)]);return s;}
```
Calculates the determinant using the [Laplace expansion](https://en.wikipedia.org/wiki/Laplace_expansion) along the first row.
[Try it online!](https://tio.run/##fZDBasMwDIbvfQqtULBdmTW2kyaY7A1y6y3LYTjt8GHeSLJT6V49k5oxGB3NwcHyr@@THfRrCPPciwaTjGlSjT/TD2KdtMaxVo16SBjw0CaVOn96H4SPWvtxWzdt7JTIdNwYZaTqxYEQkhOhprAPFDu0oaNg0l9hGx7TVoRNeqqj7KQfjtPnkGD0l5mFby8xCbk6r4A@LkzHccraDmo4O3Px1/rHQCcnsd70z2mN0ItrCCGT0q/@dJql0yBYOkZw9wiUMjcEuxCod4E4hByhQNgjlAjVPSDF7Q3QLUC7J57OcpY6gupqz/uKr1GSQefUre1SNcU9jftPk//MvdsRwPCal9fpM3ZxMWdLVvBasKUkobEV@3koW3IjF23Jhur29X8nIIbjCS7zNw)
**Unrolled:**
```
d(M, n)int*M;
{
    int i=n--, s=*M*!n, c, T[n*n];
    for (; i--; s+=M[i]*(1-i%2*2)*d(T,n))
        for (c=n*n; c--;)
            T[c] = M[n-~c+c/n+(c%n>=i)];
    return s;
}
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 43 bytes
Finally I've done writing my non-builtin solution in a golfing language!
```
·∏£‚Åπ‚Äô‚Äô¬§;·π´·∏ä‚Ç¨√á√ó‚Å∏·ªã@‚Åπ‚Äô¬§¬§·∏∑/¬§
√ß√ê‚Ç¨‚Å∏J‚Äò¬§¬µJ-*√óNS
√á·∏¢·∏¢$·πñ?
```
Thanks to *HyperNeutrino* for saving a byte!
[Try it online!](https://tio.run/##y0rNyan8///hjsUKjxp3PmqYCUSHlihYP9y5WuHhjq5HTWsUDrcrHJ4OlN3xcHe3A0TRoSWHljzcsV3/0BKuw8sPTwCpAsp7PWqYAdR7aKuCl4KuFkiTn0IwF1D7wx2LgEhF4eHOafb///@PNtNRMAeiWB2FaBMw0wzEBIoCeRaxAA "Jelly ‚Äì Try It Online") (spaced code for clarity)
*terribly long way to remove n'th elements from a list, will improve later*
---
This answer had been outgolfed by answers of HyperNeutrino, Dennis and Leaky Nun. Jelly is *very* popular as a golfing language.
Quick explanation:
```
√á·∏¢·∏¢$·πñ?    Main link.
     ?    If
    ·πñ     after remove the last element, the value is not empty (truthy)
√á         then execute the last link
 ·∏¢·∏¢$      else get the element at index [1, 1].
√ß√ê‚Ç¨‚Å∏J‚Äò¬§¬µJ-*√óNS     Helper link 1, take input as a matrix.
√ß√ê‚Ç¨                Apply the previous link, thread right argument to
   ‚Å∏J‚Äò¬§            the range [2, 3, ..., n+1]
       ¬µ           With the result,
        J-*        generate the range [-1, 1, -1, 1, ...] with that length
           √óN      Multiply by negative
             S     Sum
·∏£‚Åπ‚Äô‚Äô¬§;·π´·∏ä‚Ç¨√á√ó‚Å∏·ªã@‚Åπ‚Äô¬§¬§·∏∑/¬§    Helper link 2, take left input as a matrix, right input as a number in range [2..n+1]
·∏£
 ‚Åπ‚Äô‚Äô¬§                    Take head œÅ-2 of the matrix
     ;                   concatenate with 
      ·π´                  tail œÅ (that is, remove item œÅ-1)
       ·∏ä‚Ç¨                Remove first column
         √á               Calculate determinant of remaining matrix
          √ó         ¬§    multiply by
                  ·∏∑/     the first column,
            ·ªã@           row #
              ‚Åπ‚Äô¬§        œÅ-1 (just removed in determinant calculation routine) of
           ‚Å∏     ¬§       the matrix.
```
[Answer]
## CJam (50 45 bytes)
```
{:A_,{1$_,,.=1b\)/:CAff*A@zf{\f.*1fb}..-}/;C}
```
This is an anonymous block (function) which takes a 2D array on the stack and leaves an integer on the stack.
[Online test suite](http://cjam.aditsu.net/#code=q'%2C-~%5D2%2F%7B~%3AE%3B%0A%0A%7B%3AA_%2C%7B1%24_%2C%2C.%3D1b%5C)%2F%3ACAff*A%40zf%7B%5Cf.*1fb%7D..-%7D%2F%3BC%7D%0A%0A~%5B_%5CE%3D%5B%22Err%22%22Ok%22%5D%3D%5Dp%7D%2F&input=%5B%5B42%5D%5D%2042%0A%5B%5B2%2C%203%5D%2C%20%5B1%2C%204%5D%5D%205%0A%5B%5B1%2C%202%2C%203%5D%2C%20%5B4%2C%205%2C%206%5D%2C%20%5B7%2C%208%2C%209%5D%5D%200%0A%5B%5B13%2C%2017%2C%2024%5D%2C%20%5B19%2C%201%2C%203%5D%2C%20%5B-5%2C%204%2C%200%5D%5D%201533%0A%5B%5B372%2C%20-152%2C%20244%5D%2C%20%5B-97%2C%20-191%2C%20185%5D%2C%20%5B-53%2C%20-397%2C%20-126%5D%5D%2046548380%0A%5B%5B100%2C%20-200%2C%2058%2C%204%5D%2C%20%5B1%2C%20-90%2C%20-55%2C%20-165%5D%2C%20%5B-67%2C%20-83%2C%20239%2C%20182%5D%2C%20%5B238%2C%20-283%2C%20384%2C%20392%5D%5D%20571026450%0A%5B%5B432%2C%2045%2C%20330%2C%20284%2C%20276%5D%2C%20%5B-492%2C%20497%2C%20133%2C%20-289%2C%20-28%5D%2C%20%5B-443%2C%20-400%2C%2056%2C%20150%2C%20-316%5D%2C%20%5B-344%2C%20316%2C%2092%2C%20205%2C%20104%5D%2C%20%5B277%2C%20307%2C%20-464%2C%20244%2C%20-422%5D%5D%20-51446016699154%0A%5B%5B416%2C%2066%2C%20340%2C%20250%2C%20-436%2C%20-146%5D%2C%20%5B-464%2C%2068%2C%20104%2C%20471%2C%20-335%2C%20-442%5D%2C%20%5B159%2C%20-407%2C%20310%2C%20-489%2C%20-248%2C%20370%5D%2C%20%5B62%2C%20277%2C%20446%2C%20-325%2C%2047%2C%20-193%5D%2C%20%5B460%2C%20460%2C%20-418%2C%20-28%2C%20234%2C%20-374%5D%2C%20%5B249%2C%20375%2C%20489%2C%20172%2C%20-423%2C%20125%5D%5D%2039153009069988024%0A%5B%5B-246%2C%20-142%2C%20378%2C%20-156%2C%20-373%2C%20444%5D%2C%20%5B186%2C%20186%2C%20-23%2C%2050%2C%20349%2C%20-413%5D%2C%20%5B216%2C%201%2C%20-418%2C%2038%2C%2047%2C%20-192%5D%2C%20%5B109%2C%20345%2C%20-356%2C%20-296%2C%20-47%2C%20-498%5D%2C%20%5B-283%2C%2091%2C%20258%2C%2066%2C%20-127%2C%2079%5D%2C%20%5B218%2C%20465%2C%20-420%2C%20-326%2C%20-445%2C%2019%5D%5D%20-925012040475554%0A%5B%5B-192%2C%20141%2C%20-349%2C%20447%2C%20-403%2C%20-21%2C%2034%5D%2C%20%5B260%2C%20-307%2C%20-333%2C%20-373%2C%20-324%2C%20144%2C%20-190%5D%2C%20%5B301%2C%20277%2C%2025%2C%208%2C%20-177%2C%20180%2C%20405%5D%2C%20%5B-406%2C%20-9%2C%20-318%2C%20337%2C%20-118%2C%2044%2C%20-123%5D%2C%20%5B-207%2C%2033%2C%20-189%2C%20-229%2C%20-196%2C%2058%2C%20-491%5D%2C%20%5B-426%2C%2048%2C%20-24%2C%2072%2C%20-250%2C%20160%2C%20359%5D%2C%20%5B-208%2C%20120%2C%20-385%2C%20251%2C%20322%2C%20-349%2C%20-448%5D%5D%20-4248003140052269106%0A%5B%5B80%2C%20159%2C%20362%2C%20-30%2C%20-24%2C%20-493%2C%20410%2C%20249%2C%20-11%2C%20-109%5D%2C%20%5B-110%2C%20-123%2C%20-461%2C%20-34%2C%20-266%2C%20199%2C%20-437%2C%20445%2C%20498%2C%2096%5D%2C%20%5B175%2C%20-405%2C%20432%2C%20-7%2C%20157%2C%20169%2C%20336%2C%20-276%2C%20337%2C%20-200%5D%2C%20%5B-106%2C%20-379%2C%20-157%2C%20-199%2C%20123%2C%20-172%2C%20141%2C%20329%2C%20158%2C%20309%5D%2C%20%5B-316%2C%20-239%2C%20327%2C%20-29%2C%20-482%2C%20294%2C%20-86%2C%20-326%2C%20490%2C%20-295%5D%2C%20%5B64%2C%20-201%2C%20-155%2C%20238%2C%20131%2C%20182%2C%20-487%2C%20-462%2C%20-312%2C%20196%5D%2C%20%5B-297%2C%20-75%2C%20-206%2C%20471%2C%20-94%2C%20-46%2C%20-378%2C%20334%2C%20407%2C%20-97%5D%2C%20%5B-140%2C%20-137%2C%20297%2C%20-372%2C%20228%2C%20318%2C%20251%2C%20-93%2C%20117%2C%20286%5D%2C%20%5B-95%2C%20-300%2C%20-419%2C%2041%2C%20-140%2C%20-205%2C%2029%2C%20-481%2C%20-372%2C%20-49%5D%2C%20%5B-140%2C%20-281%2C%20-88%2C%20-13%2C%20-128%2C%20-264%2C%20165%2C%20261%2C%20-469%2C%20-62%5D%5D%20297434936630444226910432057)
### Dissection
This implements the [Faddeev-LeVerrier algorithm](https://en.wikipedia.org/wiki/Faddeev%E2%80%93LeVerrier_algorithm), and I think it's the first answer to take that approach.
> 
> The objective is to calculate the coefficients \$c\_k\$ of the characteristic polynomial of the \$n\times n\$ matrix \$A\$,
>  $$p(\lambda )\equiv \det(\lambda I\_{n}-A)=\sum \_{k=0}^{n}c\_{k}\lambda ^{k}$$
>  where, evidently, \$c\_n = 1\$ and \$c\_0 = (‚àí1)^n \det A\$.
> 
> 
> The coefficients are determined recursively from the top down, by dint of the auxiliary matrices \$M\$,
>  $$\begin{aligned}M\_{0}&\equiv 0&c\_{n}&=1\qquad &(k=0)\\M\_{k}&\equiv AM\_{k-1}+c\_{n-k+1}I\qquad \qquad &c\_{n-k}&=-{\frac {1}{k}}\mathrm {tr} (AM\_{k})\qquad &k=1,\ldots ,n~.\end{aligned}$$
> 
> 
> 
The code never works directly with \$c\_{n-k}\$ and \$M\_k\$, but always with \$(-1)^k c\_{n-k}\$ and \$(-1)^{k+1}AM\_k\$, so the recurrence is
$$(-1)^k c\_{n-k} = \frac1k \mathrm{tr} ((-1)^{k+1} AM\_{k}) \\
(-1)^{k+2} AM\_{k+1} = (-1)^k c\_{n-k}A - A((-1)^{k+1}A M\_k)$$
```
{               e# Define a block
  :A            e#   Store the input matrix in A
  _,            e#   Take the length of a copy
  {             e#     for i = 0 to n-1
                e#       Stack: (-1)^{i+2}AM_{i+1} i
    1$_,,.=1b   e#       Calculate tr((-1)^{i+2}AM_{i+1})
    \)/:C       e#       Divide by (i+1) and store in C
    Aff*        e#       Multiply by A
    A@          e#       Push a copy of A, bring (-1)^{i+2}AM_{i+1} to the top
    zf{\f.*1fb} e#       Matrix multiplication
    ..-         e#       Matrix subtraction
  }/
  ;             e#   Pop (-1)^{n+2}AM_{n+1} (which incidentally is 0)
  C             e#   Fetch the last stored value of C
}
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 28 bytes
```
@(x)round(prod(diag(qr(x))))
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0KzKL80L0WjoCg/RSMlMzFdo7AIKAgE/9M0oqONzY10FHQNTYGkkYlJrLVCtK6lOUjE0lBHwdDCFCxiagwUMYaIG5nFxmr@BwA "Octave ‚Äì Try It Online")
This uses the [QR decomposition](https://en.wikipedia.org/wiki/QR_decomposition) of a matrix **X** into an orthgonal matrix **Q** and an upper triangular matrix **R**. The determinant of **X** is the product of those of **Q** and **R**. An orthogonal matrix has unit determinant, and for a triangular matrix the determinant is the product of its diagonal entries. Octave's `qr` function called with a single output gives **R**.
The result is rounded to the closest integer. For large input matrices, floating-point inaccuracies may produce an error exceeding `0.5` and thus produce a wrong result.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 3 bytes / 5 bytes
### With built-in function
```
&0|
```
[Try it online!](https://tio.run/##y00syfn/X82g5v//aGNzIx0FXUNTIGlkYmKtoGtpDuJbGuooGFqYAvmmxkC@MUTUyCwWAA)
### Without built-in
*Thanks to [Misha Lavrov](https://codegolf.stackexchange.com/users/74672/misha-lavrov) for pointing out a mistake, now corrected*
```
YvpYo
```
[Try it online!](https://tio.run/##y00syfn/P7KsIDL///9oY3MjHQVdQ1MgaWRiYq2ga2kO4lsa6igYWpgC@abGQL4xRNTILBYA)
This computes the determinant as the product of the eigenvalues, rounded to the closest integer to avoid floating-point inaccuracies.
```
Yv       % Implicit input. Push vector containing the eigenvalues
p        % Product
Yo       % Round. Implicit display
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 30 bytes
```
@(x)-prod(diag([~,l,~]=lu(x)))
```
[Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0JTt6AoP0UjJTMxXSO6TidHpy7WNqcUKK6p@T9NIzra2NxIR0HX0BRIGpmYxForROtamoNELA11FAwtTMEipsZAEWOIuJFZbKzmfwA "Octave ‚Äì Try It Online")
or, the boring 4 byte solution (saved 6 bytes thanks to Luis Mendo (forgot the rules regaring builtin functions)):
```
@det
```
### Explanation:
Coming up! :)
[Answer]
# TI-Basic, 2 bytes
```
det(Ans
```
Ah, well.
[Please don't upvote trivial answers.](https://codegolf.meta.stackexchange.com/questions/10127/how-can-we-help-users-who-are-put-off-by-the-use-of-golfing-languages/10132#10132)
As a high school student (who's forced to own one of these calculators), this function is hella useful so...
[Answer]
# Haskell, 62 bytes
```
a#((b:c):r)=b*d(a++map tail r)-(a++[c])#r
_#_=0
d[]=1
d l=[]#l
```
[Try it online!](https://tio.run/##VVTRahsxEHz3Vwj8Yrd3Rdrd00kBf0K/wJjgxIWGOiG4@X93Z/YM10CEpdPOzu7M6vf5759f1@v9ft7udi9Pr/un2/7w8u2yO3///n7@TF/nt2u67Ufsj6@n/fa2ed4@H/LmcjwdyuaSrofjaXu9v5/fPtIhecjPtPu8vX18pR/pst8k/zum49HkdOJm8I0MSU/@owzJVse@fXyxIU1Dqvg5D6kNqa/v6ZCKH4sRpPtuCRs9yEPz6rLOjjmWSXCfAWOfcdI9qLQpwhxx1DiXuk6Vs58J1qmBbbAeO46nCfdrQFQEN8cRBaEmOBVtCMexNiemfd0GUydlDqLqcIILMrPm0To@gVBRJUTnGh8NR0ZS1W9MIKMlItWQp/g5ICQ7fMnkLbPDaQZPq8Z24Kf8RwmB1f/VQInIphV12sIMobUR1SnO6IYqOmHGmsvUyQ7JCuODu3mMzhlXKpiBjRmgVSBbiBLqV4/jMlqJDqKvoKtz1GIdaIgDeqHIJjCGTKt6PG2Qh7HmRicw5azIHno2NBHLCADUrMYaCtkIelIeXKDowjXKzWACFUcltHSsvGI9BKMB4DeBiSoZiV@Ye@ADsrKFQimFCMAsa98jpR8ZWw6GFlkyHYIZiN6wcSG00j2s1mEN0Ubu1EFzWYSAAuwONqWh/Tl8bRlkOh2G8pW1kzKRJAZPqDfSlJBbOvPUGBxvRQk41GbU1MMpG11WQFqnvoDBX9GLNoEdihN51O29aau@gC5dp5VX8oLuSaEyTEi/OG0sOZIUmrMIZ6lGTxEIeUpnFqVFYbKOJ4gDUGYKhbni/I5o2ISlggFnxaf40Sl/OiJbDtuRxhT@gXGZnvalroq2FXRMF5oc5ZGPigoRSa1hhDoIt/qwjPFVkk7hKovJrBgPFZ@ionz0OCwtHgJ2rCB/1Ofx@MAqBaRjxJkqpnWmDTD8tFifo0BjO1F0IPDhFUwujUMNRwhS@Ha3yNY5ODlGHZYmYYtXF7Sj2vIAdE1X6YQfGp3LRgqdhdoLBkqoq0GZsfo7l073fw "Haskell ‚Äì Try It Online") (Footer with test cases taken from @totallyhuman's solution.)
`d` computes the determinant using a Laplace expansion along the first column. Needs three bytes more than the [permanent](https://codegolf.stackexchange.com/a/96837/56725).
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~53~~ 52 bytes
```
1##&@@@(t=Tuples)@#.Signature/@t[Range@Tr[1^#]&/@#]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n1aaZ/vfUFlZzcHBQaPENqS0ICe1WNNBWS84Mz0vsaS0KFXfoSQ6KDEvPdUhpCjaME45Vk3fAUj8DyjKzCuJBuqPrq5O1EnSSa7VqU7RSdVJA9LpOhk6mbW1sbFcEFUuqSX4VP0HAA "Wolfram Language (Mathematica) ‚Äì Try It Online")
Unfortunately, computing the determinant of an *n* by *n* matrix this way uses O(*n**n*) memory, which puts large test cases out of reach.
## How it works
The first part, `1##&@@@(t=Tuples)@#`, computes all possible products of a term from each row of the given matrix. `t[Range@Tr[1^#]&/@#]` gives a list of the same length whose elements are things like `{3,2,1}` or `{2,2,3}` saying which entry of each row we picked out for the corresponding product.
We apply `Signature` to the second list, which maps even permutations to `1`, odd permutations to `-1`, and non-permutations to `0`. This is precisely the coefficient with which the corresponding product appears in the determinant.
Finally, we take the dot product of the two lists.
---
If even `Signature` is too much of a built-in, at **73 bytes** we can take
```
1##&@@@(t=Tuples)@#.(1##&@@Order@@@#~Subsets~{2}&/@t[Range@Tr[1^#]&/@#])&
```
replacing it by `1##&@@Order@@@#~Subsets~{2}&`. This computes `Signature` of a possibly-permutation by taking the product of `Order` applied to all pairs of elements of the permutation. `Order` will give `1` if the pair is in ascending order, `-1` if it's in descending order, and `0` if they're equal.
---
*-1 byte thanks to @user202729*
[Answer]
# [Python 2](https://docs.python.org/2/), 75 bytes
```
f=lambda m,p=[]:m[0][0]*f(zip(*p+m[1:])[1:])-f(m[1:],p+m[:1])if m else[]==p
```
[Try it online!](https://tio.run/##TY/RqsIwEETf@xXz2Ho3YNLW2kK@JOyDl9twA6YG2xf9@bqNioYQdk5mBjbdlv/LZNbV2/Mp/v6dEClZx0N0e5a78@U9pHKXfqLTA1f5Ub7MijY6aK6CR8R4nkfH1qZ1GedlhoUrIMe5xjDTazaEmglOE5oPFfX@aAgt4bCNHeFI6L9sNUELNU2u6EW9Ukoyktx/vHUnjUq3ZrNnv@q7jfSS0cf2mZJCVT@5OTAXXBT@ckVAmJDXGHJduoZpgS9DtT4A "Python 2 ‚Äì Try It Online")
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), ~~195 192 177~~ 176 bytes
```
long d(int[][]m){long D=0;for(int i=m.length,l=i-1,t[][]=new int[l][l],j,k;i-->0;D+=m[0][i]*(1-i%2*2)*(l<1?1:d(t)))for(j=l*l;j-->0;)t[j/l][k=j%l]=m[1+j/l][k<i?k:k+1];return D;}
```
[Try it online!](https://tio.run/##rVZNb9tGEL3nV8wlgGhzbe4Hl7tR1Fx87SlHQQc1Ul1KlGTYdIrC0G93Z97IRoCsiqKqIYjycjjz5r354Gb5fWkOD@v9ZrV9/TYsn57o12W/f/lA9DQux/4bvQ6H/T2tJv1@nC/mi131goO7WTP9/fAox9TPdjfDen8//lEPs97YGpaz/fpPkqeGBX/qTb2d9sb80kzvrme7ebOY94uriTX9R3flqqvJ8Nl@sZ9Wk7GqKnG8mQ1Xw3SDJ6pxvrllN9vZ5uOw4Kfttf7/uf@y/bS9tovp43p8ftzT3fT4SvTw/NvA0E8ZfD/0K9pxVpOv42O/v58vlpUkSPT1r6dxvbs5PI83D3xnHPaT1eQNNqegVkTvRy/BHXF2rKrpf3ThavLH@qdjW1O42Dc7OeM@1NTWFAt3uppSTfny2L4my85cKGWXayJGV8RmGBkxQGouBuE7zt/Ylr8ZSAmJyZ1YZAFjU1uEw5kYr3YuXk5M07AnJ9/UMtX8VwKm/Jgsxm0rsWMRXezELDFG58FqcgUz55MEFTOfhFufLy/d4J3CF8G8l4QcnLuuVFkmZLEPwiRZ7wFIIPOlaB7EJIAoaqM81Aob3ha9@4C8rBgSIrlGgNmmRK/rBAX5RmQNMWiByG/3PxCjICjKxQcQA@jBR1EylOkBCopJQQtVnZV8vcgfQklX24LAIGlw7oghnBoXxI3vmsJDUWVTCkIQSN4JVRwQzVCcGBE64GKCTaqbZOaFNt8VWQ4ZLHdoaYht0ZLBefnt2ou55kyVU4d8E/odKXUe6RXnT4JAejHA0iI9L4A5vRID7qSqNOaJAX/qX6WtKFCjDEiPGA9gLiMqHgq5WPpoVK5ii8pBkIgsHaq2y0V4SQVCtTh0iouoHGhrL5/pkqPIFlCW0DZoGo0HkVZzLaFD@RjtN4/mh0CMMcBlAIWlcvUN3J46VguVoDNObBLPoSlOx9BAM5MxNyCZh1gnshDVFbeQa3RCCEirPeUyQMKlqMLy2WJUB5OgTYKuRtVjCJAFFb7N5ahof5UvtdAfi9K5N85Z0PSDlLe3/05MtfsxGIiTqZqJao@pYDDFgZmTQwNZjC@IzbQJAY0g/9kd322UToxUrC/MBoc5aDOwex06GAgZIuRYdGcxNFhBmOqqMRC8xXfMUBMd1cV3ZXmxnkHX6FSAhq12LAYS8GIsaWUz1zhH3/lzyWLRGN25Hm1pUB4hYfXkgLUc37qQk8Xaz23RnY5@Bg@CW@iO4WK9vplgaCZdVqgEC7xnuOM4YqoMOvQAdgk3AnDpzO@0H7BpUOz8MnSGuwBloZ26xpsVOWwAbSytU4OisRaW6Qy63Gqp6SrBgMRI0TC6tunEpn0PxgX5T@hcQvyEprPQ1OGlB9zaCE4jZjdKx0Re9OrtNBKPH46vfwM "Java (OpenJDK 8) ‚Äì Try It Online")
Like many other answers, this also uses the Laplace formula. A slightly less golfed version:
```
long d(int[][]m){
  long D=0;
  int i=m.length,l=i-1,t[][]=new int[l][l],j,k
  for(;i-->0;)
    for(j=l*l;j-->0;)
      t[j/l][k=j%l]=m[1+j/l][k<i?k:k+1];
    D+=m[0][i]*(1-i%2*2)*(l<1?1:d(t));
  return D;
}
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 3 bytes
```
Det
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b73yW15H9AUWZeSXRadDVXNaehDqeRDqdxrQ6QbaLDaarDaQZmm@twWuhwWtZy1cbG/gcA "Wolfram Language (Mathematica) ‚Äì Try It Online")
Per the [meta consensus](https://codegolf.meta.stackexchange.com/questions/13128/non-trivial-answers-get-too-few-upvotes), mainly upvote nontrivial solutions that take effort to write.
[Answer]
# [Python 2](https://docs.python.org/2/), 95 bytes
*-12 bytes thanks to Lynn.*
Port of [my Haskell answer](https://codegolf.stackexchange.com/a/147709/68615).
```
f=lambda m:sum((-1)**i*v*f([j[:i]+j[i+1:]for j in m[1:]])for i,v in enumerate(m[0]))if m else 1
```
[Try it online!](https://tio.run/##TY/RroIwEETf@Yp9pLhNbAEREr@k2QdubptbYtFANfHrcVs13j7tnM5MMtdH/LvMetvc6TyGn98RwrDeQllKJarKV/fKlWYyg6fdZPxODeQuC0zgZwiGFYmkPd4TsfMt2GWMtgxmT0J4BwHsebWgtmjXuMIJTAH8jGk0Eb5vjVATglEIzZey@nw0CC3CIZ0dwhGh/2erERRT3eSKntU7JTnDyf3XW3fcKFWrkz37Zd8l0nNGHdtXigtl/eL6QFRQUeSRaWKeMeS66@LnCK70YnsC "Python 2 ‚Äì Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), ~~**238 bytes**~~, ~~**227 bytes**~~, ~~**224 bytes**~~, **216 bytes**
```
from functools import*
from itertools import*
r=range;n=len;s=sum
f=lambda l:s(reduce(lambda p,m:p*m,[l[a][b]for a,b in zip(r(n(l)),j)])*(-1)**s(s(y<j[x]for y in j[x:])for x in r(n(l)))for j in permutations(r(n(l))))
```
[Try it online!](https://tio.run/##ZVPLbttADLznK/YoGRKgJanHJvWXCD44id3asB6QZCDpz7scroyi6sELL5czHA6p8Xv5NfT8eJynoXPne/@xDMNtdpduHKZl92Lhy3Ka/g1P@@nY/zy99fvbqX@b9/O9eznvb8fu/fPobq9zMp0@7x@nZI2MWfc67rqsvbXHQ/t@OA@TO2bv7tK735cxmZI@uaVpdk0P6S7JfbrbzcmcfP@4tl@W@41MvbweUly/cF1BFrgiMJ6m7r4cl8vQz0/KNH2M06VfknPStkKHQ5q@/A1Q5viQudZnTjZPGnq@SubKzFX4W2euyVzY5nLmvD6RGFnQ2wrNFajwYgPgWrlzXxIwBspDjUhQoG/KCFXWnGOcqm3JotA44SwbqI9d5AHhsgSmijQVCBrlIoawhhAlbgBHmBsVyGFrjbCKEyViVkpCEtXmQS4BTxDmmY0m2BkfBSExYZVmlBDEPiJZUMtrHBRUKL0vTDvVSscFtEolZgv@0n@yAK70xwJZxi5coV9Z1QFeNcasMmu4wgxHRKx3XwZTiILe8FG/KIbrAikV1EGRCKiZMMY4oLgRleLsyMVHJ@EvJHMd@5EANuDA7m3gQlgUKjc9aenYABaubmwzrGzNUBBn28BMHDlI0DeL9eFNEcEX/9SD6a56Y8sF1GCaORs1BZyWIiEOzpYB@0dYqMoUkSbUIfKDsjIbyUZKxgBOv/0eUFbDYtZDpcRKhW0Lvo3okRkYh862SdaxUgvQYvptHlz4dSCYhDmEi28whiLuuRQQFGzbYAFb/ybbmCh@kGRzRxkfx07B6lTxQ1I7fKRDf2KzVbiNz7bNQzSXYSXDnkU/mhLq0BzRs2/1p4E3jz8 "Python 3 ‚Äì Try It Online")
My solution uses the definition of a determinant for calculations. Unfortunately, the complexity of this algorithm is `n!` and I can not show the passage of the last test, but in theory this is possible.
[Answer]
## [SageMath](http://www.sagemath.org/), various
Here are a bunch of methods for computing the determinant that I found interesting, all programmed in SageMath. They can all be tried [here](http://sagecell.sagemath.org/?z=eJyVk11v0zAUhu8j5T8clRu7uFWTDSEqwd24mDqE4DIKzE1OUrf-iGyHdUP8d-x07VKtQqJXzfny857XvoOPoLi3Yk-KImdwVTIoMgbXZUnT5C4fp7MrBtl7Bvn1UPQhfD03zN6FDgaLoSlN3sC6F9ILDTX6NOms0D7-JXf07CsfqofAoa2zpu4rD6YBFC3qX1z26NKkCRiSq3XNQS0tckliJVHzURWh9DS9GZ3U_PucWvDWaC4BJSrU3kHAvjW25pG-MqozTnhhNMzAaPkID8buHDTGguUxHltfKGCNFe8dxtGNQFmDcG7Q0I41PONvh3N-hmGK0GLP9mWcu48IlusWQ4m25uFMWzto8_ZxmSYQfqdoVIn7Cjt_lpncfvkMDRfyAK2Nnl0Cn_znir4r4TfnG0qTzQWNLhYeJS7K-XEaeZG0Gdm1uWDXineSVwi477h20QsujW7Bmw7CetJkNT73tLNPGdc1uF4RMsvodLqdqmLBtuV0RVSRLdlyW85530ZJh8D2bbYsKY1r2p55UBk5eBASccSiPNKuRuSrS-Qo1lo8xc2rXvJAmo9RI5trNeno9LCtYse6YlfOsuEi7C5CxEwXM18xDPWDl25ccALKx3T5BbxvSPCHt0RqokIjG27I0SDxxNcSD8-_Cjd7BhZ9b7UD96jWRooqGmLRRUcYOAPx3t9rQu-DM9CiB90rtLHOeRHmYJrcvHrJYQaJe1C8Cxzs1Zt-0XMzknMT1TCYkN9_6GQe18s90WQIU_oXzJuCHw==&lang=sage).
### Builtin, 3 bytes
```
det
```
This one isn't too interesting. Sage provides global-level aliases to many common operations that would normally be object methods, so this is shorter than `lambda m:m.det()`.
---
### Real Part of Product of Eigenvalues, 36 bytes
```
lambda m:real(prod(m.eigenvalues()))
```
Unfortunately, `eigenvalues` is not one of those global-level aliases. That, combined with the fact that Sage doesn't have a neat way to compose functions, means we're stuck with a costly `lambda`. This function symbolic values which are automatically converted to numeric values when printed, so some floating point inaccuracy may be present in some outputs.
---
### Product of Diagonal in Jordan Normal Form, 60 bytes
```
lambda m:prod(m.jordan_form()[x,x]for x in range(m.nrows()))
```
In Jordan Normal form, an NxN matrix is represented as a block matrix, with N blocks on the diagonal. Each block consists of either a single eigenvalue, or a MxM matrix with a repeated eigenvalue on the diagonal and `1`s on the super-diagonal (the diagonal above and to the right of the "main" diagonal). This results in a matrix with all eigenvalues (with multiplicity) on the main diagonal, and some `1`s on the super-diagonal corresponding to repeated eigenvalues. This returns the product of the diagonal of the Jordan normal form, which is the product of the eigenvalues (with multiplicty), so this is a more roundabout way of performing the same computation as the previous solution.
Because Sage wants the Jordan normal form to be over the same ring as the original matrix, this only works if all of the eigenvalues are rational. Complex eigenvalues result in an error (unless the original matrix is over the ring `CDF` (complex double floats) or `SR`). However, this means that taking the real part is not necessary, compared to the above solution.
---
### Product of Diagonal in Smith Decomposition
```
lambda m:prod(m.smith_form()[0].diagonal())
```
Unlike Jordan normal form, Smith normal form is guaranteed to be over the same field as the original matrix. Rather than computing the eigenvalues and representing them with a block diagonal matrix, Smith decomposition computes the elementary divisors of the matrix (which is a topic a bit too complicated for this post), puts them into a diagonal matrix `D`, and computes two matrices with unit determinant `U` and `V` such that `D = U*A*V` (where `A` is the original matrix). Since the determinant of the product of matrices equals the product of the determinants of the matrices (`det(A*B*...) = det(A)*det(B)*...`), and `U` and `V` are defined to have unit determinants, `det(D) = det(A)`. The determinant of a diagonal matrix is simply the product of the elements on the diagonal.
### Laplace Expansion, 109 bytes
```
lambda m:m.nrows()>1and sum((-1)**j*m[0,j]*L(m[1:,:j].augment(m[1:,j+1:]))for j in range(m.ncols()))or m[0,0]
```
This performs Laplace expansion along the first row, using a recursive approach. `det([[a]]) = a` is used for the base case. It should be shorter to use `det([[]]) = 1` for the base case, but [my attempt](http://sagecell.sagemath.org/?z=eJxNjUEOgjAQRfck3GGWHRwILRgjiTeAEzRdVEFCQ4spED2-FTVhNZn35_1p4AJWL354MSkFQaEIJCcolcI4asQ-5gUBPxGIcjs6h-0npMdgEOSbFEd1sEZtr60GW9nM-ek5M9SuhXm1jKUck8QkVuZkVFIzK3lFlVGZXnvbueULzIFXCvE-eTAwOPDa9R0LbbdpDG2IIeCfbw8_uAVq1iBB2y1h7pj4Q4Fvguc_gA==&lang=sage) at that implementation had a bug that I haven't been able to track down yet.
---
### Leibniz's Formula, 100 bytes
```
L2 = lambda m:sum(sgn(p)*prod(m[k,p[k]-1]for k in range(m.ncols()))for p in Permutations(m.ncols()))
```
This directly implements Leibniz's formula. For a much better explanation of the formula and why it works than I could possibly write, see [this excellent answer](https://codegolf.stackexchange.com/a/147723/45941).
---
### Real Part of `e^(Tr(ln(M)))`, 48 bytes
```
lambda m:real(exp(sum(map(ln,m.eigenvalues()))))
```
This function returns symbolic expressions. To get a numerical approximation, call `n(result)` before printing.
This is an approach that I haven't seen anyone use yet. I'm going to give a longer, more-detailed explanation for this one.
Let `A` be a square matrix over the reals. By definition, the determinant of `A` is equal to the product of the eigenvalues of `A`. The trace of `A` is equal to the sum of `A`'s eigenvalues. For real numbers `r_1` and `r_2`, `exp(r_1) * exp(r_2) = exp(r_1 + r_2)`. Since the [matrix exponential function](https://en.wikipedia.org/wiki/Matrix_exponential) is defined to be analogous to the scalar exponential function (especially in the previous identity), and the matrix exponential can be computed by diagonalizing the matrix and applying the scalar exponential function to the eigenvalues on the diagonal, we can say `det(exp(A)) = exp(trace(A))` (the product of `exp(Œª)` for each eigenvalue `Œª` of `A` equals the sum of the eigenvalues of `exp(A)`). Thus, if we can find a matrix `L` such that `exp(L) = A`, we can compute `det(A) = exp(trace(L))`.
We can find such a matrix `L` by computing `log(A)`. The matrix logarithm can be computed in the same way as the matrix exponential: form a square diagonal matrix by applying the scalar logarithm function to each eigenvalue of `A` (this is why we restriced `A` to the reals). Since we only care about the trace of `L`, we can skip the construction and just directly sum the exponentials of the eigenvalues. The eigenvalues can be complex, even if the matrix isn't over the complex ring, so we take the real part of the sum.
[Answer]
# Java 8, ~~266~~ ~~261~~ ~~259~~ 258 bytes
```
long d(int[][]m){long r=0;int i=0,j,k,l=m.length,t[][]=new int[l-1][l-1],q=m[0][0];if(l<3)return l<2?q:q*m[1][1]-m[0][1]*m[1][0];for(;i<l;r+=m[0][i]*(1-i++%2*2)*d(t))for(j=0;++j<l;)for(k=l;k-->0;){q=m[j][k];if(k<i)t[j-1][k]=q;if(k>i)t[j-1][k-1]=q;}return r;}
```
Look mom, no build-ins.. because Java has none.. >.>
-7 bytes thanks to *@ceilingcat*.
**Explanation:**
[Try it here.](https://tio.run/##rVbLbuNGELzvV8wlgGhxvPPicCayNl@Q0x4FHpSV1qFESbZMbxAY@nanu1p2FthREEQxDFIaNburq/rBzfLbUh8e1vvNavv6ZVg@Palfl/3@5YNST@Ny7L@o1@Gwv1erSb8fF92i21UvODjOzYyOVD839abe1sN8dzus9/fj7zXs5vv1H4qfGbTtcKkf57uF6eh/1n@dDHe@Oq7H5@NeDXful8efH292C7K0nYaV7eQ7WX89HCez/m6YHafioe9uJlb30@lP7sZVN6vJWFVstCFM0@mGLPF1Ox9mW60/mVn1wrE33WKL2Nu7vhoXGwa27eaPOPr09xFd6PB0RnecnV6Venj@bSAyzpx8O/QrtSOeJp/HY7@/X3TLiilT6vOfT@N6d3t4Hm8f6Jdx2E9WkzcqiBaxUur96CW4E85OVTX7jy5crfyp/uHY1ipc7ZucXHAfatXUKhZ@aWuVapWvj@1rZcmZC6Xscq0UoSti04RMEUBlrgbhW8pf24auBKSEROeWLTKDsakpwqFMtBc7F68nxhjy5PiqGqKa/krAhB@d2bhpOHYsoostmyXC6DxYTa5g5nzioGzmE3Pr8/WlG7wT@CyY95yQg3PXlipLh8z2gZlU1nsAYsh0K5oHNgkgSjWRH2qYDW@L3n1AXpYNFSI5w8CsKdHrWkahvGFZQwxSIPzZ/Q/ECAgV@eYDiAH04CMrGcr0AIWKSUAzVa3lfD3LH0JJV9uAwMBpUO6IwZxqF9iNb03hoSiyCQUhMCTvmCoKiGYoTowIHXDTwSbRjTPzTJtviyyHDJZbtDTEtmjJ4Dx/ds3VXFOmwqlDvgn9jpRaj/SK8ydBILlpYGmQnmfAlF6JAXdWlRvzzIA/96/QVhTICAPcI9oDmMuIiodCLpY@GpWq2KJyECQiS4eqbXMRXhKBUC0OneIiKgfa2utnOufIsgWUJbQNkobxINJKriV0KB8t/ebR/BCIMAa4DKCwVK7ewO25Y6VQFXTGiU3sOZjidAwGmumMuQHJPMQ6k4WorriFnJEJwSCt9JTLAAmXrArJZ4tRHUyCNAm6GlWPIaAsqPBNLkdF@4t8qYH@WJTOvXFOgqbvpPz48d@JKXbfBwNxPFWzUrXHVNCY4sBMyaGBLMYXxCbamADDyH90R78aoRMjFesLs8FhDtoM7F6GDgZChgg5Ft1ZDA1SEKayajQEb3CNGWqio9r4riwt1gvojEwFaNhIx2IgAS/GklQ2cY1z9J2/lCwWjZad69GWGuURElZPDljL8a0LKVms/dwU3cnoJ/AguIHuGC7Wy5sJhmaSZYVKsMB7gTuKw6bCoEMPYJdQIwCXzPxW@gGbBsVOL0MXuAtQFtqJa7xZKYcNII0ldapRNNbCMl1AlxspNVklGJAYKRJG1rY6s2nfg1FB/hM6lxA/oeksNHV46QG3NoLTiNmN0tGRFr14O4/E04fT618) (Only the last test case is too big to fit in a `long` of size 263-1.)
```
long d(int[][]m){             // Method with integer-matrix parameter and long return-type
  long r=0;                   //  Return-long, starting at 0
  int i=0,j,k,                //  Index-integers
      l=m.length,             //  Dimensions of the square matrix
      t[][]=new int[l-1][l-1],//  Temp-matrix, one size smaller than `m`
      q=m[0][0];              //  The first value in the matrix (to reduce bytes)
  if(l<3)                     //  If the dimensions are 1 or 2:
    return l<2?               //   If the dimensions are 1:
      q                       //    Simply return the only item in it
     :                        //   Else (the dimensions are 2):
      q*m[1][1]-m[0][1]*m[1][0];
                              //    Calculate the determinant of the 2x2 matrix
                              //  If the dimensions are 3 or larger: 
  for(;i<l;                   //  Loop (1) from 0 to `l` (exclusive)
      r+=                     //    After every iteration: add the following to the result:
         m[0][i]              //     The item in the first row and `i`'th column,
         *(1-i++%2*2)         //     multiplied by 1 if `i` is even; -1 if odd,
         *d(t))               //     multiplied by a recursive call with the temp-matrix
    for(j=0;                  //   Reset index `j` to 0
        ++j<l;)               //   Inner loop (2) from 0 to `l` (exclusive)
      for(k=l;k-->0;){        //    Inner loop (3) from `l-1` to 0 (inclusive)
        q=m[j][k];            //     Set the integer at location `j,k` to reduce bytes
        if(k<i)               //     If `k` is smaller than `i`:
          t[j-1][k]=q;        //      Set this integer at location `j-1,k`
        if(k>i)               //     Else-if `k` is larger than `i`:
          t[j-1][k-1]=q;      //      Set this integer at location `j-1,k-1`
                              //     Else: `k` and `i` are equals: do nothing (implicit)
      }                       //    End of inner loop (3)
                              //   End of inner loop (2) (implicit / single-line body)
                              //  End of loop (1) (implicit / single-line body)
  return r;                   //  Return the result-long
}                             // End of method
```
[Answer]
# JavaScript (ES6), 91
Recursive Laplace
```
q=(a,s=1)=>+a||a.reduce((v,[r],i)=>v-(s=-s)*r*q(a.map(r=>r.slice(1)).filter((r,j)=>j-i)),0)
```
*Less golfed*
```
q = (a,s=1) => // s used as a local variable
  a[1] // check if a is a single element array 
       // if array, recursive call expanding along 1st column
  ? a.reduce((v,[r],i) => v-(s=-s)*r*q(a.map(r=>r.slice(1)).filter((r,j)=>j-i)),0) 
  : +a // single element, convert to number
```
**Test**
```
q=(a,s=1)=>+a||a.reduce((v,[r],i)=>v-(s=-s)*r*q(a.map(r=>r.slice(1)).filter((r,j)=>j-i)),0)
TestCases=`[[42]] -> 42
[[2, 3], [1, 4]] -> 5
[[1, 2, 3], [4, 5, 6], [7, 8, 9]] -> 0
[[13, 17, 24], [19, 1, 3], [-5, 4, 0]] -> 1533
[[372, -152, 244], [-97, -191, 185], [-53, -397, -126]] -> 46548380
[[100, -200, 58, 4], [1, -90, -55, -165], [-67, -83, 239, 182], [238, -283, 384, 392]] -> 571026450
[[432, 45, 330, 284, 276], [-492, 497, 133, -289, -28], [-443, -400, 56, 150, -316], [-344, 316, 92, 205, 104], [277, 307, -464, 244, -422]] -> -51446016699154`
.split('\n')
TestCases.forEach(r=>{
  [a,k] = r.split (' -> ')
  a = eval(a)
  d = q(a)
  console.log('Test '+(k==d ? 'OK':'KO')+
    '\nMatrix '+a.join('|')+
    '\nResult '+d+
    '\nCheck  '+k)
})
```
[Answer]
# [Python 2](https://docs.python.org/2/) + [numpy](https://pypi.python.org/pypi/numpy/1.13.3), 29 bytes
```
from numpy.linalg import*
det
```
[Try it online!](https://tio.run/##Jci7CoAgFADQva@4Y4UFviqHvkQcgrKEfCA29PVmtZzhhDsd3pGcdfQW3GXD3Z/GLecOxgYfU1vped1SDtG4VOtaSjoSBB3mRcKYQiA7Mb4jMAI88W84LUP/J4NSTZMf "Python 2 ‚Äì Try It Online")
[Answer]
# [Julia](http://julialang.org/), 3 bytes
```
det
```
[Try it online!](https://tio.run/##yyrNyUw0/f8/zTYlteR/QVFmXolGmka0kYKxtaGCSaym5n8A "Julia 0.5 ‚Äì Try It Online")
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 6 bytes
```
matdet
```
[Try it online!](https://tio.run/##PVHJagMxDP0VHxOwwVq8iKFfEnoItCk5tAxh/n@ip2lyEbYsvcVvvT7u5Wfdb@kj7b/X7et729fH/W873U6XWXOiZjlJ55yK@LWwelGTnJT8zurPhQil2oIjpogFYx19wQb37liGYZXhy9q82MzJ@pJoNDxU9ARUA8QoHezSgTA6jgPHWsFU0ZYRAjBcAv@gpuEwpM4vjGZzJgmBQoEmAOZAC1HT59kgdQYsd@gLx9aW1MNEDZ/NZbI4IInfCZu@P8Jw/BOBG758F@1wx5CrAwhBo4d66MIPacWkDRjT@EJYPfYFZpgxSl64BYjbJMLMBJO1SAibSoZ08guJ8a//LukF5xm@qTjacwZrpDcjMkUA2I0cFVmUzp/n8/4E "Pari/GP ‚Äì Try It Online")
---
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 52 bytes
```
f(a)=if(#a,sum(n=1,#a,-(-1)^n*a[1,n]*f(a[^1,^n])),1)
```
[Try it online!](https://tio.run/##PVLJasMwEP0VQS92kECzaCPkS0ICvrjkUBPS9PvdeZOml0Eav3mLxvflcUuf930Np7Cv0zKfbuv0scTvn69pO1G0Y5oSzdftsJwpbpeDgc5XitftMs@R5v3@uG3PaZ3OPcdAZcQglWNIYtfEakWHxKBkd1b7nIhQ8jjiCBSxAFbRF0xwrcY1AFZpNqzFyugxjHoM1Ao@ZPQEUg3CKBXqUsHQKo4Nx5yhlNGW5gYATs7/kqZmNKSmL4xmMSVxg0LOJiBmZ3NT3fA8YLU7LVf488SjHEP1ENlzFrPJYoQkdidM2nzzwP5OBG3kslm0PR3DrjYwuIy@3MMXXkgzkKMhmPoTIuprXhCGGVCywsVJLCYRMB1Ko/iGMKk0sJ34ZmK8619KetPZDv@l2Nu9u6pvr/vKFAvArO9RsYtU2f6S/Rc "Pari/GP ‚Äì Try It Online")
[Answer]
# [J](http://jsoftware.com/), 5 bytes
```
-/ .*
```
[Try it online!](https://tio.run/##y/qfVqxga6VgoADE/3X1FfS0/mtyKekpqKfZWqkr6CjUWimkFXOlJmfkK6Qp2BkpGFsrGCqYwAUMjRUMzRWMTICilkAJoGy8qYKJAtAsAA "J ‚Äì Try It Online")
]