Merge pull request #8778 from SylvainCorlay/Meta...
Merge pull request #8778 from SylvainCorlay/Meta Use isinstance to check for types

File last commit:

r21631:3ac9be53 merge
Show More
115 lines | 2.1 KiB | text/plain | TextLexer

Factoring Polynomials with SymPy

Here is an example that uses SymPy to factor polynomials.

In [ ]:
from IPython.html.widgets import interact
from IPython.display import display
In [ ]:
from sympy import Symbol, Eq, factor, init_printing
In [ ]:
x = Symbol('x')
In [ ]:
def factorit(n):
    display(Eq(x**n-1, factor(x**n-1)))

Notice how the output of the factorit function is properly formatted LaTeX.

In [ ]:
In [ ]:
interact(factorit, n=(2,40));