# IterationList Command

From GeoGebra Manual

- IterationList( <Function>, <Start Value>, <Number of Iterations> )
- Gives you a list of length
*n+1*(*n*= number of iterations) whose elements are iterations of the function starting with the start value.

**Example:**After defining`f(x) = x^2`

the command`IterationList(f, 3, 2)`

gives you the list*{3, 9, 81}*.

- You can also use this command to define a sequence where
*a*depends on_{k+1}*a*and_{k}*k*. If the input function*f*is a function of two variables and start value is a list of two numbers*{s, a*, then the output list consists of numbers_{s}}*a*,_{s}*a*,....,_{s+1}*a*where for_{s+n}*k>s*we have*a*._{k+1}=f(k, a_{k}) **Example:**Define`f(k,a)=(k+1)*a`

, which corresponds to the recursive definition of factorial. The command`IterationList(f, {3, 6}, 4)`

gives you the list*{6, 24, 120, 720, 5040}*.

- IterationList( <Expression>, <Variable Name>, ..., <Start Values>, <Number of Iterations> )
- Gives you a list of length
*n+1*(*n*= number of iterations) whose elements are iterations of the expression starting with the given start value. In each iteration the variables in the expression are substituted by last elements of the list. There should be at least as many start values as there are variables, otherwise the result is*undefined*. **Example:**Let*A*,*B*be points. The command`IterationList(Midpoint(A, C), C, {B}, 3)`

internally computes values*C*_{0}=*B*,*C*_{1}=*Midpoint*(*A*,*C*_{0}),*C*_{2}=*Midpoint*(*A*,*C*_{1}),*C*_{3}=*Midpoint*(*A*,*C*_{2}) and yields {*C*_{0},*C*_{1},*C*_{2},*C*_{3}}. Hence for*A*= (0,0) and*B*= (8,0) the result will be {(8,0), (4,0), (2,0), (1,0)}.

**Example:**Let*f*_0,*f*_1 be numbers.`IterationList(a + b, a, b, {f_0, f_1}, 5)`

fills the first 2 values of the resulting list from the start values. Afterwards the values are computed as*f*_{2}=*f*_{0}+*f*_{1},*f*_{3}=*f*_{1}+*f*_{2},*f*_{4}=*f*_{2}+*f*_{3},*f*_{5}=*f*_{3}+*f*_{4}. Hence for*f*_0 =*f*_1 = 1 the result will be {1, 1, 2, 3, 5, 8}.

**Note:**See also Iteration_Command.