# 15.1. Diving into symbolic computing with SymPy


```python
from sympy import *
init_printing()
```


```python
var('x y')
```


```python
x, y = symbols('x y')
```


```python
expr1 = (x + 1) ** 2
expr2 = x**2 + 2 * x + 1
```


```python
expr1 == expr2
```


```python
simplify(expr1 - expr2)
```


```python
expr1.subs(x, expr1)
```


```python
expr1.subs(x, pi)
```


```python
expr1.subs(x, S(1) / 2)
```


```python
_.evalf()
```


```python
f = lambdify(x, expr1)
```


```python
import numpy as np
f(np.linspace(-2., 2., 5))
```

ipynb
8b8f38e4567fe41e9036965301135ad7816de2a1
Jupyter Notebook
2022-01-13T18:49:12.000Z
2022-01-13T18:49:12.000Z
bcd08ced04db00e7a66473b146f8f31f2e657539
BSD-3-Clause
jhgoebbert/jupyter-jsc-notebooks
001-Jupyter/001-Tutorials/002-IPython-Cookbook/chapter15_symbolic/01_sympy_intro.ipynb
bcd08ced04db00e7a66473b146f8f31f2e657539
BSD-3-Clause
jhgoebbert/jupyter-jsc-notebooks
001-Jupyter/001-Tutorials/002-IPython-Cookbook/chapter15_symbolic/01_sympy_intro.ipynb
bcd08ced04db00e7a66473b146f8f31f2e657539
BSD-3-Clause
jhgoebbert/jupyter-jsc-notebooks
001-Jupyter/001-Tutorials/002-IPython-Cookbook/chapter15_symbolic/01_sympy_intro.ipynb