0
$\begingroup$

I would like to use a complicated function containing DifferenceRoot as a replacement rule, but somehow it evaluates only in Table. What am I doing wrong?

The code for the table:

\[ScriptH][k_] := DifferenceRoot[Function[{\[FormalY], \[FormalN]}, {-(1 + k)^2 + (3 + 4 k) \[FormalN] - 4 \[FormalN]^2 - 2 (-k - 1 + \[FormalN]) (-k/2 + \[FormalN]) (-k - 1 + 2 \[FormalN]) \[FormalY][\[FormalN]] + 2 (-k - 1 + \[FormalN]) (-k/2 + \[FormalN]) (-k - 1 + 2 \[FormalN]) \[FormalY][1 + \[FormalN]] == 0, \[FormalY][1] == 0}]];
Flatten[Table[Table[f[Δ, Δ - k] -> (1/12288 (Gamma[Δ + 2] Gamma[s + 3/2])/(Gamma[Δ + 3/2] Gamma[s + 1]) ((Δ - s) (Δ + s + 1))/((Δ - s - 1) (Δ + s)) /. {s -> Δ - k}) ((6 HarmonicNumber[Δ - k/2, 2] - 6 (HarmonicNumber[Δ + 1] - HarmonicNumber[Δ - k]) (HarmonicNumber[-(k/2) + Δ] - HarmonicNumber[k/2 - 1])) + 12 Sum[\[ScriptH][k][j + 1]/(Δ + 1 - j), {j, 0,k/2 - 1}] + 12 Sum[\[ScriptH][k][k - j + 1]/(Δ + 1 - j), {j,k/2 + 1, k}] + 12/((Δ + 1 - k/2) k) + Sum[12/(k - 2 i + 2) 1/(Δ + 2 - i), {i, k/2}]), {Δ, k, 4}], {k, 2, 2, 2}]] // FullSimplify

(*{f[2,0]->0,f[3,1]->5/7168,f[4,2]->5/3072}*)

I could use the results of the table as a replacement rule, but I need the range of $\Delta$ and $k$ to reach at least $150$ (instead of $4$ and $2$ in the example above), and it takes forever to generate the table. So instead I would like to have a replacement rule involving only the function:

testrule = {f[Δ_, s_] -> (1/12288 (Gamma[Δ + 2] Gamma[s + 3/2])/(Gamma[Δ + 3/2] Gamma[s + 1]) ((Δ - s) (Δ + s + 1))/((Δ - s - 1) (Δ + s))) ((6 HarmonicNumber[Δ - k/2, 2] - 6 (HarmonicNumber[Δ + 1] - HarmonicNumber[Δ - k]) (HarmonicNumber[-(k/2) + Δ] - HarmonicNumber[k/2 - 1])) + 12 Sum[\[ScriptH][k][j + 1]/(Δ + 1 - j), {j, 0, k/2 - 1}] + 12 Sum[\[ScriptH][k][k - j + 1]/(Δ + 1 - j), {j,k/2 + 1, k}] + 12/((Δ + 1 - k/2) k) + Sum[12/(k - 2 i + 2) 1/(Δ + 2 - i), {i, k/2}]) /. {k -> Δ - s}};
Flatten[Table[Table[f[Δ, Δ - k], {Δ, k,4}], {k, 2, 2, 2}]] /. testrule

(*{1/2560(-2+12 (-(1/16)+DifferenceRoot[Function[{\[FormalY],\[FormalN]},{(-4+\[FormalN]) (-2+\[FormalN]) \[FormalY][\[FormalN]]+(-11+10 \[FormalN]-2 \[FormalN]^2) \[FormalY][1+\[FormalN]]+(-3+\[FormalN]) (-1+\[FormalN]) \[FormalY][2+\[FormalN]]\[Equal]0,\[FormalY][0]\[Equal]0,\[FormalY][1]\[Equal]1/16}]][2])),1/1792(-(1/4)+12 (-(1/20)+DifferenceRoot[Function[{\[FormalY],\[FormalN]},{(-5+\[FormalN]) (-2+\[FormalN]) \[FormalY][\[FormalN]]+(-14+12 \[FormalN]-2 \[FormalN]^2) \[FormalY][1+\[FormalN]]+(-4+\[FormalN]) (-1+\[FormalN]) \[FormalY][2+\[FormalN]]\[Equal]0,\[FormalY][0]\[Equal]0,\[FormalY][1]\[Equal]1/20}]][2])),1/69125 (21/20+12 (-(1/24)+DifferenceRoot[Function[{\[FormalY],\[FormalN]},{(-6+\[FormalN]) (-2+\[FormalN]) \[FormalY][\[FormalN]]+(-17+14 \[FormalN]-2 \[FormalN]^2) \[FormalY][1+\[FormalN]]+(-5+\[FormalN]) (-1+\[FormalN]) \[FormalY][2+\[FormalN]]\[Equal]0,\[FormalY][0]\[Equal]0,\[FormalY][1]\[Equal]1/24}]][2]))}*)

But in this case, the DifferenceRoot does not get evaluated. How can I fix that?

$\endgroup$

1 Answer 1

1
$\begingroup$
Clear["Global`*"]

\[ScriptH][k_] := 
  DifferenceRoot[
   Function[{\[FormalY], \[FormalN]}, {-(1 + k)^2 + (3 + 4 k) \[FormalN] - 
       4 \[FormalN]^2 - 
       2 (-k - 1 + \[FormalN]) (-k/2 + \[FormalN]) (-k - 1 + 
          2 \[FormalN]) \[FormalY][\[FormalN]] + 
       2 (-k - 1 + \[FormalN]) (-k/2 + \[FormalN]) (-k - 1 + 
          2 \[FormalN]) \[FormalY][1 + \[FormalN]] == 0, \[FormalY][1] == 
      0}]];

Define the function directly

f[Δ_Integer, m_Integer] /; (Mod[Δ, 2] == Mod[m, 2] && Δ > m >= 0) :=
 f[Δ, m] = Module[{k = Δ - m},
   (1/12288 (Gamma[Δ + 2] Gamma[
            s + 3/2])/(Gamma[Δ + 3/2] Gamma[
            s + 1]) ((Δ - s) (Δ + s + 
             1))/((Δ - s - 1) (Δ + 
             s)) /. {s -> Δ - 
          k}) ((6 HarmonicNumber[Δ - k/2, 2] - 
         6 (HarmonicNumber[Δ + 1] - 
            HarmonicNumber[Δ - 
              k]) (HarmonicNumber[-(k/2) + Δ] - 
            HarmonicNumber[k/2 - 1])) + 
       12 Sum[\[ScriptH][k][j + 1]/(Δ + 1 - j), {j, 0, 
          k/2 - 1}] + 
       12 Sum[\[ScriptH][k][k - j + 1]/(Δ + 1 - j), {j, k/2 + 1,
           k}] + 12/((Δ + 1 - k/2) k) + 
       Sum[12/(k - 2 i + 2) 1/(Δ + 2 - i), {i, k/2}]) // 
    FullSimplify]

f[200, 180] // AbsoluteTiming

(* {0.046249, 87464257436029651122526890870728559761190650510387819172670762548059854804146\
678737022595735395614494049228760765500386708112769729398955935866324833027232\
2504220686352384 / 7073402941208041925399964405364882784320142085011336900794416811618786478527\
078751763096881732562711497920986333813277852108235891723836122316630207711222\
563386367423984375} *)
$\endgroup$
1
  • $\begingroup$ Amazing, thanks! $\endgroup$
    – Pxx
    Sep 26, 2020 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.