0

Let $$N_4=\pmatrix{0&1&2&3\\1&0&4&5\\2&4&0&6\\3&5&6&0},$$ so you see that the upper/lower triangular part indexes the outer-diagonal elements. Two FOR-loops do, to get $N_k$ in general, but is there a nice mathematical construction?

draks ...
  • 18,449

1 Answers1

1

If $i < j$, then the number of digits in the strictly upper triangular entries in the rows before the $i$th is $$T_{k - 1} - T_{k - i} ,$$ where $$T_l := \tfrac{1}{2} l (l + 1)$$ is the $k$th triangular number, so that $$T_{k - 1} - T_{k - i} = \tfrac{1}{2}(k - 1) k - \tfrac{1}{2}(k - i)(k - i + 1) = \tfrac{1}{2} (i - 1) (2 k - i) .$$ The $(i, j)$ entry is itself the $(j - i)$th strictly upper triangular entry in the $i$th row, so we conclude (again for $i < j$) that $$\color{#bf0000}{(N_k)_{ij} = \tfrac{1}{2} (i - 1) (2 k - i) + j - i} .$$ Together with the facts that $$\color{#bf0000}{(N_k)_{ii} = 0} \qquad \textrm{and} \qquad \color{#bf0000}{(N_k)_{ji} = (N_k)_{ij}}$$ this completely specifies the matrix $N_k$.

One can implement this readily in Maple with the procedure N() below:

T := l -> l * (l + 1) / 2;
N := k -> Matrix(k, (i, j) -> if i <> j then T(k - 1) - T(k - min(i, j)) + abs(j - i) else 0 end if);
Travis Willse
  • 99,363