RecurrenceTable[] error: arguments should be in the form k + integer

I am trying to obtain some results from a recurrence equation, but I am having issues with my code. Probably it’s a simple mistake, but I haven’t found the way to solve it. I will put a simple example:

x0 = {453., 795., 367.};

RecurrenceTable[{x[k + 1] == Outer[Plus, x[k], x[k]] . x[k], 
  x[0] == x0}, x, {k, 0, 9}]

Any help would be much appreciated,

Thanks in advance.

I think what you’ll need to do is use three variables.

RecurrenceTable[{
  x[k + 1] == 2*x[k]^2 + y[k]*(x[k] + y[k]) + z[k]*(x[k] + z[k]),
  y[k + 1] == 2*y[k]^2 + x[k]*(x[k] + y[k]) + z[k]*(y[k] + z[k]),
  z[k + 1] == 2*z[k]^2 + x[k]*(x[k] + z[k]) + y[k]*(y[k] + z[k]),
  x[0] == 453.,
  y[0] == 795.,
  z[0] == 367.},
 {x, y, z},
 {k, 0, 9}]

You can see what was happening if you inspect the output from your code. The Dot and Outer were being evaluated, but their arguments were symbolic, so the structure was wrong for those functions. The structure was wrong because there’s no way to tell it, “hey, I want you to assume x to be a length 3 list”. You ended up with an expression which was in turn wrong for RecurrenceTable.

I’m not really familiar with RecurrenceTable, so maybe there is a more elegant way to deal with this.

Ok Eric, thank you for your comment! I didn’t notice that issue.

I am not sure if there’s any other way, because that’s just a small example with 3 dimensions, but really I have much more, so it would be difficult to program it variable by variable.

We’ll, you can precompute the recurrence expression, even turn it into a function. It just needs to be explicit about the dimensions.

recurrenceExpression[x_, y_, z_, k_] :=
Thread[Equal[{x[k + 1], y[k + 1], z[k + 1]},
Outer[Plus, {x[k], y[k], z[k]}, {x[k], y[k], z[k]}] . {x[k], y[k],
z[k]}]];

initial[x_, y_, z_] := 
 Thread[Equal[{x[0], y[0], z[0]}, {453., 795., 367.}]];

RecurrenceTable[
 Join[recurrenceExpression[x, y, z, k], initial[x, y, z]], {x, y, 
  z}, {k, 0, 9}]

Probably lots of ways to evolve this to something more elegant for your domain.

Thank you Eric, your approach is interesting, but I still don’t see how to generalize the code for a generic n number of dimensions.

Let’s say if I have n=100 dimensions, I am not sure how could I code it automatically, so that I don’t need to define 100 variables one by one {x,y,z,...}.

Thank you very much Eric! After some work, I have been able to adapt the code to my purpose.

The combination of Through[] and Thread[] has been very effective. I wasn’t even aware of Through[].

Thanks again for your time and your helpful comments!

Excellent! Glad to hear it!