MathGroup Archive 1992

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re.Iterations.. (function composition)

  • To: mathgroup at
  • Subject: Re.Iterations.. (function composition)
  • From: gaylord at
  • Date: Thu, 23 Apr 1992 16:40:05 -0500

spagiola at writes:

I'm looking for a way to achieve the following result a little more  

You get the idea.  I have a function a[] that takes an initial value  
of s as its argument.  A second function g[] takes the result of a[]  
and modifies the value of s, which then passes back to a[], etc. (If  
you're curious, this is for a natural resource model in which current  
actions affect the resource stock, which in turn affects future  

I'm sure this is quite simple and that I'm just missing something  
obvious, but after spending several hours playing with Do[],  
NestList[], FoldList[] etc, I cannot seem to get what I want.

I also need to recover every value, so that i can plot a[] and s[]  
(separately).  I'd also like to be able to either specify the number  
of iterations or let it converge to a point where it no longer  


it looks like you want to compose a and g (a functional programming thing).


Nest[Composition[g, a], s, 3]

NestList[Composition[g, a], s, 3]
{s, g[a[s]], g[a[g[a[s]]]], g[a[g[a[g[a[s]]]]]]}

note that this gives g[a[g[a[s]]]]  but not a[g[a[s]]] but it doesn't look
too hard to get the latter (i would try it now but i will be killed if i
don't  come to dinner Immediately) 

see p.213 in the bible for more detail  (it might be useful to read a book
on functional programming as well ( eg., Chris Reade).

btw - for convergence, you can of course use FixedPointList in the same

got to go or my wife will not only name my copy of Mathematica as
corespondent in the divorce but probably ask for custody of both it and my

  • Prev by Date: Re: Limits to Det Function
  • Next by Date: Re: determinants
  • Previous by thread: Signal Processing ftp server update
  • Next by thread: Sqrt