{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "506b6c31-34ca-4836-88bb-095e8e1db3f1",
   "metadata": {},
   "source": [
    "### **Course**: BIO-341 [_Dynamical systems in biology_](https://moodle.epfl.ch/course/info.php?id=14291)\n",
    "\n",
    "**Professor**: _Julian Shillcock_ & _Felix Naef_\n",
    "\n",
    "SSV, BA5, 2025"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "0e8f7421-f545-471d-b4f1-b417c425608c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib_inline.backend_inline\n",
    "from ipywidgets import interact\n",
    "from scipy.integrate import odeint\n",
    "from IPython.display import set_matplotlib_formats\n",
    "matplotlib_inline.backend_inline.set_matplotlib_formats('png', 'pdf')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d117c080-3a65-4e8e-a57c-5e4ae128551c",
   "metadata": {},
   "source": [
    "# One-dimensional bifurcations (pencil and paper)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "071ba774-c9bf-4542-8fd2-a6183c710210",
   "metadata": {},
   "source": [
    "## Question 1\n",
    "For each of the 1D vector fields A – G:\n",
    "\n",
    "A) $\\frac{dx}{dt} = r - x^2$\n",
    "\n",
    "B) $\\frac{dx}{dt} = rx - x^2$ \n",
    "\n",
    "C) $\\frac{dx}{dt} = rx - 4x^3$ \n",
    "\n",
    "D) $\\frac{dx}{dt} = rx + 4x^3$ \n",
    "\n",
    "E) $\\frac{dx}{dt} = rx - sinh(x)$  \n",
    "\n",
    "F) $\\frac{dx}{dt} = x + \\frac{rx}{1 + x^2}$  \n",
    "\n",
    "1.1 Sketch the vector field for the three cases r < 0, r = 0, r > (labelled by their value of r), mark the fixed point(s) and their stability, and indicate the direction of flow of the vector field on the diagram.\n",
    "\n",
    "1.2 Sketch a few typical trajectories for the three cases, r < 0, r = 0, r > 0.\n",
    "\n",
    "1.3 Draw the bifurcation diagram and label the branches as stable or unstable (use a solid line for stable branches and a dashed line for unstable branches).\n",
    "\n",
    "1.4 Identify the type of bifurcation in the bifurcation diagram.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f90909ae-ff25-4a96-9034-8814f7c13c9b",
   "metadata": {},
   "source": [
    "## Question 2\n",
    "Construct a vector field that depends on a real parameter r, dx/dt = f(r, x), and that has no fixed points for r < 0, and four fixed points for r > 0. Sketch the vector field in the two cases, indicate the direction of flow, and label any fixed points with their stability.  \n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b5e606b8-faae-4891-bd20-f87163397437",
   "metadata": {},
   "source": [
    "## Question 3\n",
    "Draw the bifurcation diagram for the system in Question 2.\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
