Simple recursion problem: there must be a simple answer!
- To: mathgroup at smc.vnet.net
- Subject: [mg42654] Simple recursion problem: there must be a simple answer!
- From: "George W. Gilchrist" <gwgilc at wm.edu>
- Date: Sat, 19 Jul 2003 03:19:38 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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/
- Follow-Ups:
- Re: Simple recursion problem: there must be a simple answer!
- From: Dr Bob <drbob@bigfoot.com>
- Re: Simple recursion problem: there must be a simple answer!