# How do I recursively calculate this equation and generate a list of iteration?

How do I write a recursive equation to compute a list of answers? I tried NestList, but it didn't work.

A = {{.5, -.6}, {.75, 1.1}};
x0 = {2, 0};

Dot[A,x0]
(* {1., 1.5} *)

Dot[A, {1., 1.5}]
(* {-0.4, 2.4} *)

Dot[A, Dot[A, {1., 1.5}]]
(* {-1.64, 2.34} *)


You were correct. NestList is exactly the function you want to use.

NestList[Dot[A, #]&, x0, 5]

(* {{2, 0}, {1., 1.5}, {-0.4, 2.4}, {-1.64, 2.34}, {-2.224,
1.344}, {-1.9184, -0.1896}} *)


Note that the first argument of NestList must be a function.

• @ JHM foolish me that I didn't realize x0 is the one being operated on, thanks.
– DSL
Oct 27, 2016 at 3:40
• How to visualize the change in x0,x1,x2.. with the no. of operations? Oct 27, 2016 at 4:49
• @thils ListPlot would work. Oct 27, 2016 at 5:26

Your can use MatrixPower for this example:

f[n_] := MatrixPower[{{.5, -.6}, {.75, 1.1}}, n].{2, 0}
f /@ Range[0, 5]


yields:

{{2., 0.}, {1., 1.5}, {-0.4, 2.4}, {-1.64, 2.34}, {-2.224,
1.344}, {-1.9184, -0.1896}}

• Or #.x0 & /@ NestList[Dot[A, #] &, A, 5] to make it a recursion (starts at matrix power 1). Nov 2, 2016 at 9:14
• @JacobAkkerboom thank you. Yes, the best recursive answer was already provided. I was just providing another in-built approach. :) Nov 2, 2016 at 9:17

You can also do this recursively, very nearly as you wrote it:

a[k_] := a[k] = A.a[k - 1];
a[1] = x0;


Now you can calculate any desired iterate by asking for a[5] or a[10]. Or calculate a range of values:

a[#] & /@ Range[5]
{{2, 0}, {1., 1.5}, {-0.4, 2.4}, {-1.64, 2.34}, {-2.224, 1.344}}