{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b01a7d96",
   "metadata": {},
   "source": [
    "# Prépondérance asymptotique $\\omicron$\n",
    "\n",
    "Ce notebook permet de comparer deux fonctions $f, g \\, : \\, \\mathbb{N} \\to\n",
    "\\mathbb{N}$ afin de déterminer expérimentalement si $f \\in \\omicron(g)$.\n",
    "\n",
    "On dit que $f$ est *petit-$\\omicron$* de $g$, noté $f \\in \\omicron(g)$, si pour toute constante $\\varepsilon > 0$ (facteur multiplicatif), il existe une constante entière $n_0 \\in \\mathbb{N}$ (seuil) telle que:\n",
    "  \n",
    "$$f(n) \\le \\varepsilon \\cdot g(n) \\text{ pour tout } n \\ge n_0$$\n",
    "\n",
    "en d'autres termes: $\\lim_{n \\to \\infty} \\frac{f(n)}{g(n)} = 0$\n",
    "\n",
    "Intuition: $f$ est asymptotiquement négligeable face à $g$\n",
    "\n",
    "*NB:* pour **chaque $\\epsilon$** on doit trouver un tel $n_0$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3efa0faa",
   "metadata": {},
   "outputs": [],
   "source": [
    "import utils\n",
    "\n",
    "### MODIFIER f, g, xrange, eps ET n0 CI-DESSOUS\n",
    "\n",
    "# Fonction f\n",
    "def f(x: float) -> float:\n",
    "    return 7 * x**2 - 2 * x + 10\n",
    "\n",
    "# Fonction g\n",
    "def g(x: float) -> float:\n",
    "    return 5 * x**2\n",
    "\n",
    "# Intervalle des valeurs de x\n",
    "xrange = (1, 100)\n",
    "\n",
    "# facteur multiplicatif epsilon\n",
    "eps = 2\n",
    "\n",
    "# Objectif: pour eps fixé, trouver un seuil n0 qui satifait la définition\n",
    "n0 = 20\n",
    "\n",
    "### NE PAS MODIFIER CI-DESSOUS\n",
    "\n",
    "# Fonction x |-> e * g(x)\n",
    "def e_g(x):\n",
    "    e_g.__name__ = f\"{eps} * g\"\n",
    "    return eps * g(x)\n",
    "\n",
    "# Fonction x |-> f(x) / g(x)\n",
    "def f_div_g(x):\n",
    "    f_div_g.__name__ = f\"f(x)/g(x)\"\n",
    "    return f(x) / g(x)\n",
    "\n",
    "plt = utils.plotFunctions([f, g, e_g], xrange)\n",
    "plt.axvline(x = n0, color = 'y', label = f\"n0={n0}\")\n",
    "plt.legend()\n",
    "\n",
    "plt_ratio = utils.plotFunctions([f_div_g], xrange)\n",
    "None"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "pyvenv-3.14 (3.14.7)",
   "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.14.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
