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?
- 18,449
-
Do you mean, a nice, nonrecurive formula for $(N_k)_{ij}$? – Travis Willse Jan 27 '16 at 21:35
-
@Travis something straight, but recursions are also fine... – draks ... Jan 27 '16 at 21:37
1 Answers
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);
- 99,363
-
@draks... Thanks, and yes, it's deliberately not, in the sense that one can compute any entry $(N_k){ij}$ without computing any other entry of $N_k$. – Travis Willse Jan 27 '16 at 22:03
-
-
Ah, interesting. Let me suggest you add a link to this question from that one (and vice versa). – Travis Willse Jan 27 '16 at 22:05
-
But wait: When you ask for $i\le j$ isn't this the same as two
FORloops? – draks ... Jan 28 '16 at 08:09 -
No, this is just a condition on the entries for the particular line of reasoning. – Travis Willse Jan 28 '16 at 11:25