{ "cells": [ { "cell_type": "code", "execution_count": 3, "id": "1f6be2a6", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from scipy.integrate import odeint" ] }, { "cell_type": "markdown", "id": "9270b56f", "metadata": {}, "source": [ "# Solutions to Exercises" ] }, { "cell_type": "markdown", "id": "049d9fb5", "metadata": {}, "source": [ "## Logistic Growth and COVID-19" ] }, { "cell_type": "markdown", "id": "8c667269", "metadata": {}, "source": [ "1) First, separate the variables and antidifferentiate both sides\n", "\n", "$$\n", "\\int \\frac{dy}{ky(1-\\frac{y}{M})}=\\int dt.\n", "$$\n", "\n", "The partial fraction decomposition\n", "\n", "$$\n", "\\frac{A}{ky} + \\frac{B}{1-\\frac{y}{M}}=\\frac{1}{ky(1-\\frac{y}{M})}\n", "$$\n", "\n", "with $A=1$ and $B=\\frac{1}{kM}$\n", "\n", "leads to \n", "\n", "$$\n", "\\frac{1}{k}\\ln \\frac{My}{M-y} = t+C.\n", "$$\n", "\n", "Considering the initial condition $y(0)=y_0>0$, the solution can be obtained using algebra:\n", "\n", "$$\n", "y=\\frac{M}{1+(\\frac{M}{y_0}-1)e^{-kt}}\n", "$$\n", "\n", " " ] }, { "cell_type": "markdown", "id": "6dae7918", "metadata": {}, "source": [ "2a) " ] }, { "cell_type": "code", "execution_count": 1, "id": "c46223ab", "metadata": { "tags": [ "hide-input" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ ":5: MatplotlibDeprecationWarning: The seaborn styles shipped by Matplotlib are deprecated since 3.6, as they no longer correspond to the styles shipped by seaborn. However, they will remain available as 'seaborn-v0_8-