Re: Creating List of Sequence Iterates

• To: mathgroup at smc.vnet.net
• Subject: [mg33399] Re: Creating List of Sequence Iterates
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Wed, 20 Mar 2002 01:53:02 -0500 (EST)
• References: <a76g2a\$gm0\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Bob:

NestList[F,F[1],3]

{F[1],F[F[1]],F[F[F[1]]],F[F[F[F[1]]]]}

--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Bob Harris" <nitlion at mindspring.com> wrote in message
news:a76g2a\$gm0\$1 at smc.vnet.net...
> 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[1], F[F[1]], F[F[F[1]]], 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[[1]]).
>
> 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[[1]] = 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: Mathlink for Excel
• Next by Date: RE: Re: newbie question - printing Pi
• Previous by thread: Re: Creating List of Sequence Iterates
• Next by thread: RE: Creating List of Sequence Iterates