#https://blog.dominodatalab.com/interactive-dashboards-in-jupyter/
#http://jupyter.cloudet.xyz/
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets
def f(x):
print(x)
interact(f,x=10)
27
interact(f,x=(0,100,5)) # (start, stop, stepsize)
75
outputText=widgets.Text()
outputText
inputText=widgets.Text()
def makeUpper(dummy):
outputText.value=inputText.value.upper()
inputText.on_submit(makeUpper)
inputText
%matplotlib inline
import matplotlib.pyplot as plt
from IPython.html.widgets import *
import numpy as np
t=np.arange(0.0,1.0,0.01)
def pltsin(f):
plt.plot(t,np.sin(2*np.pi*t*f))
plt.show()
interact(pltsin,f=(1,10,0.1))
t
array([ 0. , 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1 , 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2 , 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3 , 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4 , 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5 , 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6 , 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7 , 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8 , 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9 , 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99])
import seaborn as sns
sns.set_style("whitegrid")
!pip install sympy
Collecting sympy
Downloading sympy-1.0.tar.gz (4.3MB)
100% |████████████████████████████████| 4.3MB 205kB/s
Collecting mpmath>=0.19 (from sympy)
Downloading mpmath-0.19.tar.gz (498kB)
100% |████████████████████████████████| 501kB 1.7MB/s
Building wheels for collected packages: sympy, mpmath
Running setup.py bdist_wheel for sympy ... - \ | / - \ | / - \ | / done
Stored in directory: /home/jovyan/.cache/pip/wheels/05/93/22/2d0f59d842347b1f38df0d3f7a3870586df60568d2a49d94c5
Running setup.py bdist_wheel for mpmath ... - \ | done
Stored in directory: /home/jovyan/.cache/pip/wheels/02/2b/99/cd867d5da48d951118a8020e86c0c12a65022702426582d4b8
Successfully built sympy mpmath
Installing collected packages: mpmath, sympy
Successfully installed mpmath-0.19 sympy-1.0
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
from sympy import *
from sympy import init_printing
init_printing()
x = Symbol('x')
y = (x + pi)**2
y
y.subs(x,2)
def eg(xx):
return y.subs(x,xx),N(y.subs(x,xx))
interact(eg, xx=(-10.0,10.0))
def factorit(n):
return Eq(x**n-1, factor(x**n-1))
interact(factorit, n=(2,40))