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$
1
  • $\begingroup$ Já tentou usar LaTex? $\endgroup$
    – LCarvalho
    Oct 14, 2020 at 20:07

3 Answers 3

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}

$\endgroup$
1
  • $\begingroup$ Thanks for the answer! Do you know what is wrong with my code? Why I can't get the numerical value? $\endgroup$ Sep 12, 2020 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}   *)
$\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 *)
$\endgroup$
1
  • $\begingroup$ This FindSequenceFunction is pretty neat! Thanks for showing. $\endgroup$ Sep 13, 2020 at 1:58

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.