Jupyter

This notebook on nbviewer

Notebook with code and prose

Here is an example that uses SymPy to factor polynomials.

In [12]:
from ipywidgets import interact
from sympy import Symbol, Eq, factor
from sympy.interactive import init_printing
init_printing(use_latex='mathjax')
In [13]:
x = Symbol('x')
x
Out[13]:
$$x$$
In [14]:
@interact
def factorit(n=12):
    return Eq(x**n-1, factor(x**n-1))
$$x^{22} - 1 = \left(x - 1\right) \left(x + 1\right) \left(x^{10} - x^{9} + x^{8} - x^{7} + x^{6} - x^{5} + x^{4} - x^{3} + x^{2} - x + 1\right) \left(x^{10} + x^{9} + x^{8} + x^{7} + x^{6} + x^{5} + x^{4} + x^{3} + x^{2} + x + 1\right)$$

Plotting

Inline plotting with matplotlib

In [15]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

We want to plot:

\begin{equation} y = sin(\omega t) \end{equation}
In [16]:
def plot_sinωt(ω=3, T=5):
    t = np.linspace(0, T, 1000)
    y = np.sin(ω * t)
    plt.plot(t, y)
    plt.title(r"$\omega = %s$" % ω)

plot_sinωt(5, 5)
# interact(plot_sinωt)

Interactive graphics with Bokeh

In [17]:
import time
from bokeh.io import output_notebook, show
from bokeh.charts import Scatter
from bokeh.sampledata.iris import flowers

output_notebook()