Re: Simple recursion problem: there must be a simple answer!
- To: mathgroup at smc.vnet.net
- Subject: [mg42681] Re: [mg42654] Simple recursion problem: there must be a simple answer!
- From: Dr Bob <drbob at bigfoot.com>
- Date: Sun, 20 Jul 2003 06:20:59 -0400 (EDT)
- References: <200307190719.DAA16965@smc.vnet.net>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
Well, of course it's an infinite loop, if the test is 1 < 10. Maybe you meant i < 10. Bobby On Sat, 19 Jul 2003 03:19:38 -0400 (EDT), George W. Gilchrist <gwgilc at wm.edu> wrote: > I have spent the better part of a day trying to figure out how to keep > the > following from going into an infinite loop. Such a simple thing to > program > in other systems, but how the heck do you do it in Mathematica? It is > simply a > case where the value of p in the next generation is a function of p in > the > previous and the result is written to a vector for later reference. > > AA = 1.0; > Aa = 1.0; > aa = 0.5; > freqP[0] = 0; > freqP[1] = 1; > freqP[P_] := (AA*P^2 + Aa* P*(1 - P))/ > (AA*P^2 + Aa*2*P*(1 - P) + aa *(1 - P)^2); > p = Table[0.7, {10}] > For[i = 1, 1 < 10, i++, p[[i + 1]] = freqP[p[[i]]]] > > Any suggestions of Mathematica books that would be helpful for figuring > something like this out in a few minutes instead of a few days? Thank you > for any help. > > ================================================================== > George W. Gilchrist Email #1: gwgilc at wm.edu > Department of Biology, Box 8795 Email #2: kitesci at cox.net > College of William & Mary Phone: (757) 221-7751 > Williamsburg, VA 23187-8795 Fax: (757) 221-6483 > http://gwgilc.people.wm.edu/ > > > -- majort at cox-internet.com Bobby R. Treat
- References:
- Simple recursion problem: there must be a simple answer!
- From: "George W. Gilchrist" <gwgilc@wm.edu>
- Simple recursion problem: there must be a simple answer!