29 votes

Determinant of an Integer Matrix

Jelly, 15 bytes LŒ!ðŒcIṠ;ị"Pð€S Try it online! How it works ...
Leaky Nun's user avatar
  • 49.6k
26 votes

Construct the Identity Matrix

MATL, 2 bytes Xy A translation of my Octave answer. Try it online. A 4 byte version with no built-ins (thanks to Luis Mendo): ...
a spaghetto's user avatar
  • 11.2k
20 votes

Construct the Identity Matrix

TI-BASIC, 2 bytes identity(Ans Fun fact: The shortest way to get a list {N,N} is ...
lirtosiast's user avatar
  • 21.4k
19 votes

Find the inverse of a 3 by 3 matrix

MATL, 54 bytes th3LZ)t,3:q&XdpswP]w-lw/GtY*tXdsGXdsUw-IXy*2/+GtXds*-* Try it online! Just to keep it interesting, doesn't use the inbuilt matrix division or ...
Sundar R's user avatar
  • 6,612
18 votes

Construct the Identity Matrix

Julia, 9 3 bytes eye This is just a built-in function that accepts an integer n and returns an ...
Alex A.'s user avatar
  • 24.6k
18 votes

Construct the Identity Matrix

APL, 5 bytes ∘.=⍨⍳ This is a monadic function train that accepts an integer on the right and returns the identity matrix. Try it here
Alex A.'s user avatar
  • 24.6k
17 votes

Billiard balls collision

Python 3, 67 66 bytes, 53 bytes def f(p,v,q,w):p-=q;d=((v-w)/p).real*p;return v-d,w+d Try it online! -1 byte thanks to @ngn -13 bytes thanks to @Neil This ...
Joel's user avatar
  • 1,751
16 votes

Construct the Identity Matrix

Python 2, 42 bytes lambda n:zip(*[iter(([1]+[0]*n)*n)]*n)[:n] An anonymous function, produces output like ...
xnor's user avatar
  • 144k
16 votes

Find the Cross Product

Jelly, 14 13 12 bytes ;"s€2U×¥/ḅ-U Try it online! How it works ...
Dennis's user avatar
  • 210k
14 votes

Construct the Identity Matrix

Octave, 10 4 bytes @eye Returns an anonymous function that takes a number n and returns the identity matrix.
a spaghetto's user avatar
  • 11.2k
14 votes

Is the matrix rank-one?

Jelly, 6 bytes ẸÐfÆrE Try it online! How it works ...
Dennis's user avatar
  • 210k
14 votes

Eigenvalues of a Matrix

Haskell, 576 554 532 507 bytes No built-ins! ...
ბიმო's user avatar
  • 16.7k
14 votes

Calculate the Hafnian as quickly as possible

Haskell ...
Christian Sievers's user avatar
14 votes

Find the inverse of a 3 by 3 matrix

APL(Dyalog Classic),1 byte Try it online! if a flat lis is required this is 8 bytes ,∘⌹3 3∘⍴ Try it online!
jslip's user avatar
  • 791
14 votes

Are these the basis vectors?

Octave, 43 41 39 bytes @(B,v)(r=rank(B))-rows(B)|r-rank([B;v]) Anonymous function that inputs the set of vectors as a matrix B with each vector in a row, and v as ...
Luis Mendo's user avatar
  • 104k
13 votes

Verify Eigenpairs

Mathematica, 10 bytes #2.#==#3#& Takes input like {vector, matrix, scalar} and returns a boolean.
Martin Ender's user avatar
13 votes

Determinant of an Integer Matrix

Jelly, 16 15 12 10 bytes Ḣ×Zß-Ƥ$Ṛḅ- Uses Laplace expansion. Thanks to @miles for golfing off 3 5 bytes! Try it online! How it works ...
Dennis's user avatar
  • 210k
12 votes

Construct the Identity Matrix

R, 4 bytes diag When given a matrix, diag returns the diagonal of the matrix. However, when given an integer ...
Alex A.'s user avatar
  • 24.6k
12 votes

Vandermonde Determinant

Jelly, 5 bytes œc2IP œc2 gets all combinations without replacement of length 2. I computes ...
Lynn's user avatar
  • 68.1k
12 votes

Determinant of an Integer Matrix

R, 3 bytes Trivial Solution det Try it online! R, 94 92 89 bytes re-implemented solution outgolfed by Jarko Dubbeldam ...
Giuseppe's user avatar
  • 28.1k
11 votes

Find the Cross Product

LISP, 128 122 bytes Hi! This is my code: ...
PieCot's user avatar
  • 1,269
11 votes

Verify Eigenpairs

MATL, 7 bytes *i2GY*= Inputs in order: l,v,A. ...
Sanchises's user avatar
  • 9,446
11 votes
Accepted

Verify Eigenpairs

Jelly, 5 bytes æ.⁵⁼× This is a triadic, full program. Try it online! How it works ...
Dennis's user avatar
  • 210k
11 votes

Determinant of an Integer Matrix

Haskell, 71 bytes -3 bytes thanks to Lynn. Another one bytes the dust thanks to Craig Roy. ...
totallyhuman's user avatar
  • 16.3k
11 votes

Characteristic polynomial

SageMath, 3 bytes 5 bytes saved thanks to @Mego fcp Try it online! Takes a Matrix as input. ...
Uriel's user avatar
  • 13.1k
11 votes

Billiard balls collision

JavaScript (Node.js), 90 88 bytes (m,n,o,p,q,r,s,t,u=(q-=m)*q+(r-=n)*r,v=o*q+p*r-s*q-t*r)=>[o-(q*=v/u),p-(v*=r/u),s+q,t+v] Try it online! Link includes test ...
Neil's user avatar
  • 166k
10 votes

Construct the Identity Matrix

J, 4 bytes =@i. This is a function that takes an integer and returns the matrix.
marinus's user avatar
  • 31.2k
10 votes

Construct the Identity Matrix

Jelly, 4 bytes R=€R Doesn't use a built-in. Try it online! How it works ...
Dennis's user avatar
  • 210k
10 votes

Find the Cross Product

J, 27 14 bytes 2|.v~-v=.*2&|. This is a dyadic verb that accepts arrays on the left and right and returns their cross product. Explanation: ...
Alex A.'s user avatar
  • 24.6k
10 votes

Vandermonde Determinant

Mathematica, 30 bytes 1##&@@(#2-#&@@@#~Subsets~{2})& This is an anonymous function. Expanded by Mathematica, it is equivalent to ...
feersum's user avatar
  • 31.3k

Only top scored, non community-wiki answers of a minimum length are eligible