##// END OF EJS Templates
Backport PR #5488: Added missing require and jquery from cdn....
Backport PR #5488: Added missing require and jquery from cdn. For some reason (I suppose some changes at the css level) the font size inside the input cells was fixed at 14 px... making the fonts really small in the reveal slideshows. This is really annoying... As a plus, I have also added the missing calls for require and jquery (as the full html template does). I think these fixes belong to 2.0, but I also know we are on the edge... so I hope to get it inside :wink: Cheers.

File last commit:

r16120:24b93a1d
r16230:ba262623
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)
$$x^{12} - 1 = \left(x - 1\right) \left(x + 1\right) \left(x^{2} + 1\right) \left(x^{2} - x + 1\right) \left(x^{2} + x + 1\right) \left(x^{4} - x^{2} + 1\right)$$
In [6]:
interact(factorit, n=(2,40));
$$x^{21} - 1 = \left(x - 1\right) \left(x^{2} + x + 1\right) \left(x^{6} + x^{5} + x^{4} + x^{3} + x^{2} + x + 1\right) \left(x^{12} - x^{11} + x^{9} - x^{8} + x^{6} - x^{4} + x^{3} - x + 1\right)$$
In [ ]: