# How to implement this recursion relation?

I am trying to implement the following relation in Mathematica for any $$k$$:

\begin{align} t_{n,n_1, \ldots, n_k} &= \frac{1}{2} \sum_{m=0}^{n-2} \left( t_{m,n-m-2,n_1, \ldots, n_k} - \frac{1}{N} t_{n-2,n_1,\ldots,n_k} \right) + \frac{n_1}{2} \left( t_{n+n_1-2,n_2,\ldots,n_k} - \frac{1}{N} t_{n-1,n_1-1,n_2,\ldots,n_k} \right) \\ & \qquad\qquad\qquad + \ldots + \frac{n_k}{2} \left( t_{n+n_k-2,n_1,\ldots,n_{k-1}} - \frac{1}{N} t_{n-1,n_k-1,n_2,\ldots,n_{k-1}} \right)\,. \tag{1} \end{align}

The start values are:

$$t_0 = N\,, \qquad t_1 = 0\,, \qquad t_2 = \frac{N^2-1}{2}\,, \tag{2}$$

and note that the indices are not ordered.

The first term is easy and can be implemented with something of the type:

t[n_, nk___] := 1/2 Sum[t[m, n - m - 2, nk] - 1/N t[n - 2, nk], {m, 0, n - 2}]


But I am struggling with the other terms, since the indices do not appear as a group together. I can always write the relation up to a given $$k$$, but is it possible to generalise to any $$k$$, and if yes how?

Small extra question: I know I am not supposed to use N as a variable, but I am so used to it and it always works. Would it be possible to use Nc instead, but have it displayed as N? This exists for example in the FeynCalc package, where the variable SUNN is displayed as N.

• To display Nc as N you can use Format[Nc]:=N Apr 8, 2021 at 11:54
• @Hausdorff MakeBoxes[Nc, StandardForm] := InterpretationBox["N", Nc] is probably a better choice, because the output in the notebook will be interpreted correctly even if you edit/copy it. Apr 8, 2021 at 12:05
• @xzczd Oh, that is a much neater way of doing it. Thanks! Apr 8, 2021 at 12:10
• $t_{n\color{red}{+}n_1-2,n_2,\ldots,n_k}$ <- Is it a typo? Apr 8, 2021 at 12:12
• @xzczd No that's how the recursion goes (it's eq. (2.30) in 1705.02909).
– Pxx
Apr 8, 2021 at 12:37

I believe the relation you wrote is only valid for $$n>2$$. For $$n=0,1,2$$ you have to use the identities of eq.(2.31) in [1705.02909], \begin{aligned} t_{0,n_1,n_2\dots} &= Nt_{n_1,n_2},\\ t_{1,n_1,n_2\dots} &= 0,\\ t_{2,n_1,n_2\dots} &= \frac{N^2-1+n_1+n_2+\dots}{2}t_{n_1,n_2,\dots}. \end{aligned} The code below should do the trick, though more elegant solutions are definitely possible. You can check that it reproduces the sample values given in eq.(2.32) of the paper.

ClearAll[t]
t[0,nk__Integer] := Nc t[nk]
t[1,nk__Integer] := 0
t[2,nk__Integer] := 1/2(Nc^2-1+Plus@@{nk}) t[nk]

t[0] = Nc;
t[1] = 0;
t[2] = (Nc^2-1)/2;

t[n_Integer, nk___Integer] /; n>2 := t[n, nk] =
1/2 Sum[t[m, n - m - 2, nk] - 1/Nc   t[n - 2, nk], {m, 0, n-2}]+
Sum[
{nk}[[i]]/2(
t[n+{nk}[[i]]-2,Sequence@@Delete[{nk},i]]-
1/Nc t[n-1,Sequence@@ReplacePart[{nk},i->{nk}[[i]]-1]]
),
{i,Length@{nk}}]

• Amazing, thanks a lot! That helps me a lot to learn how to write such codes myself!
– Pxx
Apr 8, 2021 at 17:13