You are here:

Advanced Math/sequence for calculating flea populations.

Advertisement


Question
As a vet I'm constantly trying to explain the population growth rates for fleas reproducing under ideal environmental conditions (85% humidity and 26C). The life cycle: an adult female will produce 40 eggs a day, laying 500 in a lifetime, and will live for 4 weeks. 50% are offspring are female, and the egg/larval/pupal stages take 28 days to reach maturity and start laying the next generation. If a single adult female flea is introduced on day 0, on day 29 there is 41 adults and 460 eggs; day30 - 80 adults(mom died), 420+800 eggs (only half are female and lay eggs); day 30 120 adults, 380+800+1600 eggs, etc etc. Does this make sense? Would be great to be able to input the number of days after introduction of a single adult female, and get a figure of entire adult and egg populations.  I'd be interested in a copy of the calulations if possible. Thanks for your help.

Answer
I designed a program for you in C++.

It assumes that there are 2 fleas to start with
(doesn't it take 1 male and 1 female?).

Every time u is pushed it updates them by 1 year.
Note that for the first 27 numbers listed out,
the new fleas are still developing.

Since they only lay about 500 eggs at 40 per day, I have them laying 40 for the first 12 days and 20 on the 13th day.

The first set produces the second generation, and then holds for awhile (a few days) until that generation starts production.

After the third generation, production has spread out enough that new fleas appear evevery day.  The fleas are kept in the computer, so there is no need to start itching.

Don't worry - when the program ends, all the fleas are killed.
Yes, I'm sure of it.

After 100 days, there are over 2,000,000,000 fleas.
Unfortunately, on the computer, this is almost too many, for on the next day the population seems to have died out.

Now if you only wanted an approximate number of fleas, I could make that into a real number, but that would round when it got that high.

I could make adjustments in the program to possible apply some medicine to kill of most of the fleas at a later time or sonething.

It works great, but I'm not sure how to send an execuatable program without your email address...

After 10 days, I have 402.
After 20 days, there are 442.
After 30 days, there are 2,842.
After 40 days, there are 62,040.
After 50 days, there are 106,040.
After 60 days, there are 426,040.
After 70 days, there are 8,777,960.
After 80 days, there are 22,809,600.
After 90 days, there are 65,769,600.
After 100 days, there are 1,209,761,200.
After a few more days, there were too many and they all died.

Not really, but the numbers were too big for C++ in long int.

I'm not sure if the program I wrote was entirely correct.

Here is the copy of it you could highlight and put into C++
{ if you have C++ }.  Note that there are three lines near the bottom that wrapped around as I was sending them.   They may or may not need to be fixed on arrival.

/*
females produce 40 eggs a day for 12 days and 20 egss on 13th day
half of the eggs are female

eggs take 28 days to reach maturity

life after birth is 4 weeks
*/
// population.cpp

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

#define MAX 68

void intro() {
 printf ("This program will list out the number of fleas that there are.\n");
 printf ("They start production on day 28 and go to day 39.\n");
 printf ("At that point, they have produced 500 eggs.\n");
}

void kill (long int *p) {
 int i;   // used in for loop
//  for (i=0; i<MAX; i++)
//printf ("%9.4f", rand())
//    p[i] = rand()*p[i];
}

int upper (char ch) {
 if (ch >= 'a' && ch <= 'z') ch = ch - 32;
 return (ch);
}

void help () {
 printf ("\nAssistance for the program\n\n");
 printf (" I list individuals\n");
 printf (" P print out\n");
 printf (" U update\n");
 printf (" Q quit\n\n");
 printf (" Choice? ");
}

void list (long int *p) {
 int i;    // used in for loop

 for (i=0; i<MAX; i++) {
   printf (" %3d:%9ld", i, 2*p[i]);
   if ((i + 1) % 5 == 0)
     printf ("\n");
  }
 printf ("\n");
}

long int out (long int *p) {
 int i;   // used in for loop
 long int sum=0;    // population sum

 for (i=0; i<MAX; i++)  sum += p[i];

 return (sum);
}

long int update (long int *p) {
 int i;
 long int sum=0;

 for (i=MAX-1; i>0; i--) {
   p[i] = p[i-1];
   sum += p[i];
  }

 p[0] = 0;   // account for new born fleas
 for (i=28; i<40; i++)
   p[0] += 20*p[i];
 sum += p[0];
 return (sum);
}

void main() {
 int i;      // used in for loop
 int ch;      // command for program to do
 int d=0;      // number of days
 long int p[MAX];      // used for population
 long int pop;      // the population

 intro ();
 // initialize the population
 for (i=0; i<MAX; i++)  p[i] = 0;
 p[28] = 1;   // start with one mature
 pop = 1;

 help();
 ch =upper(getch());
 if (ch != 'Q')
   do {
     printf ("ch %c\n", ch);

     if (ch == 'U') {
       d++;    // add one to number of days
       printf ("The number of days is %d.\n", d);
      }

     if (ch == 'H') help();
     else if (ch == 'I') list (p);
     else if (ch == 'P') printf ("The total is %ld\n", pop = 2*out(p));
     else if (ch == 'O') kill (p);
     else if (ch == 'U') printf ("Another day passed.  Now there are %ld fleas.\n", pop = 2*update(p));
     else if (ch != 'Q') help();

     if (pop < 0)  for (i=0; i<MAX; i++)  p[i] = 0;   // if population goes negative, eliminate all

     help();
     ch = upper(getch());
    }
   while (ch != 'Q');
 else printf ("Boy, you killed them before they got started!\n\n");

 if (d > 0) printf ("And that exterminated the fleas ...\n\n");
}

Advanced Math

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scott A Wilson

Expertise

I can answer any question in general math, arithetic, discret math, algebra, box problems, geometry, filling a tank with water, trigonometry, pre-calculus, linear algebra, complex mathematics, probability, statistics, and most of anything else that relates to math. I can even tell you it takes me over 2,000 steps to go a mile, but is that relevant?

Experience

Experience in the area; I have tutored people in the above areas of mathematics for almost two years in AllExperts.com. I have tutored people here and there in mathematics since before I received a BS degree almost 25 years ago. In just two more years, I received an MS degree as well, but more on that later. I tutored at OSU in the math center for all six years I was there. Most students offering assistance were juniors, seniors, or graduate students. I was allowed to tutor as a freshman. I tutored at Mathnasium for well over a year. I worked at The Boeing Company for over 5 years. I received an MS degreee in Mathematics from Oregon State Univeristy. The classes I took were over 100 hours of upper division credits in mathematical courses such as calculus, statistics, probabilty, linear algrebra, powers, linear regression, matrices, and more. I graduated with honors in both my BS and MS degrees. Past/Present Clients: College Students at Oregon State University, various math people since college, over 7,500 people on the PC from the US and rest the world.

Publications
My master's paper was published in the OSU journal. The subject of it was Numerical Analysis used in shock waves and rarefaction fans. It dealt with discontinuities that arose over time. They were solved using the Leap Frog method. That method was used and improvements of it were shown. The improvements were by Enquist-Osher, Godunov, and Lax-Wendroff.

Education/Credentials
Master of Science at OSU with high honors in mathematics. Bachelor of Science at OSU with high honors in mathematical sciences. This degree involved mathematics, statistics, and computer science. I also took sophmore level physics and chemistry while I was attending college. On the side I took raquetball, but that's still not relevant.

Awards and Honors
I earned high honors in both my BS degree and MS degree from Oregon State. I was in near the top in most of my classes. In several classes in mathematics, I was first. In a class of over 100 students, I was always one of the first ones to complete the test. I graduated with well over 50 credits in upper division mathematics.

Past/Present Clients
My clients have been students at OSU, people nearby, friends with math questions, and several people every day on the PC, and you're probably make one more.

©2012 About.com, a part of The New York Times Company. All rights reserved.