{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Sympy" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%config InlineBackend.figure_format = 'svg'\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us import everything from sympy. We will also enable pretty printing." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from sympy import *\n", "init_printing()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We must define symbols which will be treated symbolically" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "sympy.core.symbol.Symbol" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = symbols('x')\n", "type(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us define an expression" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x*sin(pi*x) + tan(pi*x)\n" ] } ], "source": [ "f = x*sin(pi*x) + tan(pi*x)\n", "print(f)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Differentiation**. We can perform symbolic differentiation." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAAaCAYAAACn6qfNAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAKeElEQVR4Ae2d65HUOBDHh60NAI4IDjLgEQGQAY8IWDI4im98oyAD7iJYIAMgAh4ZwEVwMBlw/59WLWSP7bFlW56x3VVCltSS+qV2W9Kwl379+rVZYZXA3CTw/Pnzy+Lpmefrms8fq347N15XflYJmARO7GHNVwkMIQE5zDOlu0OM1XOMl6LjqU8PNNYPpS89x1y7ewlIrq9XYRyeBFaHfng6OVqKtMjvi/ibyj8cABPlF8tL0XRNtN04ANrmQAIvzPdzYGROPKwOXdqUYdoneRbd5p4vB1PiyW1x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AS3vR++YJMhu9y//ox7euQH2sUQAAAABJRU5ErkJggg==", "text/latex": [ "$\\displaystyle \\pi x \\cos{\\left(\\pi x \\right)} + \\pi \\left(\\tan^{2}{\\left(\\pi x \\right)} + 1\\right) + \\sin{\\left(\\pi x \\right)}$" ], "text/plain": [ " ⎛ 2 ⎞ \n", "π⋅x⋅cos(π⋅x) + π⋅⎝tan (π⋅x) + 1⎠ + sin(π⋅x)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "diff(f,x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compute second derivative" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAg0AAAAaCAYAAAA0VG+eAAAACXBIWXMAAA7EAAAOxAGVKw4bAAANIElEQVR4Ae2d7ZXdtBaGT2algCFUAHQQkgoIHQSoIKGDy8q//MsKHXBvBRPoAKiAkA4CFdxwOsh9H423ro+PLMu2bMtztNdSZOtz692vPq05uffx48dDlYpARaA8BF6+fHktrV40mn3e+M8UfixP26pRRaAicAkIXC3ZSA1uz+WeLFlHLbsisAQChXD3tfT4oXHfqJ0f5P5cor2XWqaw/elS217bXRGIIdDXNxZbNKjCp1LoS/m/xRSrcRWB0hAoiLvdRfdrYfW59HtYGmY71oeF2a871r+qXhFYCoFg31hk0aBO6I5V5X+/VGsuqVzhaEfTizd7zboWb8yECgrjLv3n7YRmnGRZ26Zr13fS2JEv0vUvZflZ/r9GZi0y+drYr11fkaBnUmptLIfqU3ywbyyyaBCGP8vVY78MZJLhGMzW3Fmyk70TA+hE+Ivhruzwb7n2/QUWEX8p7F1q2xpbrskfVNsVh8BZOn8vn83ObqXaeremO5RqO+l11jfu5b4IqUrYFf8p/5P9mjBNc2urUvPdGXCzisrkE89j+T9kLXigMNXHouG4RJsGqvbRqhseWbsf6Znv+eCcPGH6whIfmjqL5K50Y+JnQcMnv/ZCord1SrcJf1BIdW/OIQNGugxi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bgVYNjCAg/CAyO3Ukyli1bnOqlYzC4xr75RetT3qdKMOsiZLSCzJHS985wV23ZlD+YRjrM4pDyr8of1cdmggkjtKDIzLZ8xUnfaut8cK5a0l5s1+4bVwsgxJ0Idn9V5iHwWtm32OWb1pw6ocMcYQVuq/M55ayV9y5xd2v+YLO5HFqNPxoUr6Uvp0And7poxA6k2noHRupRsXjbdfvGEicNdLzfVdHUn8DtwfbygoUhx/R8VnFHZWshoPrYIbLjuqjFn9p7p7ir9mzCH3iqunfFIenLpzB+o6bvkyHNKlakd7V1sdaJK1a67bp9I/tJgyrgOJ0fRuJosco8BBjA+Na2tlDnlqcca7fX1XcHubsVf8BzbxziVKR7p8vxYif/VFvvxFABNUu33UnfyL5oaAB5Jv9FAJwaNAIBTWIcz3LSwAW7VaSpa/XTjVUal1bJneHuFvwB4r1xSPpyyuAvv6XRpKxU1dZl2WOMNiXbLtQ3sn+eMLBUGScNob+ztyTVrwgUiUDlbpFmWUQp2XpXn1EWAaEWWhEIINDXN5Y6aTioQv6c8b18+3OngFo1qCJQHgKVu+XZZEGNOHrleLhKRaAicIpAsG/8D2gJUq058ltrAAAAAElFTkSuQmCC", "text/latex": [ "$\\displaystyle \\pi \\left(- \\pi x \\sin{\\left(\\pi x \\right)} + 2 \\pi \\left(\\tan^{2}{\\left(\\pi x \\right)} + 1\\right) \\tan{\\left(\\pi x \\right)} + 2 \\cos{\\left(\\pi x \\right)}\\right)$" ], "text/plain": [ " ⎛ ⎛ 2 ⎞ ⎞\n", "π⋅⎝-π⋅x⋅sin(π⋅x) + 2⋅π⋅⎝tan (π⋅x) + 1⎠⋅tan(π⋅x) + 2⋅cos(π⋅x)⎠" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "diff(f,x,2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Product of two functions**. Define a more complicated expression as product of two expressions\n", "\n", "$$\n", "h(x) = f(x) g(x)\n", "$$\n", "\n", "and differentiate it" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAApcAAAAaCAYAAADi3Xe+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAPEklEQVR4Ae2d77XctBbFJ3elgAAVPOgAQgWEDgJUkNABrPst37Kgg7xXwU3SAVABIR2EV8EL08F9++exvDQzkqWxJMv26Kyla1t/j/bZOpJle+6D+/v7XZOGQEOgIdAQaAhsBYEXL148Ul9u+/583h+fKX6/lT62fjQElozAzZKVa7o1BBoCZRDQJPtc4UmZ2lut14zAQrj1i/T4uQ/fyR4fFf66Zrvk7ruwfZW7zlZfXgRq2qgtLvPastXWEFg8AnI4T6XkVzr+vnhlm4KrQmBB3Dq9efpFQH4u/b5cFaDLVpYF/G/LVvHqtatmo7PFpchiHiFswipz92fu9tZmpDnxCbUVSk/BVnX/1IdXtGOfp9SbWlZ6dI8Ldfwxta4tlcdGc/Zn7vbm6NvCuAW/36X2e247zd1eCj7S9W+Vf6PjTyn1bKns3PYLtVfaRti+D2fz3NHikkwy9Gbu7Cr1p1tIbGnA5OpLBXuEbBFKn9T1vp9vdfxVFXyqwMDj/LFC7fH1Bn0UmvQIVOAlLRfhXmWjLoZbsum/Fez3K1ls/q2497EYNV6EkQJn5fpRR25ar1qWypdSNur7653nhsWlMvKo7DMd387BELWDc/1H4XmJ9lTvrP0xfVC73aPGUv0y7aztWMMeIVuE0hMw3qtu7uoRnK55dMQHBbOMr67lkz9qm925xzoyITQRAsKi+YkMTFgyt6QbN3TY+avYrjZeHJACO4UPCmOLR25W/xOLbY180v/a1xslbDQ6z3WLy544tzr+PKPhmeggbPSAj9WtUn8G9dQ+u1TV7+akB+8ZVZea9gjZIpQ+BTzVaS/e+GimW1AqPnrXZEq7EWUY37ZuEUW2m0X2wP/M7fcGQEtwb6h8/pNRbqmvVXyR2mWeoW3eMd7HwKJ8V80L+q/A426zIAHDMcGnPO1xG8tXM+3a1xvZbSR723PJ2Tx301ubwTfrozIpx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} + \\pi \\left(\\tan^{2}{\\left(\\pi x \\right)} + 1\\right) + \\sin{\\left(\\pi x \\right)}\\right) e^{x}$" ], "text/plain": [ " x ⎛ ⎛ 2 ⎞ ⎞ x\n", "(x⋅sin(π⋅x) + tan(π⋅x))⋅ℯ + ⎝π⋅x⋅cos(π⋅x) + π⋅⎝tan (π⋅x) + 1⎠ + sin(π⋅x)⎠⋅ℯ " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = exp(x)\n", "h = f*g\n", "diff(h,x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Function composition**. Composition of two functions\n", "\n", "$$\n", "h(x) = (f \\circ g)(x) = f(g(x))\n", "$$\n", "\n", "Apply this to the case $f(x) = \\sin(x)$, $g(x) = \\cos(x)$." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "h = sin(cos(x))\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAALgAAAAVCAYAAAD1sST3AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFlElEQVRoBd2a7XHUMBCGLxkKCKSD0AEfFQAdBFJBoAMYfiX/GNIB0AGhA6ACknQAHRDSQXgfoTWyI9l39up8k51RZH3sq3e1K1nWZXF9fb24jeno6GhvrF1TdMeO6aW36dyn8BvSzbVvL26hHB8fv5ZZDyaYthcxJkCsX9XB7qqkHfgN+eVG+9oDXEZC4o/SyxqzKdx94e4q/zIWX7rf0FVeheNYXn164jrZ7j78qW0e/ITR65dc+9oDXBO1p7Sj9HDqpHX1ZSC4b5W/6batWhbGiXReRcxV1dfa39PuGsQ9+Q35pdu+9gAXAVbhXeWvKkzme2F+cMQFC8xNF2+7ve315jfkl//tXh83m4Cjj4w/3jzAVNrxxvXEq2H3pvMb8ou1r30H994aDE9vBM6gv6zsmIP5whHPFaqi3S48K/Ib8ktov+NiRQIig7i9eKp0pcSZGDlQ/UMlzt+nSuTfVH6ufKEcn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d6zsjUs+PSP9QLI/tBGLG5mmu9klVmIRFIXBstVCag+D6AJ9d7BH5zXFG5JWpDj/9JsSBstVNQm41BMYyjvHVroj7Ywq0JdiCUPxiucmwszh0KOZEec3rDbuur9tm4waHEL+FVxS/CD35zDXCb1LnyaFT2hmcMJ+ERhCzO1qIZg1VTx9tub67e/Ib8krZvexszMx47NTu+l4R7ai+wijjedntT9eY35Jem/VYFuFYuH7Sch9l5J0nEAMt+DJqEV1PZ0+4aPD35Dfml236rAjw6hzN695fTMX4Dw/NtMIbDKjpedq8y5ip9vfgN+aXd7vlvkZuCpX+V3FN6PZYPumCM1Z9Lb6rdtXlP5Tfkl1z7XzsiWt4mbePIAAAAAElFTkSuQmCC", "text/latex": [ "$\\displaystyle - \\sin{\\left(x \\right)} \\cos{\\left(\\cos{\\left(x \\right)} \\right)}$" ], "text/plain": [ "-sin(x)⋅cos(cos(x))" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = cos(x)\n", "h = sin(g)\n", "print('h =',h)\n", "diff(h,x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the two functions $f,g$ have already been defined and we want to compose, then we can use substitution," ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "h = sin(cos(x))\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAALgAAAAVCAYAAAD1sST3AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFlElEQVRoBd2a7XHUMBCGLxkKCKSD0AEfFQAdBFJBoAMYfiX/GNIB0AGhA6ACknQAHRDSQXgfoTWyI9l39up8k51RZH3sq3e1K1nWZXF9fb24jeno6GhvrF1TdMeO6aW36dyn8BvSzbVvL26hHB8fv5ZZDyaYthcxJkCsX9XB7qqkHfgN+eVG+9oDXEZC4o/SyxqzKdx94e4q/zIWX7rf0FVeheNYXn164jrZ7j78qW0e/ITR65dc+9oDXBO1p7Sj9HDqpHX1ZSC4b5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itj0dA1GacOCuPnbuS3Yw5NzfMLPGr5hcGlQS/eQc4wAQLqycVys11WGzo9qEaUmMFZ3L91xWCiHQZeV2mHWKQ3TgfJ33CeT0pdx85v/P/Nd2FzfEMTsgTpRfqQxCnQh9uUGxulp27FKNkN33m5gaHEr/afgl+2+IXKy+JwcJOlZ77dlVmB+UDFAdzPredC8ceKrHz2rmdnYd6zsjUs+PSP9QLI/tBGLG5mmu9klVmIRFIXBstVCag+D6AJ9d7BH5zXFG5JWpDj/9JsSBstVNQm41BMYyjvHVroj7Ywq0JdiCUPxiucmwszh0KOZEec3rDbuur9tm4waHEL+FVxS/CD35zDXCb1LnyaFT2hmcMJ+ERhCzO1qIZg1VTx9tub67e/Ib8krZvexszMx47NTu+l4R7ai+wijjedntT9eY35Jem/VYFuFYuH7Sch9l5J0nEAMt+DJqEV1PZ0+4aPD35Dfml236rAjw6hzN695fTMX4Dw/NtMIbDKjpedq8y5ip9vfgN+aXd7vlvkZuCpX+V3FN6PZYPumCM1Z9Lb6rdtXlP5Tfkl1z7XzsiWt4mbePIAAAAAElFTkSuQmCC", "text/latex": [ "$\\displaystyle - \\sin{\\left(x \\right)} \\cos{\\left(\\cos{\\left(x \\right)} \\right)}$" ], "text/plain": [ "-sin(x)⋅cos(cos(x))" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f = sin(x)\n", "g = cos(x)\n", "h = f.subs({'x':g})\n", "print('h =',h)\n", "diff(h,x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Integration**. We can also compute indefinite integrals" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "sin(x)\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEwAAAAVCAYAAADsFggUAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADaElEQVRYCd2X7VEbMRCGDUMBTqggpoOEVAB0AKYCoIMw/LL/ZaADSAnQAaECEjoIHcS4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2nkm2OycCy0AAAAASUVORK5CYII=", "text/latex": [ "$\\displaystyle - \\cos{\\left(x \\right)}$" ], "text/plain": [ "-cos(x)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(f)\n", "integrate(f,x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can get definite integrals." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFoAAAAVCAYAAADGpvm7AAAACXBIWXMAAA7EAAAOxAGVKw4bAAADLUlEQVRYCe2Y0VEbMRCGzxkKcJIO7A4CVADuAEgFwR2E4cl+hQ6AEqADQgUM7gB3EOIOnP+TJc2dTjqf75yJB25n1pJ2V+vTr9Vq77Llcpl1nMZgMpkMNsUnNudT1lESgel0+lPKb0mDtGJg53qLHrvlSEqc3ov31V84+Udstf4TrftQ7UVs/euwkp5NWqi9ZX5PYd5Xeyd+Ex+IAfuzDD4s0Fo7mDyp3VfrycprYyX7F00+UrvY40eDU7yp3/SoMP090ZUWcxMuqAFW+MDXuMvRIZqr8ZlANUc+rq4ntT7w1e+ADjATKOTmeSBuM8TX2V4bD/9qLhEg3xw50pqjZ8kf3CBn82plQ7X3kv/K2XDfHIvxg0/ou2wKuXcl9r8j9bwPL23ewddo54AWCAM9GJfID/UNsGoBCxDn4pnYVUcjZNIZUv8RnfhabDZLLcB50njsB/EOBUEpP8dNa0kJhONdTB2UlwDqo1djF41EJoTNg2w8yEaaZZRiV5KzEQB2oL6ba03Wgog9Fdi2CF+DVhFtF/EkR+Fiqh7yVPNmMQPrD5Cu83rJAd1FN3qi/jlvQx+/Yrqkhwsxi/yjluP7KGZzCr4lC+mLBG5DQ12TMcHQbws0D1SV7zZ9MACEfq+a6K+zqQKDzYB4tksxFxw5n2i/Fa9LHzLdGpmN27XU4VIBF1uKnE3VKSL1mA1RS2QPxT05BOBz9d1GxP6DU1DlOzanSoavt50CWgAQpaQV8muJpD8Ro8eucMlhLB2XJkQOB8xzBo6kpzYmBUX9Wzs20p0aK2rVENHzEOiv1iXK/0W8pfJRJgSJow/I0JGYF4EwMrGh4nDl2aX6YXQydnp1S8R/HJakZUFdrEhfM/NRSQ9DBEBEBA/Cn7GzlEut35DkZyOy4AAa5OrkQpUhG6KOKoPohhjfSG5AVMtaiPp8vgcc1pQEWjo2j1Iymr4k3wgr2fP848LXOwk6EgIWnGR1VBck+WHz2dhhmDrq+njvdpymbVQmpq4HrA7oSMgoAkmX3BNEZCOyc/FhUm8HdBpGLuU2r+LM9aeiy9FpoDMblZSU694mC15kz3f9wuX9F2NSOAIx4Go7AAAAAElFTkSuQmCC", "text/latex": [ "$\\displaystyle 1 - \\cos{\\left(1 \\right)}$" ], "text/plain": [ "1 - cos(1)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "integrate(f,(x,0,1))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Taylor expansion**. Compute Taylor expansion of $f(x)$ around $x=0$" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "sin(x)\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAAAvCAYAAAA4htUtAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAMnklEQVR4Ae2dvbLdNBDHb8J9gEvoKOEN8tFnhvAGhDxBSEkHk+52GXiDkC5dIB1lkpk0VIG0VIGOjnA66ML/p3g1so+Pbfkc+0i62hkdybIka1fa1e5K9rn07t27kwqVArlS4Pz8/BOFP3Ltf+n9vlSigGHSaeBuKbxVIH1D4YHyXyvOHhr87gmRZw0y4PhW+U+zRy4SAeH8UFXAn7glaEoZ70iSJFX8NKneHK4z36mpPzTBfqBJxd8oeqHwIdcFAAz1lQJ4wVRPDVelLxpACxYTQgiMPUK4whEpUKqAedCh6Ue6RpspCT6TUClCI9tzUFhILoVt6PqhQhUuIVGOlC5SwPQw3heiL1pNUSA8WbXPF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tokGMnXXL8TnnuqbsJ2LY9je3DaSricadXnk4P3VM1obEvaAnDUYcOhbudjiRABhQhUDGkCYsPsCW5/vxXC21RvTMWVgDHnhD21kMj4q7+z9EcQmtzfSTr09kwJZChhNrk2Dr8V96DNhi4CGmTjt2tUADH8Eahcsr08Id8sufq2+czoc4b8L2BmbhI/KMbaUH8Rtanu7OlTz96dAliZSgzaq9ZAQGZx8+5NunRbEJPiTeBfF27dKO7wVg+MuOpgGk4rDG42yT6Nw/RQurxuKTsGHtvjvHUzGEK7qAm2IfLQ9zKcp7YVt1PQBKZCzgMFk6E4wSHNNAcdfKoxFn2aBcIBhYKSunwGhY3Y1NLDXBMLnQAd2mkwrCO8dI82fdXXxoB84H8OxmoIP5cM6tHOi9vm2Cb43L4x1PaU9qldYgAKXF2hzlSY1ifCOM5k8cymNWcBJQvb/cwBzMJq24fssXNBSYA5MAc4W+KA8nJtOcChG0PBCKkLHgdIp0sH13/pIrH7a6VsvEJS3Dz7gTfCwZ3u+nZqYR4HeL9rNa+o4tTSBEDA2qWBUf67iOD0af6r6jOAAWL3pO+YB5o7/e1CVcV87U14foJmgoThQmjagw0YBp+4NheTooH4iNE2LYawwmThiQL89xOKj8miztA09ARYf/gXD7bbFtudaqD8HocD/oVhsQ+1zuSgAAAAASUVORK5CYII=", "text/latex": [ "$\\displaystyle x - \\frac{x^{3}}{6} + \\frac{x^{5}}{120} - \\frac{x^{7}}{5040} + O\\left(x^{8}\\right)$" ], "text/plain": [ " 3 5 7 \n", " x x x ⎛ 8⎞\n", "x - ── + ─── - ──── + O⎝x ⎠\n", " 6 120 5040 " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(f)\n", "series(f,x,0,8)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compute Taylor expansion of $h(x)$ around $x=0$" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "sin(cos(x))\n" ] }, { "data": { "image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oLwVzQDm5AhcBQKSWx7Ts1WLrR6nJNfdU3b71TbadTZ/17mhnB9jL+GkCGgAYz8p+zybl25OCoU3+woQkJyy5YJv9YZ7ZK+g5umr6LqbHlPnmB4B19n0mMY4uqEcQ8XDHIFECNRGB8ZH8+Z5ItbOxhFIhoDkkxeSWNA9S8b0yhm57l55Bx68+q6z23WwG8rbYe0lnRQBDWh8cYTPO2GMODkCRSEgueTLCD/oeKbrs+5LjvaJ624UFg/cGQHX2W074P+/oYyveJ1YDgAAAABJRU5ErkJggg==", "text/latex": [ "$\\displaystyle \\sin{\\left(1 \\right)} - \\frac{x^{2} \\cos{\\left(1 \\right)}}{2} + x^{4} \\left(- \\frac{\\sin{\\left(1 \\right)}}{8} + \\frac{\\cos{\\left(1 \\right)}}{24}\\right) + x^{6} \\left(\\frac{7 \\cos{\\left(1 \\right)}}{360} + \\frac{\\sin{\\left(1 \\right)}}{48}\\right) + O\\left(x^{8}\\right)$" ], "text/plain": [ " 2 \n", " x ⋅cos(1) 4 ⎛ sin(1) cos(1)⎞ 6 ⎛7⋅cos(1) sin(1)⎞ ⎛ 8⎞\n", "sin(1) - ───────── + x ⋅⎜- ────── + ──────⎟ + x ⋅⎜──────── + ──────⎟ + O⎝x ⎠\n", " 2 ⎝ 8 24 ⎠ ⎝ 360 48 ⎠ " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(h)\n", "series(h,x,0,8)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Expression is not a function" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "p = (x + 1)/(x**2 + 2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We cannot evaluate `p` at a numerical value. To do that, we can substitute the symbol `x` with a numerical value." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAsAAAArCAYAAACuAHIQAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABt0lEQVQ4Ee2U31HCQBDGE8cCwBKgAwY6gA6kBehAx6fkFTuILUgHUILYAZagdBC/33G7XhLCg2/OuDOb3fv2u73N/dm8rusMKctyJPMYBlk2lf1kLPw9YlkOORIr2YUF5G/kP0gX8vfgN3wkBNbBix8RWOUkfTXcyHMBRxEGFoiWjAPhlOiZAT8EkumSnJNQc58WRXGUKnzmWBmdbFplIpDlbYe8jA5ZAD+21aRnD9oSqdXSlXSXYvidMpRppUx3sr7nlrlBFuFegbHs0gjyRyhjJwvgh2ay/kNxAgk4+sZx7zQOx0ogkbkSjBnfRhAiS1FvW5oXqR3tG3vNfYQU/yf/ejdyXkI6+5ofWsE1Qhr7i4di9znTBec+WwujqTDeCPcHYY2RIAEjM5nnRDtYyt/K+hvkhawiARyxjE/n4Q+Zp0OfQ4NoovuGhZoVIMvQQGyySmX4xUMRkRYcerb8FyP7bgAoQO+AOJNS2pvUpfduaGJnN3rJpNOELxm2dSj/FGqWM0EhtMTKoDTf54P8gyaQpVfsB9nTPUu1mNM4Dgdk5HbnzDSRH2SltSXxHxRAXd6X5Xcu0jcTDtslOy9vbQAAAABJRU5ErkJggg==", "text/latex": [ "$\\displaystyle \\frac{2}{3}$" ], "text/plain": [ "2/3" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p.subs({'x':1})" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKsAAAAPCAYAAACbZT/hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADCElEQVRoBe2a0VEbMRCGzwwFQDoI6YCQChI6IEkFJB2ER/uNIR0kHSRQAh0wuIPQQYAOnP8T2hv5rOP8ouzMDjsjVlr90mp9v1fS4dlqtepe5OUT8PwEFovFgfx/UPmt+uPYWmYlWQW8yMC/0m9ULmS7GxtcsxdzWPcv2ZbWMO2Fw38k3xHi0fM4URyXxDIij8Ls71qnGreqn0tfYZPek7qVPlaZJKwwfDtweKb6tXQnTZsC8ZN44XAeyXeweN4pHjhT4xkZ94x4E1n1EL+oviediEqH6rCZ9g+VY2wTAinJoomoGQvhhwvwwrGkSL5DxSPebHBMNhJgJ514aZn1o2wbW7VsNyrfBIbIo2cJ9ZHGD1Xeq/Qi+9oCvHAsKJLvgPHAs5pwDIWbSXayJtXe53qpLCvS/5x8VSeZeJTQebAXDveRfIeKR7zpd/TMk0427k/n1kbvyshWPSWvJgBH6r/TXGTXzyp2QbuUrTwWeOFYfiTfEeMhpiTiDNv/oXQ6q2ZzxzHAiPhcVpwitPUflQ5Uf1A5VbFvjheOeCP5jhgPMZmQVe3NlNm62Xw+h8V/VL6XRAOhNpmStwQbffQjwkCCh1yfoU3Ux+Xsk8rrbPvvOK2B44nLGlv4bjHnts+mhW/mzP6TUhs+8hZqv7RT58xaO6sazrIu2/qU2Pm2xEF0iMIWbOKFw38k3xHjISbuFrXn1O0UzIZUQzFbdTDgYvzaN2Qw0YEXznONLXy3mHPbZ9PCN3MO5ETtagIlsyJcgki/Q7HMWl6Shhja9Buxa/1Gdi+c5xpb+G4x57bPpoVv5iTxwSF4WE18RlZelpdbtZpJ3urvsvjmZfOG4mxaIzvjOTMa2b1wLDiS74jxEJNxcDyzikw/BbyXJgUnUR2Wczk6fbI8MV/2lQpn0V7U5rZ/Ld3f4FSvjXfBsVCvNbbw3WLObT+fFr6ZMwucQaqZtf8hSyYXZAPIhYr/1/JbgaV0L2rz5gBichBeE9kYbw45QmyMZ4AXLprvaPGIF+zOJMLydSdhJvkHuSlvbR+xXkUAAAAASUVORK5CYII=", "text/latex": [ "$\\displaystyle 0.666666666666667$" ], "text/plain": [ "0.666666666666667" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p.subs({'x':1.0})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The result depends on whether we substitute with an integer or a float. You can substitute with a rational number like this" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAsAAAArCAYAAACuAHIQAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABVUlEQVQ4Ee2VzVHDQAxGMUMBmdCB0wE/HSQdQAvQATnaV+ggUAJ0YGqgg6QEhg7Me461bDCGWw6AZjTSSt9qZa1WLtq2PciprusT1o/wKfpb7jtygXGCeIBf4TO4hAcUYCNc6mXjDcLoAzocWL4x/IPz4uy3Gsf90dM8BfUiGolrtnmkOWyvvMAbuMF3j/wAu/iJ9vuBo9n8+jSKqqp2Z8FoLf7ADXbjywLQsyVi2RfDeefcW2K3rzvqmr8HrpCLcKDfojv3FujP2qORdFxrCALgKQ7MeEEJ7FNaA/A55WTECXZTTGCNG4xG+oq2QXywY0wrrG2H8EfOg2ic4kDPK5TSGIAx+GFPbLpLzjgilxy9gpvcpj5Ig0hXRJoiU80j8g4YwAWOGbL7GQlCL2X1BMbgB50j48r1Swbw6rfjq9/ZsO6uVUdGc/wz19FIAj3KfD9TaqR3ASGhkognHoYAAAAASUVORK5CYII=", "text/latex": [ "$\\displaystyle \\frac{1}{2}$" ], "text/plain": [ "1/2" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p.subs({'x':1//2})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For how to make python functions out of expressions, see below." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Compute roots\n", "\n", "Let us find roots of quadratic equation\n", "\n", "$$\n", "a x^2 + b x + c = 0\n", "$$" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAcwAAAA/CAYAAABtqviFAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAPIUlEQVR4Ae2d7bXUthaGh7MoAEgFFzrgowIOHQCpAOgAVv7xjxU6ACogoQOSCoB0kNwKwqWDc9/HY3nZHnv8MZZteV6t5bEsy/p4tOXtLcuaa1dXV7su9/r169uK87u2f+R/0h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/v+uDYZ0zKwXLOa/XLs++a8KgtTAsNEE5YJq0zyURg38vJHpOV3l9QVSzSbRYvQaQsKlnN2PQiYfQ9IG49iGViugc1+OfZDcl6NhZkrOV50swh1WCk+1OVSYdnEH+2xIguFqGOUKYo2WJcso+d3mYFcj714wdPse7DaahTLwHIta/bLsR+a82oUpgrOMCs37uLvj0qVKX+DyVDtBwnZS+35r7OP2rAw+aSEsLqyVZBdBwGz7wB0BqctA8s1stkvx35Qzgd/78XVUjxYG1huT+S3tQYUOxMwARMwgc0TOKb/LjZfe1fQBEzABEzABCYgYIU5AUQnYQImYAImsH0CVpjbb2PX0ARMwARMYAICbQozfMJxa4I8nIQJmIAJmIAJpEIgrEf+o17gNoXJwua4ppV29mf8awImYAImYALbI3A/r9LXetUaFaZmCYV1Wpkpa2cCJmACJmACmycg3cea5FiYrAfQ28IETFgogG8b7UzABEzABExg6wT4cw9cfbW5LLDRwuSMtCsXsGAACwKwko6dCZiACZiACWySgPQcyhJd91b+8mI5RX1bFWYe46H2rNv6TQlgqtqZgAmYgAmYwKYI5MqS0dT38jdal1S4caWfOgklEFb+eSF/eL9Zj+ZjEzABEzABE0iKgHQak1yxLDv1W5eFmVVcCbJ+6z1t9X8Jyc77xwRMwARMwAQSJcD64zf7GIP/ByUwhk9tUV91AAAAAElFTkSuQmCC", "text/latex": [ "$\\displaystyle \\left\\{ - \\frac{b}{2 a} - \\frac{\\sqrt{- 4 a c + b^{2}}}{2 a} : 1, \\ - \\frac{b}{2 a} + \\frac{\\sqrt{- 4 a c + b^{2}}}{2 a} : 1\\right\\}$" ], "text/plain": [ "⎧ _____________ _____________ ⎫\n", "⎪ ╱ 2 ╱ 2 ⎪\n", "⎨ b ╲╱ -4⋅a⋅c + b b ╲╱ -4⋅a⋅c + b ⎬\n", "⎪- ─── - ────────────────: 1, - ─── + ────────────────: 1⎪\n", "⎩ 2⋅a 2⋅a 2⋅a 2⋅a ⎭" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x, a, b, c = symbols('x a b c')\n", "eq = a*x**2 + b*x + c\n", "roots(eq,x)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAADkAAAAVCAYAAAD8dkbIAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAC2klEQVRYCdWY7W0UMRCG704UEEIHSQdAKiB0ECghdADi192/KHQQpYKI6yChA5IOkg4I18HxPCuvZXu99xFA2Rtp5PF4PDuvPR5bO14ul6OSZrPZHrq36pFvyvGh9YnxgJhew3fID2V8k1KB0Wd0P4L+Zzk+xH4AJrhz5GvYTYo0TneSwRNGvsMvkRfR6hkF4nCXvoQQzK5H++jvgi5r0F+jWNB+aAdetEJoj2gfMBgSwAvied/GiXyOfKsOrh0lwbtZkTrpGkeGIQjoUxoKwNxVN8GM24iGDvIYFPcAy84YOndwD72pvJaGDlIwq45PCb4KuDyTVaNUGVbPNLKa/YLn8An6b7RrCbt7jG5oszSsTcQmFo9i3OtixHi1+BS2o3InXRnzvUo4NX1uYaubLLAL2NK9dlWDjSnW3MG0WxM+BKiPtuKWPlz4/VQZQTLZiR9hg+5QCNDDLrj0wlVelVLRF/NcQK+nN1G5vWAMc3z0ZY6Z5XmNFXY8nU4FZ/o1q8NgrSyP0Av+lHZMG4m+6edH+1Y22v6tEGI4oI1XSs0n42bVJSymswkKd+IM9nXjLvWlnbucLUCw1ZEX8H8lvnXKB/ZpVwIMQXylbTdtPlHJRN98bSFwBTJiTOByCUbgzs/Aq/uXhH9T75A2FiJkd1QgGQVbn6bvkJu4GpCJldWqqVyJLhXTs6jeVW0qnM5rH00nP0XGp/Ec0ZbHQeCPFZ++2nzWLdqxja4QJ8CuSlw5+n7EANpd9Jnloe8lxs2G37CZs7b4YOP3LDReOWVBPEbXV3wy8BuB5COSqXKJY1PhFXwFu5NeH+rKIFDlhJ2LZTZ4/jchj4dAPY8lNRlUKmv9jUEaIA7imUic1XTJcC7i5zDX9Pe2se33Muo8BlbZ7uxYWXg6r4UdROa5j0XH+EuQndfCLoEkvQXotZbVh+zPgIAw9KBbrn3/XdFfWTGxeXYKMXvPG3sn5j+KyQfbDQFDbQAAAABJRU5ErkJggg==", "text/latex": [ "$\\displaystyle \\left\\{ a : 2\\right\\}$" ], "text/plain": [ "{a: 2}" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x, a = symbols('x a')\n", "eq = (x - a)**2\n", "roots(eq,x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Expand, factor, simplify" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHwAAAAVCAYAAACE5YosAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADvklEQVRoBe2Z203cQBSGDaIAQjqADkjoADqApAKgAyLeeIugA0IFUegAUgGEDkIHQdsB+T7LMxpP1uD17tobsUc6zPjsXP5znbFZeX5+Liahs7OzdcafVnM2q/YQ+WiSdZZj52eBl3y01mHbcxY8DvPoX9L/BW8F2bId3AKNPlrtAO0IJ+8m887pbyLbTmTL7rAWaPRRF4eb3ffD6rPc/RULNPpoZdIzPN+IzDbD92mXJT03zoI8pz7qcoZHNaoyvo/gQxT23AGDF8cv1bYfaZ98Rv5Qyd50k/uoc4ZXhvbCdkB/kBt6wEC7F7xK34pzAu/Rvw3yt9gG+6B79FGnDK8WMotKQ1fPBe1jz4bVufGNwb3BIK4juj/gd8oWgcDkRdfL7bc+8LBPWfloaz6a+NJWLWRmX9LflulbUi2lfZNG/A0Gvw2kZGavV1hT+ZB9MeY454Kn0nusj7pkuO/cAreNxCa1TIs/zLejYw26UcM2vRi4Ye8hxY0+qjm8igzLpKX5D3wNewO/oC2J/iKVyYOAK2vLbwJgrV3c2ujnOowzUDwWpB34ELZEfoalO8Zom95oEkyMbfRRLOkMsjwaGZ6Bsk62LPjV5r/JFLDq7PL8oo2EfBL91PlCZoE7+Are5dmjS1uYFH3TTDCVGY4iKuElR0enFy/7j8hGfWs3xX7qcQ3mtCq11o95ZnbqUHX31dMslzbg9PdSOM8/s8QUSroKeMnJb5BmxUxKF2tr9J/uA7clXydqZfmliYy1IhmgeamfRL975qdB7zeGB2Q6vhiztuJI/C4G7ZaTgeL8cXcd188xp/OnwpQuFBz+CWHtnRUAOsbSeJNO6NpnPQ02tw80rG9mbtCWryEZztb6MT8PMOd+zdZrfGT+OIcWyK0SvpbFytO4SPYDc6bClC63xmI6Vs4dq6IFv9cCQdmiERg15hZtzBL6Bqv0BHfSjzXMVOfGKofM54J2ZNs3TYspZLi40zLms5lSRhabaFDLTj7GcYMSmLyk7dCGz6sBj5jTIyrH/o9+jDc4vAN4QTLQzdZRpvfpmL0YNh9iLwNsZpjMcBVSuZARBc8aS0OG7PYzZYxy5AtBYBKzxril79mZ0i6ysnzSttKPceptVnt51dAGQCRk/nYXBf103HNmmNYqzJbCKxQ6oX0Pf4fNACNdWW5MRAtBHkM6Pbwzp6DK6lQJ2upnYFgVNHCB7sfwDaz+vrI+0e878GeKqfM/TzTIktpbgECxenS6tLXf5fWRq68PWY6YkQW85A1y0Uvx/wVZN8hkr8ewcQAAAABJRU5ErkJggg==", "text/latex": [ "$\\displaystyle a^{2} - 2 a x + x^{2}$" ], "text/plain": [ " 2 2\n", "a - 2⋅a⋅x + x " ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x, a = symbols('x a')\n", "expand((x-a)**2)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFYAAAAaCAYAAAAtzKvgAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADkUlEQVRoBe2Y0VEbMRCGD08K8CQdQAcmVBDoAJIKwB3Yw5P9loEOgAoyoQNCBTh0EDoIuQ6c/5Olsyzf+eSDOxvmdma90molrX6tVjrvTKfTpKVqCIzH4656ntveu1aeSp9+qDZk28sicCEQ+w4N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aLGAAAAABJRU5ErkJggg==", "text/latex": [ "$\\displaystyle \\left(- a + x\\right)^{2}$" ], "text/plain": [ " 2\n", "(-a + x) " ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "factor(x**2 - 2*a*x + a**2)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAC4AAAAQCAYAAABpyU3qAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABfklEQVRIDc2W7U3DMBCGU5QBKtigI1DYoCPwMQF0AxD/+g+VDYARygZlg0JHYISqG5TnMY5lKoqQSJqc9ObO58T3+nLnpLfZbIquy2QyOYbjDAyx1/ItvXRRINiH1zNYgRMwAEkaJU7wEZEG6KcU8Y9GzOy5t2PfoMx6koNkNWOYNVG7NE28dsLVgqlUeB1m5jpOnKKvgHV1GX0L7nmJdusqz/gUYg8CVgtgY4wY36Ld1BR0RkLGIWemc2JrxmfArCuHIJ8PzjYvVam8Qf4jIzLEXuJzAwU6dHc2/81k/hGHJ8i2uGGfH29PMHb9X9f94ZnkqjK+TJ4v4wJ1v+XbOdxBTMK+NY9Dy69WyWs8LEwQM2dNp0bE1xe1Rv7nYmUk5OfU5nxF+1rX2Hnp3DG2STsjZtwMi1XchJ/YJPic85RpU45i8NAz2iUwy36SJVhAdAzmwIZ7B24olY337EuIayUogRt6hs9KmPea/DskyP6a0+3VKB6n4Uitcc2w1Cfm03LmS5W2QQAAAABJRU5ErkJggg==", "text/latex": [ "$\\displaystyle x + 1$" ], "text/plain": [ "x + 1" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f = (x + x**2)/(x*sin(x)**2 + x*cos(x)**2)\n", "simplify(f)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get Latex code" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgEAAAAYCAYAAAB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IO54uDnwLRo+aN2fD5mpZ8tbPbKqrA4Cf3Mjb/Gz6Z7XYSaGx8fj+KLtTpmDV017kmdAJ+Q5pQvhWFhb/12wxA+1R8GACen4Vh07StWgbuOc0r15iajKbFb89ynxNk3VsHfh8wuf474iKcoJyA843mUjon7Zh5TnJQLdvycLqQi8/3wiM7YTdodZUQ3i2o6NxlNCe6a5z4lzr6xCv4+ZHb5c8RnDWvoaLiv7iQAPZZXxXt0ju/rI96dfvf7q/b2GJjj9UIJEVizjNY894QqNLirgn8YuoJPGJ+xSsfCfY0nAciId5T88EQs0UfKU4VYfpbUfs0yWvPc56DDBf+wFAo+YXzGKh0F91WeBCAheVXs4vnaV+8f6ana878FGhfGyC+UDoE1y2jNc0+nQcN7KviHsSv4hPEZq3QM3P8HBEq5qKFHPHAAAAAASUVORK5CYII=", "text/latex": [ "$\\displaystyle - \\sin^{3}{\\left(x \\right)} + 3 \\sin^{2}{\\left(x \\right)} \\cos{\\left(x \\right)} - 3 \\sin{\\left(x \\right)} \\cos^{2}{\\left(x \\right)} + \\cos^{3}{\\left(x \\right)}$" ], "text/plain": [ " 3 2 2 3 \n", "- sin (x) + 3⋅sin (x)⋅cos(x) - 3⋅sin(x)⋅cos (x) + cos (x)" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = symbols('x')\n", "p = (cos(x)-sin(x))**3\n", "expand(p)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "- \\sin^{3}{\\left(x \\right)} + 3 \\sin^{2}{\\left(x \\right)} \\cos{\\left(x \\right)} - 3 \\sin{\\left(x \\right)} \\cos^{2}{\\left(x \\right)} + \\cos^{3}{\\left(x \\right)}\n" ] } ], "source": [ "print_latex(expand(p))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Solve a linear system\n", "\n", "$$\n", "x_1 + x_2 = a, \\qquad x_1 - x_2 = b\n", "$$" ] }, { "cell_type": "code", "execution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CnjkdxcpVvJbRtJHhizDYERCEiX2ChiBN34ner/AXrVYSShwZMvAAAAAElFTkSuQmCC", "text/latex": [ "$\\displaystyle \\left\\{ x_{1} : \\frac{a}{2} + \\frac{b}{2}, \\ x_{2} : \\frac{a}{2} - \\frac{b}{2}\\right\\}$" ], "text/plain": [ "⎧ a b a b⎫\n", "⎨x₁: ─ + ─, x₂: ─ - ─⎬\n", "⎩ 2 2 2 2⎭" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x1, x2, a, b = symbols('x1 x2 a b')\n", "e1 = x1 + x2 - a\n", "e2 = x1 - x2 - b\n", "solve([e1, e2],[x1,x2])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can capture the result as a dictionary." ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x1 = a/2 + b/2\n", "x2 = a/2 - b/2\n" ] } ], "source": [ "r = solve([e1, e2],[x1,x2])\n", "print('x1 = ', r[x1])\n", "print('x2 = ', r[x2])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example: create Python function from sympy expression\n", "\n", "Lets first define a function and get its derivative." ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "x = symbols('x')\n", "f = x * sin(50*x) * exp(x)\n", "g = diff(f,x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We cannot evaluate `f` and `g` since they are not python functions. We first create Python functions out of the symbolic expressions and then plot them." ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "ffun = lambdify(x,f)\n", "gfun = lambdify(x,g)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can now evaluate these functions at some argument" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "f(1) = -0.7132087970679899\n", "g(1) = 129.72606342238427\n" ] } ], "source": [ "print('f(1) =',ffun(1.0))\n", "print('g(1) =',gfun(1.0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can now use these to plot graphs of the functions" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 2024-12-13T09:11:54.014126\n", " image/svg+xml\n", " \n", " \n", " Matplotlib v3.9.2, https://matplotlib.org/\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "xx = np.linspace(0.0,1.0,200)\n", "plt.figure(figsize=(9,4))\n", "plt.subplot(121)\n", "plt.plot(xx,ffun(xx))\n", "plt.grid(True)\n", "plt.title('f(x) = '+str(f))\n", "plt.subplot(122)\n", "plt.plot(xx,gfun(xx))\n", "plt.grid(True)\n", "plt.title('Derivative of f(x)');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example: Truncation error of FD scheme\n", "\n", "Approximate second derivative using finite difference scheme\n", "\n", "$$\n", "f''(x) \\approx \\frac{f(x-h) - 2 f(x) + f(x+h)}{h^2}\n", "$$\n", "\n", "We perform Taylor expansion around $x$ to find the error in this approximation: write\n", "\n", "$$\n", "f(x \\pm h) = f(x) \\pm h f'(x) + \\frac{h^2}{2} f''(x) \\pm \\ldots\n", "$$\n", "\n", "and simplify the rhs. This can be done by sympy." ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAABKCAYAAAC2AC4VAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAfI0lEQVR4Ae2dTbLcthWF2yqNMpKfd2D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db2LlOq2LrqHAvP/e+UHAeorLPlM7a/9FpXPw4n8xwl9YnKt1Kvd5LAvcuYfch3Csa01LXYxq7xwICH+IC4JVD/3A2sk94TP4wTIjn037XZMInkNmuhYjcDYEpHPoa14q1TH6Sd/e6v8VRp+DbiMQ+JcKC6sBIUQ/Ouc68W7k2FT8SK4VT2EWIzAZgVF/ttnMXcrJAPpUDisPCsprgCzBcJxF53snOHQCDFbNT+5njPoOhB8m366BrpqUNxnS4Mi9YcMfb90kKwAEC2JKBwIxtRgBI2AEjIAR2DQC1T04oxuqQZJNxq/kM/iy9BLe9JBfZfg63bcIH0gGhOI/8iEg4FXbfxMxhMjwPYkmQSy+26+4fcJad7LSPFDEZFqm3Nosqi8TXzMCRsAIGAEjcMkITCI4qcFxIMVyg5XC5CYBE33hAqGBbIANxyxDZBKjYyxghONOIsozWHJiZpiVA0lSuMnNSRB2JkbACBgBI3AJCEwmOBowGZTTJjHWT6dYGy4Bozl1ZI9S5/dLIulgTwVr0S1R+NFLVCkTpQ3Lh/KDNUc+rxcny06KZt8IGAEjYASMwCYRmENwGCyL38NhMNU1CA8WBAZWBvD38ovxdW1zorZC/mZZTZTHUaRR8cGd71XwP2DskaoSGt6EOCo/xbcYASNgBIyAEbhIBCYTnL7WaoBlYGVA3Zv8qdJgyA2bfwnCklMlG4SdXChD7o0cG43D3pt4TFl7vB8nx9gZGgEjYASMwGUgMOktqsto2t3XUuSCZaIXclhzIDgQnZYVS2HsYeJf3PP+HJ1bjIARMAJGwAgYgYkImOBMBO7YZCIv4ZV5pePDWOHbEfIhQCzjQYLYHPxWYX6NW0BYjIARMAJGwAjMQcAEZw56I9OKtKT/ocJK430wI3FzNCNgBIyAETACUxH4PyuzZ5CB0GtKAAAAAElFTkSuQmCC", "text/latex": [ "$\\displaystyle \\left. \\frac{d^{2}}{d \\xi_{1}^{2}} f{\\left(\\xi_{1} \\right)} \\right|_{\\substack{ \\xi_{1}=x }} + \\frac{h^{2} \\left. \\frac{d^{4}}{d \\xi_{1}^{4}} f{\\left(\\xi_{1} \\right)} \\right|_{\\substack{ \\xi_{1}=x }}}{12} + \\frac{h^{4} \\left. \\frac{d^{6}}{d \\xi_{1}^{6}} f{\\left(\\xi_{1} \\right)} \\right|_{\\substack{ \\xi_{1}=x }}}{360} + O\\left(h^{6}\\right)$" ], "text/plain": [ " ⎛ 4 ⎞│ ⎛ 6 ⎞│ \n", " 2 ⎜ d ⎟│ 4 ⎜ d ⎟│ \n", " h ⋅⎜────(f(ξ₁))⎟│ h ⋅⎜────(f(ξ₁))⎟│ \n", "⎛ 2 ⎞│ ⎜ 4 ⎟│ ⎜ 6 ⎟│ \n", "⎜ d ⎟│ ⎝dξ₁ ⎠│ξ₁=x ⎝dξ₁ ⎠│ξ₁=x ⎛ 6⎞\n", "⎜────(f(ξ₁))⎟│ + ───────────────────── + ───────────────────── + O⎝h ⎠\n", "⎜ 2 ⎟│ 12 360 \n", "⎝dξ₁ ⎠│ξ₁=x " ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x, h = symbols(\"x,h\")\n", "f = Function(\"f\")\n", "T = lambda h: (f(x-h) - 2*f(x) + f(x+h))/(h**2)\n", "series(T(h), h, x0=0, n=6)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The above result shows that the FD formula is equal to\n", "\n", "$$\n", "\\frac{f(x-h) - 2 f(x) + f(x+h)}{h^2} = f''(x) + \\frac{h^2}{12} f^{(4)}(x) + \\frac{h^4}{360} f^{(6)}(x) + O(h^6)\n", "$$\n", "\n", "The leading error term is $O(h^2)$ \n", "\n", "$$\n", "\\textrm{error} = \\frac{f(x-h) - 2 f(x) + f(x+h)}{h^2} - f''(x) = \\frac{h^2}{12} f^{(4)}(x) + \\frac{h^4}{360} f^{(6)}(x) + O(h^6) = O(h^2)\n", "$$\n", "\n", "so that the formula is second order accurate." ] } ], "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.12.8" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }