Came across a question tonight: How do you construct the matrix
$$\begin{pmatrix}1&2&…&n\\n&1&…&n-1\\…\\2&3&…&1\end{pmatrix}?$$
Here’s a bit of Maxima code to make it happen:
(%i1) M(n):=apply(matrix,makelist(makelist(mod(x-k+n,n)+1,x,0,n-1),k,0,n-1))$
(%i2) M(5);
[ 1 2 3 4 5 ]
[ ]
[ 5 1 2 3 4 ]
[ ]
(%o2) [ 4 5 1 2 3 ]
[ ]
[ 3 4 5 1 2 ]
[ ]
[ 2 3 4 5 1 ]
I also ended up wondering about the determinants of these matrices:
(%i3) makelist(determinant(M(i)),i,1,10); (%o3) [1, - 3, 18, - 160, 1875, - 27216, 470596, - 9437184, 215233605, - 5500000000]
I became curious if this sequence of numbers was known, and indeed that is the case. It is sequence number A052182 in the Encyclopedia of Integer Sequences: “Determinant of n X n matrix whose rows are cyclic permutations of 1..n.” D’oh.
As it turns out, this sequence also has another name: it’s the Smarandache cyclic determinant sequence. In closed form, it is given by
$${\rm SCDNS}(n)=(-1)^{n+1}\frac{n+1}{2}n^{n-1}.$$
(%i4) SCDNS(n):=(-1)^(n+1)*(n+1)/2*n^(n-1);
n + 1
(- 1) (n + 1) n - 1
(%o4) SCDNS(n) := (------------------) n
2
(%i5) makelist(determinant(SCDNS(i)),i,1,10);
(%o5) [1, - 3, 18, - 160, 1875, - 27216, 470596, - 9437184, 215233605, - 5500000000]
Surprisingly, apart from the alternating sign it shares the first several values with another sequence, A212599. But then they deviate.
Don’t let anyone tell you that math is not fun.