```python
import numpy as np
from sympy import *
init_printing(use_latex='mathjax')
```


```python
x, h = symbols("x h")
f = Function("f")
f(x).series(x, x0=h, n=3)
```




$$f{\left (h \right )} + \left(- h + x\right) \left. \frac{d}{d \xi_{1}} f{\left (\xi_{1} \right )} \right|_{\substack{ \xi_{1}=h }} + \frac{1}{2} \left(- h + x\right)^{2} \left. \frac{d^{2}}{d \xi_{1}^{2}}  f{\left (\xi_{1} \right )} \right|_{\substack{ \xi_{1}=h }} + \mathcal{O}\left(\left(- h + x\right)^{3}; x\rightarrow h\right)$$




```python
x = symbols('x')
f = exp(x ** 2)
series(f, x, n = 12)
```




$$1 + x^{2} + \frac{x^{4}}{2} + \frac{x^{6}}{6} + \frac{x^{8}}{24} + \frac{x^{10}}{120} + \mathcal{O}\left(x^{12}\right)$$




```python
x,p = symbols('x p')
f = 1 / x
t = series(f, x, x0=p, n = 5)
t.subs({p:4})
```




$$\frac{1}{2} + \frac{1}{64} \left(x - 4\right)^{2} - \frac{1}{256} \left(x - 4\right)^{3} + \frac{1}{1024} \left(x - 4\right)^{4} - \frac{x}{16} + \mathcal{O}\left(\left(x - 4\right)^{5}; x\rightarrow 4\right)$$




```python
x,p = symbols('x p')
f = ln(x)
t = series(f, x, x0=p, n = 2)
t.subs({p:10})
```




$$\log{\left (10 \right )} - 1 + \frac{x}{10} + \mathcal{O}\left(\left(x - 10\right)^{2}; x\rightarrow 10\right)$$




```python
x,p = symbols('x p')
f = 1 / ((1 - x) ** 2 )
t = series(f, x, x0=p, n = 4)
t.subs({p:0})
```




$$1 + 2 x + 3 x^{2} + 4 x^{3} + \mathcal{O}\left(x^{4}\right)$$




```python
x,p = symbols('x p')
f = sqrt(4 - x)
t = series(f, x, x0=p, n = 4).removeO()
t.subs({p:0})
```




$$- \frac{x^{3}}{512} - \frac{x^{2}}{64} - \frac{x}{4} + 2$$




```python
x,y, dx, dy = symbols('x y dx dy')
f = x * (y ** 2 ) * exp(- (x ** 4 ) - ((y ** 2) / 2))

e = f.series(x, x0=dx, n=1).removeO().series(y, x0=dx, n=1).removeO()
simplify(e)
```




$$dx^{3} e^{- dx^{4} - \frac{dx^{2}}{2}}$$




```python
x = symbols('x')
f = exp(x) + x + sin(x)
f.series(x, x0=0, n=6).removeO()
```




$$\frac{x^{5}}{60} + \frac{x^{4}}{24} + \frac{x^{2}}{2} + 3 x + 1$$




```python
x = symbols('x')
f = 2 / (x ** 2 - x)
f.series(x, x0=0.5, n=6).removeO()
```




$$- 128.0 \left(x - 0.5\right)^{4} - 32.0 \left(x - 0.5\right)^{2} - 8.0$$




```python
x = symbols('x')
f = exp(-2 * x)
f.series(x, x0=2, n=2)
```




$$e^{-4} - \frac{2}{e^{4}} \left(x - 2\right) + \mathcal{O}\left(\left(x - 2\right)^{2}; x\rightarrow 2\right)$$




```python

```

135ef65e308222649d3b63b3a10ff5dfb1a1a7d8
ipynb
Jupyter Notebook
Certification 2/Week4.1 - Taylor series.ipynb
The-Brains/MathForMachineLearning
5cbd9006f166059efaa2f312b741e64ce584aa1f
MIT
2018-04-16T02:53:59.000Z
2021-05-16T06:51:57.000Z
Certification 2/Week4.1 - Taylor series.ipynb
The-Brains/MathForMachineLearning
5cbd9006f166059efaa2f312b741e64ce584aa1f
MIT
Certification 2/Week4.1 - Taylor series.ipynb
The-Brains/MathForMachineLearning
5cbd9006f166059efaa2f312b741e64ce584aa1f
MIT
2019-05-20T02:06:55.000Z
2020-05-18T06:21:41.000Z
Qwen/Qwen-72B
1. YES
2. YES