       Re: Creating List of Sequence Iterates

• To: mathgroup at smc.vnet.net
• Subject: [mg33406] Re: [mg33385] Creating List of Sequence Iterates
• From: Tomas Garza <tgarza01 at prodigy.net.mx>
• Date: Wed, 20 Mar 2002 01:53:14 -0500 (EST)
• References: <200203190438.XAA16778@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Have you heard at all of NestList?

In:=
f[x_] := 3*x + 2
In:=
NestList[f, x, 10]
Out=
{x, 2 + 3*x, 2 + 3*(2 + 3*x), 2 + 3*(2 + 3*(2 + 3*x)),
2 + 3*(2 + 3*(2 + 3*(2 + 3*x))),
2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*x)))),
2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*x))))),
2 +
3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*x)))))),
2 +
3*(2 +
3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 +
3*x))))))),
2 +
3*(2 +
3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 +
3*(2 + 3*x)))))))),
2 +
3*(2 +
3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 + 3*(2 +
3*(2 + 3*(2 + 3*x)))))))))}

In:=
NestList[f,1,10]
Out=
{1,5,17,53,161,485,1457,4373,13121,39365,118097}

Tomas Garza
Mexico City
----- Original Message -----
From: "Bob Harris" <nitlion at mindspring.com>
To: mathgroup at smc.vnet.net
Subject: [mg33406] [mg33385] Creating List of Sequence Iterates

> Howdy,
>
> I'm trying to figure out how, with a single expression, I can create a
list
> of iterates of some sequence.
>
> For example, suppose I have defined F[x_] := 3x+2 and I want to get a list
> that contains F, F[F], F[F[F]], etc.  It seems like I could do
> something like
>
>     iterates = Table [F[ iterates[[n-1]] ] , {n,1,20}]
>
> to get a list of the first 20 iterations of this function (assuming I had
> some way to define interates[]).
>
> Anyone know how I can do that, short of writing the following function?
>
>   Iterate[func_ , first_ , iterations_] := Module[ {v, ix},
>     v = Table[0, {n, 1, iterations}];
>     v[] = first;
>
>     For[ix=2, ix<=iterations, ix++, v[[ix]] = func[v[[ix-1]]] ];
>
>     v
>     ]
>
> Any help would be appreciated.  I'm mostly interested in being pointed in
> the right direction.
>
> Thanks,
> Bob H
>
>

```

• Prev by Date: Re: Creating List of Sequence Iterates
• Next by Date: RE: Full text of the current warning message(s)
• Previous by thread: Re: Creating List of Sequence Iterates
• Next by thread: Re: Creating List of Sequence Iterates