4
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ 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 $\endgroup$
    – Michael E2
    Commented Jun 12 at 20:49
  • $\begingroup$ Corrected according to the suggestion from @MichaelE2 $\endgroup$
    – Ahmed Riza
    Commented Jun 15 at 13:00
  • $\begingroup$ Thanks for the edits. $\endgroup$
    – Michael E2
    Commented Jun 15 at 15:28

3 Answers 3

4
$\begingroup$
$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} *)
$\endgroup$
6
$\begingroup$
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}  *)
$\endgroup$
3
$\begingroup$

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

enter image description here

$\endgroup$

Your Answer

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

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