Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Python You want to model a population N that grows according to \"logistic

ID: 3823871 • Letter: U

Question

Using Python

You want to model a population N that grows according to "logistic growth", defined mathematically as dN/dt = rN(1-N/Nmax). Write a python program that solves (integrates) dN/dt using using Euler's method. Euler's method iteratively estimates a variable across an integration interval [t0-tend] from derivative values (dy/dt) using the following formula: y(t+h) = y(t)+h*(dy/dt) Euler Image Your program should solve for y for time starting at 0 and ending at 100. Assume r=0.12, and Nmax=100. Use a stepsize (h) of 0.01. Initially, assume N (at t=0) is 1. As your output, generate a chart of N(t)

thanks

Explanation / Answer

Python 2.7 code:

r=0.12
Nmax=100.0
h = 0.01;
size = int(100/0.01);
y = [];
x = []
for i in range(0,size):
   x.append(i*0.01)
   y.append(0.0)
y[0] = 1;
for n in range(0,size-1):
y[n+1] = y[n] + h*( r*y[n]*(1-(y[n])/Nmax));
print "N(", n+1, ")= ", y[n+1]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote