This is an example for the displaytools extension for the IPython Notebook.
The extension introduces some "magic" comments (like ## and ##: ) which trigger additional output (normally only the return value of the last line of a cell is printed). See Why is this useful?
In [17]:
%load_ext displaytools3
%reload_ext displaytools3
In [18]:
import sympy as sp
from sympy import sin, cos
from sympy.abc import t, pi
In [19]:
x = 2*pi*t
y1 = cos(x)
y2 = cos(x)*t
ydot1 = y1.diff(t) ##
ydot2 = y2.diff(t) ##
ydot1_obj = y1.diff(t, evaluate=False) ##
Note that the equation sign (i.e., =) must be enclosed by two spaces, i.e.: lhs = rhs.
If the variable name is also desired this can be triggered by ##:
In [20]:
ydot1 = y1.diff(t) ##:
ydot2 = y2.diff(t) ##:
ydot1_obj = y1.diff(t, evaluate=False) ##:
Printing can be combined with LaTeX rendering:
In [21]:
sp.interactive.printing.init_printing(1)
In [22]:
ydot1 = y1.diff(t) ##:
ydot2 = y2.diff(t) ##:
ydot1_obj = y1.diff(t, evaluate=False) ##:
If there is no assignment taking place, ## nevertheless causes the display of the respective result.
In [23]:
y1.diff(t,t) ##
y2.diff(t,t) ##
In [24]:
xx = sp.Matrix(sp.symbols('x1:11')) ##
yy = sp.Matrix(sp.symbols('y1:11')) ##:T
xx.shape, yy.shape ##
In [25]:
# combination with other comments
a = 3 # comment ##:
In [28]:
# Multiline statements and indended lines are not yet supported:
a = [1,
2] ##:
if 1:
b = [10, 20] ##:
c = [100, 200] ##: