When I use RecurrenceTable
to solve a recursion relations, I encounter a problem, which is perhaps simple, but I do not understand why it is complaining. Here is a simple example. First, let's create a list
alist = Table[2^i, {i, 1, 100}]
and next evaluate
RecurrenceTable[{b[n] == alist[[n]] + b[n - 1], b[1] == 2}, b, {n, 1, 10}]
Then the results are
Part::pkspec1: The expression n cannot be used as a part specification. >>
Part::pkspec1: The expression 1+n cannot be used as a part specification. >>
Part::pkspec1: The expression 1+#1 cannot be used as a part specification. >>
General::stop: Further output of Part::pkspec1 will be suppressed during this calculation. >>{2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046}
Does anyone know where things go wrong and how to solve it?
In general I would like to know how to use the ReccurenceTable
when the recursion relation depends on values from another precomputed list.
Comments
Post a Comment