27 votes

Determinant of an Integer Matrix

Jelly, 15 bytes LŒ!ðŒcIṠ;ị"Pð€S Try it online! How it works ...
  • 48.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): ...
19 votes

Construct the Identity Matrix

TI-BASIC, 2 bytes identity(Ans Fun fact: The shortest way to get a list {N,N} is ...
  • 21.2k
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 ...
  • 24.2k
18 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 ...
  • 6,452
17 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
  • 24.2k
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 ...
  • 1,751
15 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 ...
  • 139k
15 votes

Find the Cross Product

Jelly, 14 13 12 bytes ;"s€2U×¥/ḅ-U Try it online! How it works ...
  • 207k
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.
14 votes

Is the matrix rank-one?

Jelly, 6 bytes ẸÐfÆrE Try it online! How it works ...
  • 207k
14 votes

Eigenvalues of a Matrix

Haskell, 576 554 532 507 bytes No built-ins! ...
  • 16.5k
14 votes

Calculate the Hafnian as quickly as possible

Haskell ...
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!
  • 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 ...
  • 101k
13 votes

Verify Eigenpairs

Mathematica, 10 bytes #2.#==#3#& Takes input like {vector, matrix, scalar} and returns a boolean.
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 ...
  • 24.2k
12 votes

Vandermonde Determinant

Jelly, 5 bytes œc2IP œc2 gets all combinations without replacement of length 2. I computes ...
  • 66.2k
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 ...
  • 26.8k
12 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 ...
  • 207k
11 votes

Find the Cross Product

LISP, 128 122 bytes Hi! This is my code: ...
  • 1,079
11 votes

Verify Eigenpairs

MATL, 7 bytes *i2GY*= Inputs in order: l,v,A. ...
  • 9,346
11 votes
Accepted

Verify Eigenpairs

Jelly, 5 bytes æ.⁵⁼× This is a triadic, full program. Try it online! How it works ...
  • 207k
11 votes

Characteristic polynomial

SageMath, 3 bytes 5 bytes saved thanks to @Mego fcp Try it online! Takes a Matrix as input. ...
  • 13k
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 ...
  • 147k
10 votes

Construct the Identity Matrix

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

Construct the Identity Matrix

J, 4 bytes =@i. This is a function that takes an integer and returns the matrix.
  • 31.1k
10 votes

Vandermonde Determinant

Mathematica, 30 bytes 1##&@@(#2-#&@@@#~Subsets~{2})& This is an anonymous function. Expanded by Mathematica, it is equivalent to ...
  • 30.9k
10 votes

Arnold's Cat Map

Jelly, 9 bytes Zṙ"JC$µ2¡ Try it online! The coordinates are as in the answer. Explanation ...
  • 66.2k
10 votes

Is this a Jordan matrix?

JavaScript, 58 bytes a=>a.some((r,y)=>r.some((c,x)=>(r/(r=c)==a[x][x])/-y--<c)) Try it online! When c==0 ...
  • 30.8k

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