|
4 | 4 | "cell_type": "markdown", |
5 | 5 | "metadata": {}, |
6 | 6 | "source": [ |
7 | | - "# Using a Maclauren Series to Estimate $e$\n", |
| 7 | + "# Using a Maclaurin Series to Estimate $e$\n", |
8 | 8 | "\n", |
9 | | - "A [Maclauren series](https://mathworld.wolfram.com/MaclaurinSeries.html) is an infinite series of terms that can be used to approximate more complex functions quickly.\n", |
| 9 | + "A [Maclaurin series](https://mathworld.wolfram.com/MaclaurinSeries.html) is an infinite series of terms that can be used to approximate more complex functions quickly.\n", |
10 | 10 | "\n", |
11 | 11 | "You're going to approximate $e^x$ by using the first few terms of the series. The series equation for $e^x$ is this:\n", |
12 | 12 | "\n", |
|
39 | 39 | "outputs": [], |
40 | 40 | "source": [ |
41 | 41 | "def e_x(x, terms=10):\n", |
42 | | - " \"\"\"Approximates $e^x$ using 'terms' terms of the Maclauren series\"\"\"\n", |
| 42 | + " \"\"\"Approximates $e^x$ using a given number of terms of the Maclaurin series\"\"\"\n", |
43 | 43 | " n = np.arange(terms)\n", |
44 | 44 | " return np.sum((x ** n) / fac(n))" |
45 | 45 | ] |
|
74 | 74 | "name": "stdout", |
75 | 75 | "output_type": "stream", |
76 | 76 | "text": [ |
77 | | - "N (terms)\tMaclauren\tError\n", |
| 77 | + "N (terms)\tMaclaurin\tError\n", |
78 | 78 | "1\t\t1.000\t\t19.086\n", |
79 | 79 | "2\t\t4.000\t\t16.086\n", |
80 | 80 | "3\t\t8.500\t\t11.586\n", |
|
92 | 92 | } |
93 | 93 | ], |
94 | 94 | "source": [ |
95 | | - "print(\"N (terms)\\tMaclauren\\tError\")\n", |
| 95 | + "print(\"N (terms)\\tMaclaurin\\tError\")\n", |
96 | 96 | "\n", |
97 | 97 | "for n in range(1, 14):\n", |
98 | | - " maclauren = e_x(3, terms=n)\n", |
99 | | - " print(f\"{n}\\t\\t{maclauren:.03f}\\t\\t{e**3 - maclauren:.03f}\")" |
| 98 | + " maclaurin = e_x(3, terms=n)\n", |
| 99 | + " print(f\"{n}\\t\\t{maclaurin:.03f}\\t\\t{e**3 - maclaurin:.03f}\")" |
100 | 100 | ] |
101 | 101 | }, |
102 | 102 | { |
|
0 commit comments