None Notebook

This notebook contains material from CBE30338; content is available on Github.

< 1.3 Python Conditionals and Libraries | Contents | Tag Index | 2.0 Process Modeling >

Open in Colab

Download

1.4 Python Numeric Integration Revisited

1.4.1 Sidenotes

1.4.1.1 Code Academy Sidenote

1.4.1.2 Markdown/Latex Sidenote

Jupyter-notebooks are very convenient because they include these markdown blocks to include discussion of the material.

Programs like Microsoft Word are examples of a "What you see is what you get" editor. In Markdown, you use characters and symbols to format your text, and then actually compile them.

For instance, I've been making liberal use of the header feature using the '#' pound/hashtag symbol. Double click on this cell to see how I'm creating the text below.

1.4 First Header

1.4.1 Second Header

1.4.1.1 Tertiary Header

1.4.1.1.1 Etc

Bolded Text

Italicized Text

Those are a couple examples of some basic formatting. You can see more examples throughout this tutorial. The sidenote above has an example of a link, while there are examples of a chart, and a photo below. Take a look and see if you can reproduce it on your own!

For further reference: Github's Markdown Guide

1.4.1.2 Latex Side Note

A big included feature in Jupyter-notebook markdown blocks is that you have the ability to include LaTeX formatted text as well.

LaTeX (pronounced "La-tech") is similar to a markdown language in and of itself (it is not What-You-See-Is-What-You-Get). It is considerably more feature-full than markdown, but also has a bigger learning curve. I recommend that you use it just for math, as Markdown can't provide Math formatting.

$$ y = mx + b $$ $$ \frac{3}{5} $$ $$ \lambda \leq \pi + \Pi $$ $$ \log_b(a) = \frac{\log(a)}{\log(a)} $$

Just that should be enough to cover most of the math you'll need in this course. Don't feel like you have to use LaTeX. It is also acceptable to do your work out (neatly) on paper and include a photo.

1.4.2 Hare and Lynx Example

1.4.2.1 Adapted from Dr. Kantor's Notes

1.4.2.2 Introduction

We'd like to model the number of Hares and Lynx in a certain population of animals.

As cute as that Lynx is, it will prey on the Hare to the exclusion of all other animals if possible. This means the population levels of the Lynx and Hare are intrinsically related, see the pelt trading data for the Hudson's Bay Company:

1.4.2.3 Modeling

We can start with the basic equation of: change = in - out

$$ \frac{dH}{dt} = (Hare Birth Rate) - (Hare Death Rate) \\ \frac{dL}{dt} = (Lynx Birth Rate) - (Lynx Death Rate) $$

1.4.2.3.1 Relevant Parameters

Parameter Symbol Value
Lynx/Hare Predation Rate $a$ 3.2
Lynx/Hare Conversion $b$ 0.6
Lynx/Hare Michaelis Constant $c$ 50
Lynx Death Rate $d$ 0.56
Hare Carrying Capacity $k$ 125
Hare Reproduction Rate $r$ 1.6

1.4.2.3.2 Model Equations

These parameters can be used to form a model:

$$ \frac{dH}{dt} = rH(1 - \frac{H}{k}) - \frac{aHL}{c + H} \\ \frac{dL}{dt} = a \frac{bHL}{c + H} - d*L $$

The focus of this tutorial is not on the development of these model equations, but do review the equations and try to make sense of them. It can help you in debugging steps later should you have an error.

1.4.2.4 Programming and Plotting

1.4.2.4.1 Step 1: Initialization

1.4.2.4.2 Step 2: Default Parameter Values

1.4.2.4.3 Step 3: Define the differential equations

1.4.2.4.4 Step 4: Integrate Differential Equations

1.4.2.4.5 Step 5: Plot

If you have more than one thing to plot, we can make use of the subplot feature

< 1.3 Python Conditionals and Libraries | Contents | Tag Index | 2.0 Process Modeling >

Open in Colab

Download