# Recurrence relation with a sum

Say we have the following recurrence: $$T[n] = \sum_{j=1}^{n-1} 2 T[j] T[j-1], \forall n > 1$$

with $$T[0] = T[1] = 2$$

I tried RecurrenceTable but that does not work with the inner summation:

RecurrenceTable[{a[n] == Sum[2*a[i]*a[i - 1], {i, 1, n - 1}], a[0] == 2, a[1] == 2}, a, {n, 1, 6}]


What's the best way to evaluate this in Mathematica?

• People here generally like users to post code as copyable Mathematica code as well as images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find the meta Q&A, How to copy code from Mathematica so it looks good on this site, helpful Commented Jun 12 at 20:49
• Corrected according to the suggestion from @MichaelE2 Commented Jun 15 at 13:00
• Thanks for the edits. Commented Jun 15 at 15:28

\$Version

(* "14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)" *)

Clear["Global*"]

T[0] = T[1] = 2;

T[n_Integer?Positive] := T[n] =
Sum[2 T[j] T[j - 1], {j, 1, n - 1}]

seq = T /@ Range[6]

(* {2, 8, 40, 680, 55080, 74963880} *)

RecurrenceTable[
{t[n + 1] == 2 t[n]  t[n - 1] + If[n > 1, t[n], 0],
t[1] == 2, t[0] == 2},
t[n], {n, 6}]

(*  {2, 2, 8, 40, 680, 55080, 74963880}  *)


You can use Nest and BlockMap, e.g.

f[u_] := Join[u, {Total[2 BlockMap[Times @@ # &, u, 2, 1]]}]
Nest[f, {2, 2}, 8] // Column
`