For more information and examples, see:
Using widgets requires IPython 2.0, see http://ipython.org/install.html for installation advice.
(Not available on SageMathCloud yet.)
In [1]:
%pylab inline
In [2]:
from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display
In [3]:
def plot_sine(k):
x = linspace(-2,2,1000)
plot(x,sin(2*pi*k*x))
For one particular $k$:
In [4]:
plot_sine(2)
Make it interactive with a slider bar for $k$ between 0 and 5 by steps of 0.1:
In [5]:
w = interactive(plot_sine, k=(0,5,0.1))
display(w)
In [6]:
import sympy as S
S.init_printing()
x = S.symbols('x')
In [7]:
def expand_power(n):
f = (x + 1)**n
f2 = S.expand(f)
display(f2)
In [8]:
expand_power(3)
In [9]:
w = interactive(expand_power, n=(1,10,1))
display(w)