##// END OF EJS Templates
Added bootstrap3 progress bar classes
r17729:a4156457
Show More
Factoring.ipynb
140 lines | 3.6 KiB | text/plain | TextLexer

Factoring Polynomials with SymPy

Here is an example that uses SymPy to factor polynomials.

In [1]:
from IPython.html.widgets import interact
from IPython.display import display
In [2]:
from sympy import Symbol, Eq, factor, init_printing
init_printing(use_latex='mathjax')
In [3]:
x = Symbol('x')
In [4]:
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 [5]:
factorit(12)
x121=(x1)(x+1)(x2+1)(x2x+1)(x2+x+1)(x4x2+1)
In [6]:
interact(factorit, n=(2,40));
x211=(x1)(x2+x+1)(x6+x5+x4+x3+x2+x+1)(x12x11+x9x8+x6x4+x3x+1)
In [ ]: