In [1]:
%pylab inline
x = linspace(0, 2*pi)
In [2]:
plot(x, sin(x), label=r'$\sin(x)$')
plot(x, cos(x), 'ro', label=r'$\cos(x)$')
title(r'Two familiar function')
Out [2]:
In [3]:
%load_ext sympyprinting
In [4]:
import sympy as sym
from sympy import *
x, y, z = sym.symbols("x y z")
In [5]:
Rational(3,2)*pi + exp(I*x)/(x**2 + y)
Out [5]:
In [6]:
eq = ((x+y)**2 * (x+1))
eq
Out [6]:
In [7]:
expand(eq)
Out [7]:
In [8]:
diff(cos(x**2)**2 / (1 + x), x)
Out [8]:
You can italicize, boldface
def f(x): """a docstring""" return x**2
or other languages:
In [9]:
from IPython.display import Image
Image(filename=u'/Users/yaboo/Downloads/hoge.jpeg')
Out [9]:
In [10]:
from IPython.display import YouTubeVideo
YouTubeVideo('iwVvqwLDsJo')
Out [10]:
In [11]:
%%ruby
puts "Hello from Ruby #{RUBY_VERSION}"
In [12]:
%%bash
echo "hello from $BASH"
In [13]:
%load_ext rmagic
X = np.array([0,1,2,3,4])
Y = np.array([3,5,4,6,7])
In [14]:
%%R -i X,Y -o XYcoef
XYlm = lm(Y~X)
XYcoef = coef(XYlm)
print(summary(XYlm))
par(mfrow=c(2,2))
plot(XYlm)
In [42]:
XYcoef
Out [42]:
In [16]:
load_ext cythonmagic
In [17]:
%%cython -lm
from libc.math cimport sin
print 'sin(1)=', sin(1)