{ "cells": [ { "cell_type": "markdown", "id": "c47b6799", "metadata": {}, "source": [ "# Feuille de calcul symbolique de développements limités " ] }, { "cell_type": "markdown", "id": "a7bc68b7", "metadata": {}, "source": [ "Importation des packages Python" ] }, { "cell_type": "code", "execution_count": 1, "id": "b41024c8", "metadata": {}, "outputs": [], "source": [ "from sympy import *\n", "from sympy.interactive import printing " ] }, { "cell_type": "markdown", "id": "d3468afe", "metadata": {}, "source": [ "x est désormais un symbole (qui sera la variable dans nos DL)" ] }, { "cell_type": "code", "execution_count": 2, "id": "9b93e6b6", "metadata": {}, "outputs": [], "source": [ "x = symbols('x')" ] }, { "cell_type": "markdown", "id": "54ed43ba", "metadata": {}, "source": [ "La fonction series permet de faire des DL.\n", "Par défaut, les DL sont calculés en 0 à l'ordre 5.\n", "Attention : Python utilise un \"grand O\" et pas un \"petit o\". " ] }, { "cell_type": "code", "execution_count": 13, "id": "58cab3ff", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle x - \\frac{x^{2}}{2} + \\frac{x^{3}}{3} - \\frac{x^{4}}{4} + \\frac{x^{5}}{5} + O\\left(x^{6}\\right)$" ], "text/plain": [ "x - x**2/2 + x**3/3 - x**4/4 + x**5/5 + O(x**6)" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "series(ln(1+x),x)" ] }, { "cell_type": "markdown", "id": "1553eae7", "metadata": {}, "source": [ "On écrira que $\\ln(1+x)= x-\\dfrac{x^2}{2}+ \\dfrac{x^3}{3}-\\dfrac{x^4}{4}+\\dfrac{x^5}{5}+o(x^5)$." ] }, { "cell_type": "code", "execution_count": 15, "id": "affa29e4", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 1 - \\frac{x^{2}}{2} + \\frac{x^{4}}{24} + O\\left(x^{6}\\right)$" ], "text/plain": [ "1 - x**2/2 + x**4/24 + O(x**6)" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "series(cos(x),x)" ] }, { "cell_type": "markdown", "id": "000849cc", "metadata": {}, "source": [ "On écrira que $\\cos(x)= 1-\\dfrac{x^2}{2}+ \\dfrac{x^4}{24}+o(x^5)$." ] }, { "cell_type": "markdown", "id": "92b1e9e5", "metadata": {}, "source": [ "Pour faire un DL au point c à un ordre supérieur à 6, exécuter le code ci-dessous." ] }, { "cell_type": "code", "execution_count": 17, "id": "67cf9660", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\frac{1}{2} - \\frac{\\left(x - 1\\right)^{2}}{8} + \\frac{\\left(x - 1\\right)^{3}}{16} - \\frac{5 \\left(x - 1\\right)^{4}}{128} + \\frac{7 \\left(x - 1\\right)^{5}}{256} - \\frac{21 \\left(x - 1\\right)^{6}}{1024} + \\frac{33 \\left(x - 1\\right)^{7}}{2048} + \\frac{x}{2} + O\\left(\\left(x - 1\\right)^{8}; x\\rightarrow 1\\right)$" ], "text/plain": [ "1/2 - (x - 1)**2/8 + (x - 1)**3/16 - 5*(x - 1)**4/128 + 7*(x - 1)**5/256 - 21*(x - 1)**6/1024 + 33*(x - 1)**7/2048 + x/2 + O((x - 1)**8, (x, 1))" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c=1\n", "n=7\n", "series(sqrt(x),x,c,n+1)" ] }, { "cell_type": "markdown", "id": "5b042275", "metadata": {}, "source": [ "Pensez à remplacer le $O((x-1)^8)$ par un $o((x-1)^7)$." ] }, { "cell_type": "markdown", "id": "c85bb61a", "metadata": {}, "source": [ "## Corrections de la feuille de TD 9" ] }, { "cell_type": "markdown", "id": "b338d531", "metadata": {}, "source": [ "Exercice 5" ] }, { "cell_type": "code", "execution_count": 19, "id": "d8bc9dd3", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 1 + 2 x - \\frac{3 x^{2}}{2} + \\frac{2 x^{3}}{3} - \\frac{11 x^{4}}{24} + O\\left(x^{5}\\right)$" ], "text/plain": [ "1 + 2*x - 3*x**2/2 + 2*x**3/3 - 11*x**4/24 + O(x**5)" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 1.\n", "series(cos(x)+2*ln(1+x),x,0,5)" ] }, { "cell_type": "markdown", "id": "d913fa9f", "metadata": {}, "source": [ "On obtient $\\cos(x)+2\\ln(1+x)=1+2x-\\dfrac{3x^2}{2}+ \\dfrac{2x^3}{3}-\\dfrac{11x^4}{24}+o(x^4)$." ] }, { "cell_type": "code", "execution_count": 21, "id": "996cf4c0", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 1 - \\frac{x}{2} - \\frac{x^{2}}{8} + \\frac{11 x^{3}}{48} - \\frac{5 x^{4}}{128} + \\frac{73 x^{5}}{3840} + O\\left(x^{6}\\right)$" ], "text/plain": [ "1 - x/2 - x**2/8 + 11*x**3/48 - 5*x**4/128 + 73*x**5/3840 + O(x**6)" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#2.\n", "series(sqrt(1+x)-sin(x),x,0,6)" ] }, { "cell_type": "markdown", "id": "8ac973a1", "metadata": {}, "source": [ "On obtient $\\sqrt{1+x}-\\sin(x)=1-\\dfrac{x}{2}-\\dfrac{x^2}{8}+ \\dfrac{11x^3}{48}-\\dfrac{5x^4}{128}+ \\dfrac{73x^5}{3840}+o(x^5)$." ] }, { "cell_type": "code", "execution_count": 23, "id": "34295d0a", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 2 x + \\frac{2 x^{3}}{3} + O\\left(x^{5}\\right)$" ], "text/plain": [ "2*x + 2*x**3/3 + O(x**5)" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#3.\n", "series(x+x**3+atan(x),x,0,5)" ] }, { "cell_type": "markdown", "id": "428c0684", "metadata": {}, "source": [ "On obtient $x+x^3+\\arctan(x)=2x+ \\dfrac{2x^3}{3}+o(x^4)$." ] }, { "cell_type": "markdown", "id": "3c7f3f1a", "metadata": {}, "source": [ "Exercice 6" ] }, { "cell_type": "code", "execution_count": 25, "id": "532db4ef", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\frac{1}{2} - \\frac{\\left(x - 1\\right)^{2}}{8} + \\frac{\\left(x - 1\\right)^{3}}{16} + \\frac{x}{2} + O\\left(\\left(x - 1\\right)^{4}; x\\rightarrow 1\\right)$" ], "text/plain": [ "1/2 - (x - 1)**2/8 + (x - 1)**3/16 + x/2 + O((x - 1)**4, (x, 1))" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#1.\n", "series(sqrt(x),x,1,4)" ] }, { "cell_type": "markdown", "id": "71f4b942", "metadata": {}, "source": [ "On obtient $\\sqrt{x} = \\dfrac{1}{2}- \\dfrac{(x-1)^2}{8}+\\dfrac{(x-1)^3}{16}+\\dfrac{x}{2}+o((x-1)^3)$." ] }, { "cell_type": "code", "execution_count": 28, "id": "42ce6f43", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle -1 - \\frac{\\left(x - 1\\right)^{2}}{2} + \\frac{\\left(x - 1\\right)^{3}}{2} + x + O\\left(\\left(x - 1\\right)^{4}; x\\rightarrow 1\\right)$" ], "text/plain": [ "-1 - (x - 1)**2/2 + (x - 1)**3/2 + x + O((x - 1)**4, (x, 1))" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#2.\n", "series(asin(ln(x)),x,1,4)" ] }, { "cell_type": "markdown", "id": "c832729a", "metadata": {}, "source": [ "On obtient $\\arcsin(\\ln(x)) = -1-\\dfrac{(x-1)^2}{2}+\\dfrac{(x-1)^3}{2}+x+o((x-1)^3)$." ] }, { "cell_type": "code", "execution_count": 30, "id": "6e15c5d6", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle e^{\\frac{\\sqrt{3}}{2}} + \\frac{\\left(x - \\frac{\\pi}{3}\\right) e^{\\frac{\\sqrt{3}}{2}}}{2} + \\left(x - \\frac{\\pi}{3}\\right)^{2} \\left(- \\frac{\\sqrt{3} e^{\\frac{\\sqrt{3}}{2}}}{4} + \\frac{e^{\\frac{\\sqrt{3}}{2}}}{8}\\right) + \\left(x - \\frac{\\pi}{3}\\right)^{3} \\left(- \\frac{\\sqrt{3} e^{\\frac{\\sqrt{3}}{2}}}{8} - \\frac{e^{\\frac{\\sqrt{3}}{2}}}{16}\\right) + O\\left(\\left(x - \\frac{\\pi}{3}\\right)^{4}; x\\rightarrow \\frac{\\pi}{3}\\right)$" ], "text/plain": [ "exp(sqrt(3)/2) + (x - pi/3)*exp(sqrt(3)/2)/2 + (x - pi/3)**2*(-sqrt(3)*exp(sqrt(3)/2)/4 + exp(sqrt(3)/2)/8) + (x - pi/3)**3*(-sqrt(3)*exp(sqrt(3)/2)/8 - exp(sqrt(3)/2)/16) + O((x - pi/3)**4, (x, pi/3))" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#3.\n", "series(exp(sin(x)),x,pi/3,4)" ] }, { "cell_type": "markdown", "id": "550b6927", "metadata": {}, "source": [ "Exercice 7 \n", "\n", "Remarque : penser à remplacer les $O(x^{n+1})$ par des $o(x^n)$. " ] }, { "cell_type": "code", "execution_count": 31, "id": "d8af9e4e", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 1 + x - \\frac{x^{3}}{3} - \\frac{x^{4}}{6} + O\\left(x^{5}\\right)$" ], "text/plain": [ "1 + x - x**3/3 - x**4/6 + O(x**5)" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#1.\n", "series(cos(x)*exp(x),x,0,5)" ] }, { "cell_type": "code", "execution_count": 32, "id": "3c3fea13", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle x^{6} + O\\left(x^{7}\\right)$" ], "text/plain": [ "x**6 + O(x**7)" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#2.\n", "series((sin(x))**6,x,0,7)" ] }, { "cell_type": "code", "execution_count": 33, "id": "14d7554c", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle x^{2} - x^{3} + \\frac{11 x^{4}}{12} + O\\left(x^{5}\\right)$" ], "text/plain": [ "x**2 - x**3 + 11*x**4/12 + O(x**5)" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#3.\n", "series((ln(1+x))**2,x,0,5)" ] }, { "cell_type": "markdown", "id": "03d38bbf", "metadata": {}, "source": [ "Exercice 8 \n", "\n", "Remarque : penser à remplacer les $O(x^{n+1})$ par des $o(x^n)$." ] }, { "cell_type": "code", "execution_count": 34, "id": "5ca26140", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 1 + \\frac{x^{2}}{2} + \\frac{5 x^{4}}{24} + O\\left(x^{5}\\right)$" ], "text/plain": [ "1 + x**2/2 + 5*x**4/24 + O(x**5)" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#1.\n", "series(1/cos(x),x,0,5)" ] }, { "cell_type": "code", "execution_count": 35, "id": "974797ce", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle x + \\frac{x^{3}}{3} + \\frac{2 x^{5}}{15} + O\\left(x^{6}\\right)$" ], "text/plain": [ "x + x**3/3 + 2*x**5/15 + O(x**6)" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#2.\n", "series(tan(x),x,0,6)" ] }, { "cell_type": "code", "execution_count": 37, "id": "5a3f6414", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\log{\\left(4 \\right)} + \\frac{x}{2} + \\frac{3 x^{2}}{8} - \\frac{x^{3}}{8} - \\frac{x^{4}}{64} + \\frac{x^{5}}{32} + O\\left(x^{6}\\right)$" ], "text/plain": [ "log(4) + x/2 + 3*x**2/8 - x**3/8 - x**4/64 + x**5/32 + O(x**6)" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#3.\n", "series(ln(3*exp(x)+exp(-x)),x,0,6)" ] }, { "cell_type": "markdown", "id": "8498dc2f", "metadata": {}, "source": [ "Exercice 11 " ] }, { "cell_type": "code", "execution_count": 38, "id": "7a501b81", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle - \\frac{1}{2} + \\frac{23 x^{2}}{24} - \\frac{719 x^{4}}{720} + O\\left(x^{6}\\right)$" ], "text/plain": [ "-1/2 + 23*x**2/24 - 719*x**4/720 + O(x**6)" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 1.\n", "series((1/(1+x**2)-cos(x))/x**2,x,0)" ] }, { "cell_type": "markdown", "id": "382e2535", "metadata": {}, "source": [ "On en déduit que $\\lim_{x\\to 0}f(x) = -\\dfrac{1}{2}$." ] }, { "cell_type": "code", "execution_count": 42, "id": "233e48f7", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 2 - \\frac{11 x^{2}}{10} + \\frac{3359 x^{4}}{4200} + O\\left(x^{6}\\right)$" ], "text/plain": [ "2 - 11*x**2/10 + 3359*x**4/4200 + O(x**6)" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 2.\n", "series((atan(x)-x)/(sin(x)-x),x,0)" ] }, { "cell_type": "markdown", "id": "fca5e0a6", "metadata": {}, "source": [ "On en déduit que $\\lim_{x\\to 0}f(x) = 2$." ] }, { "cell_type": "code", "execution_count": 44, "id": "41511bf5", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\frac{2}{3} + \\frac{4 x^{4}}{189} + O\\left(x^{6}\\right)$" ], "text/plain": [ "2/3 + 4*x**4/189 + O(x**6)" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 3.\n", "series(1/(sin(x))**2 - 1/(sinh(x))**2,x,0)" ] }, { "cell_type": "markdown", "id": "59613413", "metadata": {}, "source": [ "On en déduit que $\\lim_{x\\to 0}f(x) = 2/3$." ] }, { "cell_type": "code", "execution_count": 48, "id": "383e2d72", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\frac{\\log{\\left(b \\right)}}{2} + \\frac{\\log{\\left(a \\right)}}{2} + x \\left(- \\frac{\\left(\\frac{\\log{\\left(a \\right)}}{2} + \\frac{\\log{\\left(b \\right)}}{2}\\right)^{2}}{2} + \\frac{\\log{\\left(a \\right)}^{2}}{4} + \\frac{\\log{\\left(b \\right)}^{2}}{4}\\right) + O\\left(x^{2}\\right)$" ], "text/plain": [ "log(b)/2 + log(a)/2 + x*(-(log(a)/2 + log(b)/2)**2/2 + log(a)**2/4 + log(b)**2/4) + O(x**2)" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#4.\n", "a = symbols('a')\n", "b = symbols('b')\n", "# La technique est de faire un DL de ln(f(x)).\n", "# on tronque le DL pour n'avoir que des termes d'ordre 0 et 1.\n", "series(ln((a**x +b**x)/2)*(1/x),x,0,2)" ] }, { "cell_type": "markdown", "id": "d88a94dd", "metadata": {}, "source": [ "En repassant à l'exponentielle, on en déduit que $\\lim_{x\\to 0} f(x) = \\sqrt{ab}$." ] }, { "cell_type": "code", "execution_count": null, "id": "1e263d0c", "metadata": {}, "outputs": [], "source": [] } ], "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.4" } }, "nbformat": 4, "nbformat_minor": 5 }