# Physics 212, 2018: Lectures 4

Back to the main Teaching page.

In this lecture, we continue learning the basics of computational modeling and Python language using the simple linear (,malthusian) growth model.

## Finishing up from the previous lecture

explore how the solution spends on dt. Output results only when t is an integer.

## New Python constructions

• Objects -- mutable (arrays and lists) vs. immutable (numbers)
• Object attributes and object methods, using dir()
• Variables vs. objects
• Lists vs. Numpy arrays
• Why np.zeros((2,4)) and not np.zeros(2,4)?
• Creation, concatenation (stacking).
• Slicing -- doesn't create new arrays
• Flatten copies data, ravel and reshape does not
• Strings
• Loops
• Vector math is always faster than element-by-element math

## Our simplest model

A real environment won't have resources that are capable of supporting an infinite bacterial population. Thus as the population grows, the growth rate should decrease. The simplest assumption is that it decreases linearly $r(n)=r_{0}-r_{1}n$ . This gives for the growth: ${\frac {dn}{dt}}=(r_{0}-r_{1}n)n=r_{0}n\left(1-{\frac {n}{r_{0}/r_{1}}}\right)$ . Or, in other words, ${\frac {dn}{dt}}=r_{0}n\left(1-{\frac {n}{N_{0}}}\right)$ , where $N_{0}$ is the carrying capacity -- the number of bacteria where there growth rate is equal to 0, and the population stabilizes.