Factoring Polynomials with SymPyΒΆ
Here is an example that uses SymPy to factor polynomials.
In [1]:
from ipywidgets import interact
In [2]:
from sympy import Symbol, Eq, factor
In [3]:
x = Symbol('x')
In [4]:
def factorit(n):
return Eq(x**n-1, factor(x**n-1))
In [5]:
factorit(12)
Out[5]:
Eq(x**12 - 1, (x - 1)*(x + 1)*(x**2 + 1)*(x**2 - x + 1)*(x**2 + x + 1)*(x**4 - x**2 + 1))
In [6]:
interact(factorit, n=(2,40));