I've written some simple code that, for various $N \geq 1$ and $k = 1,\ldots,N+1$ computes the $n$-th derivative of $\log S_N$ where $S_N(z) = \sum_{k=0}^N \frac{1}{k!}z^k$ as follows:
f[z_, N_] := Sum[z^k/k!, {k, 0, N}]
g[z_, N_] := Log[f[z, N]]
t = Table[Evaluate[D[g[z, 7], {z, n}]], {n, 8}]
Here I can vary $7$ and $8$ to be any $N$ and $N+1$ (resp.). For a shorter example, the output if $7$ and $8$ are replaced by $3$ and $4$ is
$$ \left\{\frac{\frac{z^2}{2}+z+1}{\frac{z^3}{6}+\frac{z^2}{2}+z+1},\frac{z+1}{\frac{z^3}{6}+\frac{z^2}{2}+z+1}-\frac{\left(\frac{z^2}{2}+z+1\right)^2}{\left(\frac{z^3}{6}+\frac{z^2}{2}+z+1\right)^2},\frac{2 \left(\frac{z^2}{2}+z+1\right)^3}{\left(\frac{z^3}{6}+\frac{z^2}{2}+z+1\right)^3}-\frac{3 (z+1) \left(\frac{z^2}{2}+z+1\right)}{\left(\frac{z^3}{6}+\frac{z^2}{2}+z+1\right)^2}+\frac{1}{\frac{z^3}{6}+\frac{z^2}{2}+z+1},-\frac{6 \left(\frac{z^2}{2}+z+1\right)^4}{\left(\frac{z^3}{6}+\frac{z^2}{2}+z+1\right)^4}+\frac{12 (z+1) \left(\frac{z^2}{2}+z+1\right)^2}{\left(\frac{z^3}{6}+\frac{z^2}{2}+z+1\right)^3}-\frac{4 \left(\frac{z^2}{2}+z+1\right)}{\left(\frac{z^3}{6}+\frac{z^2}{2}+z+1\right)^2}-\frac{3 (z+1)^2}{\left(\frac{z^3}{6}+\frac{z^2}{2}+z+1\right)^2}\right\} $$
Since $S_m'(z) = S_{m-1}(z)$ for all $m \geq 1$, these expressions will always $\mathbb{Z}$-linear combinations of quotients of powers of $S_m$ for varying $m$, and I would like to find a way to tell Mathematica to replace each occurrence of $S_m(z)$ with the symbol f[z,m]
. Is this possible? I've seen other questions on simple substitutions using /.
but none where the replacement scheme seemed easily adapted to this problem. In particular, the replacement scheme would need to be greedy to avoid, e.g., replacing instances of $S_m(z)$ with $f[z,m-2] + (1/(m-1)!z^{m-1}) + (1/m!z^m)
.
Is there a way to make this happen?
Edit: This post seems quite relevant. (I had missed it when searching.) I will see if it can be applied here.
t /. Table[f[z, y] -> kk[z, y], {y, Range[3, 0, -1]}]
for your {3,4} example (kk represents f, to use f directly, you'll need to fiddle withHoldForm
et al.) $\endgroup$PolynomialReduce
. It's designed for algebraic replacement. One caveat is that you might have to separately consider numerators and denominators. $\endgroup$