29
votes
Determinant of an Integer Matrix
Jelly, 15 bytes
LŒ!ðŒcIṠ;ị"Pð€S
Try it online!
How it works
...
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):
...
20
votes
Construct the Identity Matrix
TI-BASIC, 2 bytes
identity(Ans
Fun fact: The shortest way to get a list {N,N} is ...
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 ...
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 ...
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
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 ...
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 ...
16
votes
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
14
votes
14
votes
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!
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 ...
13
votes
Verify Eigenpairs
Mathematica, 10 bytes
#2.#==#3#&
Takes input like {vector, matrix, scalar} and returns a boolean.
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
...
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 ...
12
votes
Vandermonde Determinant
Jelly, 5 bytes
œc2IP
œc2 gets all combinations without replacement of length 2. I computes ...
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
...
11
votes
11
votes
11
votes
Accepted
Verify Eigenpairs
Jelly, 5 bytes
æ.⁵⁼×
This is a triadic, full program.
Try it online!
How it works
...
11
votes
Determinant of an Integer Matrix
Haskell, 71 bytes
-3 bytes thanks to Lynn. Another one bytes the dust thanks to Craig Roy.
...
11
votes
Characteristic polynomial
SageMath, 3 bytes
5 bytes saved thanks to @Mego
fcp
Try it online!
Takes a Matrix as input.
...
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 ...
10
votes
Construct the Identity Matrix
J, 4 bytes
=@i.
This is a function that takes an integer and returns the matrix.
10
votes
Construct the Identity Matrix
Jelly, 4 bytes
R=€R
Doesn't use a built-in. Try it online!
How it works
...
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:
...
10
votes
Vandermonde Determinant
Mathematica, 30 bytes
1##&@@(#2-#&@@@#~Subsets~{2})&
This is an anonymous function.
Expanded by Mathematica, it is equivalent to ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
linear-algebra × 52code-golf × 45
matrix × 36
math × 34
decision-problem × 4
polynomials × 3
abstract-algebra × 3
complex-numbers × 3
array × 3
number × 2
sequence × 2
arithmetic × 2
number-theory × 2
integer × 2
fastest-code × 2
binary-matrix × 2
code-challenge × 1
geometry × 1
graphical-output × 1
parsing × 1
binary × 1
permutations × 1
image-processing × 1
atomic-code-golf × 1
cryptography × 1