Suppose that a colony of 1000 bacteria is multiplying at a r

Suppose that a colony of 1000 bacteria is multiplying at a rate of r=0.8 per hour per individual (i.e. an individual produces an average of 0.8 offspring every hour). How many bacteria are there after 10 hours? Bacterial growth can be modeled as: dN/dt = rN(t) where N(t) is the population size at time t. Use the script in Problem 3 (Euler\'s method) to solve the problem.

Solution

// Function that takes differential-equation, initial condition,
// ending x, and step size as parameters
// h = step size = r in our current problem
function eulersMethod(f, x1, y1, x2, h) {
   // Header
   console.log(\"\\tX\\t|\\tY\\t\");
   console.log(\"------------------------------------\");

   // Initial Variables
   var x=x1, y=y1;

   // While we\'re not done yet
   // Both sides of the OR let you do Euler\'s Method backwards
   while ((x<x2 && x1<x2) || (x>x2 && x1>x2)) {
       // Print what we have
       console.log(\"\\t\" + x + \"\\t|\\t\" + y);

       // Calculate the next values
       y += h*f(x, y)
       x += h;
   }

   return y;
}

function cooling(x, y) {
   return -0.07 * (y-20); // replace with N(t)
}

var r = 0.8;
var bacteriaCount = 1000
// t ranges from 0 -> 10 hours
var t0 = 0;
var tF = 10;
eulersMethod(cooling, t0, bacteriaCount, tF, r);

################ OUTPUT ###########################################
VM81:6    X   |   Y  
VM81:7 ------------------------------------
VM81:16    0   |   1000
VM81:16    0.8   |   945.12
VM81:16    1.6   |   893.31328
VM81:16    2.4000000000000004   |   844.4077363199999
VM81:16    3.2   |   798.2409030860799
VM81:16    4   |   754.6594125132594
VM81:16    4.8   |   713.518485412517
VM81:16    5.6   |   674.681450229416
VM81:16    6.3999999999999995   |   638.0192890165687
VM81:16    7.199999999999999   |   603.4102088316408
VM81:16    7.999999999999999   |   570.7392371370689
VM81:16    8.799999999999999   |   539.897839857393
VM81:16    9.6   |   510.783560825379
483.2996814191578

 Suppose that a colony of 1000 bacteria is multiplying at a rate of r=0.8 per hour per individual (i.e. an individual produces an average of 0.8 offspring every

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site