# Factoring Polynomials with SymPy

Here is an example that uses [SymPy](http://sympy.org/en/index.html) to factor polynomials.


```python
from ipywidgets import interact
```


```python
from sympy import Symbol, Eq, factor
```


```python
x = Symbol('x')
```


```python
def factorit(n):
    return Eq(x**n-1, factor(x**n-1))
```


```python
factorit(12)
```




    Eq(x**12 - 1, (x - 1)*(x + 1)*(x**2 + 1)*(x**2 - x + 1)*(x**2 + x + 1)*(x**4 - x**2 + 1))




```python
interact(factorit, n=(2,40));
```


    interactive(children=(IntSlider(value=21, description='n', max=40, min=2), Output()), _dom_classes=('widget-in…



```python

```

aa4f911c833b559630de400d1d8203398fb5b090
ipynb
Jupyter Notebook
docs/source/examples/Factoring.ipynb
nthiery/ipywidgets
463cb0444d1a2f31c3d5cacfe6b38d067f231406
BSD-3-Clause
2019-06-27T08:22:43.000Z
2019-06-27T08:22:43.000Z
docs/source/examples/Factoring.ipynb
miklobit/ipywidgets
092c085aaf3b1165a5c8f24a9ce663ae523e7969
BSD-3-Clause
2019-02-07T18:19:36.000Z
2021-07-29T08:37:12.000Z
docs/source/examples/Factoring.ipynb
miklobit/ipywidgets
092c085aaf3b1165a5c8f24a9ce663ae523e7969
BSD-3-Clause
2021-04-08T11:30:13.000Z
2021-04-08T11:30:13.000Z
Qwen/Qwen-72B
1. YES
2. YES