Algosim documentation: IteratedImages

IteratedImages

Computes iterated images of a value under a given function.

Syntax

Description

If f is a function, x any object, and n a non-negative integer, then IteratedImages(f, x, n) returns the list

'(x, f(x), f(f(x)), ..., f^n(x)).

The orbit function is similar, except that it returns the values as a set instead of a list. (In particular, this means that the elements are not ordered and that the result contains no duplicates.)

Examples

IteratedImages(cos, 1, 20)
1
0.540302305868
0.857553215846
0.654289790498
0.793480358743
0.701368773623
0.763959682901
0.722102425027
0.750417761764
0.731404042423
0.744237354901
0.735604740436
0.74142508661
0.737506890513
0.740147335568
0.738369204122
0.739567202212
0.738760319874
0.739303892397
0.738937756715
0.739184399771
a ≔ n ↦ if(even(n), n/2, 3⋅n+1);
IteratedImages(a, 37, 25)
37
112
56
28
14
7
22
11
34
17
52
26
13
40
20
10
5
16
8
4
2
1
4
2
1
4

See also