# RecurrenceTable with vector

Mathematica can do a RecurrenceTable with a vector, here is a simple example:

RecurrenceTable[{x[n + 1] == 2* x[n], x[0] == {1, 2, 3}}, x, {n,  3}]


with output

{{1, 2, 3}, {2, 4, 6}, {4, 8, 12}, {8, 16, 24}}

I want to do something similar but instead of multiplying by 2 I want to multiple each element in x[n] by a different number. For example, one would think that this would work:

RecurrenceTable[{x[n + 1] == {1,2,3}* x[n], x[0] == {1, 2, 3}}, x, {n,  3}]


since Times is listable but I get an error

RecurrenceTable::excptn: Value {1,2,3,2,4,6,3,6,9} is a numerical exception. >>

I get the same result using MapThread etc. Thoughts?

-
Would NestList[{1, 2, 3} # &, {1, 2, 3}, 3] be acceptable ? – b.gatessucks Jan 8 '13 at 19:00
Try to write down your recurrence formulae ... – Dr. belisarius Jan 8 '13 at 19:12
Although you say you see the same problem "using MapThread", in MMA 8 this succeeds: RecurrenceTable[{x[n + 1] == MapThread[Times, {{1, 2, 3}, x[n]}], x[0] == {1, 2, 3}}, x, {n, 3}]. (This expression was prompted by @b.gatessucks' answer.) – whuber Jan 8 '13 at 21:00

g[input_List] := {1, 2, 3} input

(+1) The truly curious thing about this work-around is if you merely leave List out of the definition of g, the RecurrenceTable expression does not work (it returns an empty list). Tracing the evaluation reveals the problem: {1,2,3}*x[n] is expanded as {x[n], 2 x[n], 3 x[n]}, because MMA does not (yet) know that x[n] is a list at the time of expansion. – whuber Jan 8 '13 at 20:51