```python
# symbols and expressions
from sympy import *
init_printing(use_unicode=True)
```


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


```python
f = Function('f')
```


```python
f = x**2 + y**2 + z**2
```


```python
print(f)
```

    x**2 + y**2 + z**2



```python
pprint(f)
```

     2    2    2
    x  + y  + z 



```python
f = x**2 - 3*x + 2
```


```python
pprint(f)
```

     2          
    x  - 3⋅x + 2



```python
# evaluate f for a particular value of x, say x=1.0
pprint(f.subs(x,1.0))
```

    0



```python
pprint(f.subs(x,3.0))
```

    2.00000000000000



```python
f = (x**2 - 3*x + 2)/(x**2-x)
```


```python
pprint(f)
```

     2          
    x  - 3⋅x + 2
    ────────────
        2       
       x  - x   



```python
# simplify expressions
simplify(f)
```


```python
# expand an expression
f = (x+2)**3*(x-3)**2
```


```python
pprint(f)
```

           2        3
    (x - 3) ⋅(x + 2) 



```python
expand(f)
```


```python
# finding roots
f = x**2 - 3*x + 2
```


```python
solve(f,x)
```


```python
g = (x+2)**3*(x-3)**2
```


```python
solve(g,x)
```


```python
f = x**2 + x + 1
```


```python
y=solve(f,x)
```


```python
pprint(y)
```

    ⎡  1   √3⋅ⅈ    1   √3⋅ⅈ⎤
    ⎢- ─ - ────, - ─ + ────⎥
    ⎣  2    2      2    2  ⎦



```python
# show the values are numerals
y[0].evalf()
```


```python
y[1].evalf()
```


```python
for z in y:
    pprint(z.evalf())
```

    -0.5 - 0.866025403784439⋅ⅈ
    -0.5 + 0.866025403784439⋅ⅈ



```python
# solution of a set of equations
x,y,z = symbols('x y z')
```


```python
eq1 = Eq(x+y+z,0)
```


```python
print(eq1)
```

    Eq(x + y + z, 0)



```python
eq2 = Eq(2*x-y-z,10)
eq3 = Eq(y+2*z,5)
```


```python
solve([eq1, eq2, eq3],[x,y,z])
```

27af484066d84d3bb61cb0c26682022490a9671a
ipynb
Jupyter Notebook
3-polynomials.ipynb
chennachaos/SA2CTechChatSymPy
9f1dbb48655ff5f8bdd6b4ced48b58aed0ba5bf4
MIT
3-polynomials.ipynb
chennachaos/SA2CTechChatSymPy
9f1dbb48655ff5f8bdd6b4ced48b58aed0ba5bf4
MIT
3-polynomials.ipynb
chennachaos/SA2CTechChatSymPy
9f1dbb48655ff5f8bdd6b4ced48b58aed0ba5bf4
MIT
Qwen/Qwen-72B
1. YES
2. YES