<s>[INST] Determinant and inverse matrix calculation of a special matrix Is there any smart way of calculating the determinant of this kind matrix?
\begin{pmatrix}
1 & 2 & 3 & \cdots &  n \\
2 & 1 & 2 & \cdots & n-1 \\ 
3 & 2 & 1 & \cdots & n-2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
n & n-1 & n-2 & \cdots & 1 \end{pmatrix}
I encountered this in a problem for the case $n=4$. I need to find the inverse matrix.
I doubt the idea of this problem is to calculate all the cofactors and then the inverse matrix in the usual way.
I see the pattern here and some recursive relations... but I am not sure if this helps for calculating the determinant of the existing matrix.
 [/INST] $$\begin{vmatrix}
1 & 2 & 3 & \cdots &  n \\
2 & 1 & 2 & \cdots & n-1 \\ 
3 & 2 & 1 & \cdots & n-2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
n & n-1 & n-2 & \cdots & 1 \end{vmatrix}$$
Notice the sum of an element from the first column and an element from the last column (with the same row) will always be equal to $n+1$,thus we can do $(C_1 = C_1+C_n)$
$$ = \begin{vmatrix}
n+1 & 2 & 3 & \cdots &  n \\
n+1 & 1 & 2 & \cdots & n-1 \\ 
n+1 & 2 & 1 & \cdots & n-2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
n+1 & n-1 & n-2 & \cdots & 1 \end{vmatrix} = (n+1)
\begin{vmatrix}
1 & 2 & 3 & \cdots &  n \\
1 & 1 & 2 & \cdots & n-1 \\ 
1 & 2 & 1 & \cdots & n-2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
1 & n-1 & n-2 & \cdots & 1 \end{vmatrix}$$
From here, we can do as follows: 
go from the last row towards the first and decrease each row's value with the one above it (for any row but the first one).
($\forall i \neq 1, R_i=R_i-R_{i-1}$, Starting with $i=n$ then $i=n-1 ... i=2$).
$$ = (n+1)\begin{vmatrix}
1 & 2 & 3 & \cdots &  n \\
0 & -1 & -1 & \cdots & -1 \\ 
0 & 1 & -1 & \cdots & -1 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
0 & 1 & 1 & \cdots & -1 \end{vmatrix}$$
Expand $C_1$:
$$ = (n+1)\begin{vmatrix}
-1 & -1 & -1 & \cdots &  -1 \\
1 & -1 & -1 & \cdots & -1 \\ 
1 & 1 & -1 & \cdots & -1 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
1 & 1 & 1 & \cdots & -1 \end{vmatrix}$$
Now Add the first row to all of the other rows ($\forall i \neq 1, R_i = R_i + R_1$).
$$ = (n+1)\begin{vmatrix}
-1 & -1 & -1 & \cdots &  -1 \\
0 & -2 & -2 & \cdots & -2 \\ 
0 & 0 & -2 & \cdots & -2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
0 & 0 & 0 & \cdots & -2 \end{vmatrix} = (n+1)[-(-2)^{n-2}]$$
</s>