I would like to express the following nested sum in Mathematica:
$$ S(m,j,N) = \sum_{k_1=m+j-1}^{N-1} f(N,k_1) \sum_{k_2=m+j-2}^{k_1-1} f(k_1,k_2) \cdots \sum_{k_m=j}^{k_{m-1}-1} f(k_{m-1},k_m) $$
where $m$, $j$ and $N$ are unspecified and $f(p,q)$ is a complicated function depending on the indices $p$ and $q$. Thus, not only are there a variable number of nested sums, the ranges of the sums are also of variable length, depending on the index of the immediately outer sum.
Can anyone please help me? I've searched for solutions to this on this forum and elsewhere, but could only find solutions that treated the ranges of the sums to be variable but equal.
I eventually need to place $S(m,j,N)$ inside other expressions and functions, so I need to be able to pass $m$, $j$, $N$ as symbols. For example, one expression I ultimately want to obtain is
$$ \sum_{m=1}^{N-1} \frac 1 {m!} \sum_{j=1}^{N-m} S(m,j,N), $$
and I would like the solution as an analytic formula, valid for any $N$. I am hoping (and have reason to believe) that the multiple sum $S(m,j,N)$ will simplify down to an easier expression. If you would like to see my definition for the function $f$, here is my code:
phifn[m_, k_] := \[Piecewise] {
{\[Piecewise] {
{1, k = 1},
{0, 2 <= k <= n}
}, m = 1},
{\[Piecewise] {
{((Gamma[m] Pochhammer[q, m - k])/(
Gamma[m - k + 1] Pochhammer[q + 1, m - 1])), 1 <= k <= m},
{0, m < k <= n}
}, 2 <= m <= n}
};
betafn[m_] := (PolyGamma[q + m] - PolyGamma[q]) q r;
f[m_, k_] := phifn[m, k] betafn[m];
I should also add that I'm rather unexperienced when it comes to Mathematica.
Array
andNest
and the like all seem to require an integer in the relevant position. $\endgroup$