Skip to content

Commit

Permalink
Fixed terms in Taylor series rlabbe#307
Browse files Browse the repository at this point in the history
  • Loading branch information
rlabbe committed May 4, 2020
1 parent 3b6d8b6 commit 23b0c37
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Supporting_Notebooks/Taylor-Series.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [
{
Expand All @@ -25,7 +25,7 @@
"<IPython.core.display.HTML object>"
]
},
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -66,21 +66,21 @@
"\n",
"Now we can substitute these values into the equation.\n",
"\n",
"$$\\sin(x) = \\frac{0}{0!}(x)^0 + \\frac{1}{1!}(x)^1 + \\frac{0}{2!}(x)^2 + \\frac{-1}{3!}(x)^3 + \\frac{0}{4!}(x)^4 + \\frac{-1}{5!}(x)^5 + ... $$\n",
"$$\\sin(x) = \\frac{0}{0!}(x)^0 + \\frac{1}{1!}(x)^1 + \\frac{0}{2!}(x)^2 + \\frac{-1}{3!}(x)^3 + \\frac{0}{4!}(x)^4 + \\frac{1}{5!}(x)^5 + ... $$\n",
"\n",
"And let's test this with some code:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"estimate of sin(.3) is 0.30452025\n",
"estimate of sin(.3) is 0.29552025\n",
"exact value of sin(.3) is 0.29552020666133955\n"
]
}
Expand All @@ -89,7 +89,7 @@
"import numpy as np\n",
"\n",
"x = .3\n",
"estimate = x + x**3/6 + x**5/120\n",
"estimate = x - x**3/6 + x**5/120\n",
"exact = np.sin(.3)\n",
"\n",
"print('estimate of sin(.3) is', estimate)\n",
Expand Down Expand Up @@ -120,7 +120,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.6"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 23b0c37

Please sign in to comment.