MathGroup Archive 2003

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

Search the Archive

Re: Simple recursion problem: there must be a simple answer!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42703] Re: Simple recursion problem: there must be a simple answer!
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 22 Jul 2003 04:40:39 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <bfas59$gnv$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

it would help you to understand the For[] loop
that you like.

For[i=0, i<10, i++, something]

ends when i is >= 10

but in your code you wait until 1 (one) is larger
than 10 and that will probably not happen.

There are some basic mathematics book that explain that
1 is always smaller than 10 ..

Regards
  Jens

"George W. Gilchrist" 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/


  • Prev by Date: Re: Recovering f[z] values?
  • Next by Date: Re: Usage of tex
  • Previous by thread: Re: Simple recursion problem: there must be a simple answer!
  • Next by thread: AW: Applying multiple functions to multiple sets of arguments