# Diving into symbolic computing with SymPy


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


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


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


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


```
expr1 == expr2
```




    False




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


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


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


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


```
_.evalf()
```


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


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




    array([ 1.,  0.,  1.,  4.,  9.])



b9e266fea6338a8a69665c576ee806e5376fadb2
ipynb
Jupyter Notebook
Chapter15/01_sympy_intro.ipynb
PacktPublishing/IPython-Interactive-Computing-and-Visualization-Cookbook-Second-Edition
7c41466113641abf7070f7bd14cc687c19c9c1ea
MIT
2018-03-06T19:38:30.000Z
2022-02-25T06:54:38.000Z
Chapter15/01_sympy_intro.ipynb
PacktPublishing/IPython-Interactive-Computing-and-Visualization-Cookbook-Second-Edition
7c41466113641abf7070f7bd14cc687c19c9c1ea
MIT
Chapter15/01_sympy_intro.ipynb
PacktPublishing/IPython-Interactive-Computing-and-Visualization-Cookbook-Second-Edition
7c41466113641abf7070f7bd14cc687c19c9c1ea
MIT
2018-02-19T16:11:16.000Z
2022-02-25T06:54:40.000Z
Qwen/Qwen-72B
1. YES
2. YES