IPython is a powerful command shell designed for interactive computing in multiple programming languages. Although it was initially designed for Python, its functionalities have quickly permeated other programming languagues like and other capabilities like Notebooks.
It is worth mentioning the main author of IPython is Fernando Perez, a physic graduate from the Universidad de Antioquia and currently Professor in University of California, Berkeley.
Features
IPython provides a rich architecture for interactive computing with:
Since 2011, IPython has incorporated a new funcionality called Notebooks. For those who know notebooks of Mathematica® and SAGE this feature may be familiar.
Official page IPython Notebooks
The IPython Notebook is a web-based interactive computational environment where you can combine code execution, text, mathematics, plots and rich media into a single document. These notebooks are normal files that can be shared with colleagues, converted to other formats such as HTML or PDF, etc. You can share any publicly available notebook by using the IPython Notebook Viewer service which will render it as a static web page. This makes it easy to give your colleagues a document they can read immediately without having to install anything.
What is better than a step by step example when you want to introduce a new tool. Next it is shown a simple example of a IPython notebook for generating a family of Lissajous curves.
Red cursive text corresponds to comments on the activity.
Lissajous curves are a family of parametric two-dimensional curves normally obtained when solving multi-harmonic systems, like a mass-spring systems with two springs in each axis (x and y) or some circuit systems. The figures are described with the following equations:
$x(t) = A\sin(a t +\delta)$
$y(t) = B\sin(b t)$
where $A$ and $B$ are the amplitudes along each axis, $a$ and $b$ the angular frequencies and $\delta$ the relative phase.
![Some text](URL_to_figure)
#This line is always necessary when you use matplotlib in a notebook, otherwise the figures will not appear.
%pylab inline
import matplotlib.pyplot as plt
import numpy as np
Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline]. For more information, type 'help(pylab)'.
#Solutions
def Lissajous( t, A=1.0, B=1.0, a=1.0, b=1.0, delta=0.0 ):
x = A*np.sin(a*t+delta)
y = B*np.sin(b*t)
return x, y
#Parameters to be sampled--------------------
#delta
Ndelta = 4 #Number of delta parameters
Delta = np.linspace(0,np.pi,Ndelta)
#Ratio c=a/b
Nratio = 6 #Number of c parameters
C = np.linspace(0,1,Nratio)
#Time array
T = np.linspace(0,40,1000)
#Initializing plotting environment
plt.figure( figsize=(4*Ndelta, 4*Nratio) )
plt.subplot( Nratio, Ndelta, 1 )
plt.plot()
#Sweeping all figures
for i in xrange( Ndelta ):
for j in xrange( Nratio ):
#Creating a subfigure with the current delta and ratio c
plt.subplot( Nratio, Ndelta, j*Ndelta+i+1 )
#Plotting this Lissajous curve
X, Y = Lissajous( T, b=C[j], delta=Delta[i] )
plt.title( "$\delta=$%1.2f\t$a/b=$%1.2f"%(Delta[i],C[j]) )
plt.plot( X, Y, linewidth=2 )
For this activity, you should obtain something like this.
Once you have a notebook, you can upload it in some online storage service like Dropbox or Google drive or some repository service like GitHub. Then, you can put the link of your notebook directly into the IPython Notebook Viewer.
from IPython.core.display import Image
Image(filename='./figures/nbviewer.png')