5
$\begingroup$

I'm trying to analyze the following sequence of numbers:

$$a_1 = 2 \quad \text{ s.t } \quad a_n = 4\sum_{i=1}^{n}a_i $$ I wrote the following code for creating a Recurrence Table for this sequence of numbers:

rt = RecurrenceTable[{a[n + 1] == 4 Sum[a[n], {1, n}], a[1] == 2}, a, {n, 1, 10}]

But, I'm facing the following issue, when I try to evaluate the actual numerical value, I'm getting the following format as output:

$rt[[2]] = 4 \times \sum_{1}^{1}2$

Even when I run

N[rt[[2]]

The output is

4. NSum[2, {1, 1}]

The ouput for the FullForm is:

\!\(
TagBox[
StyleBox[
RowBox[{"Times", "[", 
RowBox[{"4", ",", 
RowBox[{"Sum", "[", 
RowBox[{"2", ",", 
RowBox[{"List", "[", 
RowBox[{"1", ",", "1"}], "]"}]}], "]"}]}], "]"}],
ShowSpecialCharacters->False,
ShowStringCharacters->True,
NumberMarks->True],
FullForm]\)

Any tips on how to get the numerical values? Is the error in the actual function for the definition of the Recurrence Table?

$\endgroup$
  • $\begingroup$ Já tentou usar LaTex? $\endgroup$ – LCarvalho Oct 14 at 20:07
7
$\begingroup$
a[1] = 2;
a[n_] := a[n] = 4 Sum[a[i], {i, n - 1}]

Table[a[n], {n, 1, 10}]

{2, 8, 40, 200, 1000, 5000, 25000, 125000, 625000, 3125000}

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for the answer! Do you know what is wrong with my code? Why I can't get the numerical value? $\endgroup$ – Davi Barreira Sep 12 at 23:45
3
$\begingroup$

You can introduce a memory variable b[n] and solve for both a[n] and b[n].

RecurrenceTable[{a[n + 1] == 4 b[n], b[n] == b[n - 1] + a[n], 
   a[1] == b[1] == 2}, {a, b}, {n, 1, 10}][[All, 1]]

(*   {2, 8, 40, 200, 1000, 5000, 25000, 125000, 625000, 3125000}   *)
| improve this answer | |
$\endgroup$
2
$\begingroup$
Clear["Global`*"]

In your code, you have the wrong syntax for the Sum. However, even with the correct syntax

rt = RecurrenceTable[{a[n + 1] == 4 Sum[a[i], {i, 1, n}], a[1] == 2}, 
  a, {n, 1, 10}]

enter image description here

As stated in the error message, all instances of a[_] must have arguments of the form n + integer

Amplifying on the answer by Suba Thomas

a[1] = 2;
a[n_] := a[n] = 4 Sum[a[i], {i, n - 1}]

seq = Table[a[n], {n, 1, 10}]

(* {2, 8, 40, 200, 1000, 5000, 25000, 125000, 625000, 3125000} *)

You can use FindSequenceFunction to generalize from the sequence

y[n_] = FindSequenceFunction[seq, n]

enter image description here

a[200] == y[200]

(* True *)
| improve this answer | |
$\endgroup$
  • $\begingroup$ This FindSequenceFunction is pretty neat! Thanks for showing. $\endgroup$ – Davi Barreira Sep 13 at 1:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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