old wiki Pretty Printing - gxyd/sympy GitHub Wiki
old wiki Pretty Printing
This page is obsoleted by http://wiki.sympy.org/wiki/Pretty_Printing
= Introduction =
!SymPy is able to display nice-looking formulas on a pure terminal using ascii-art. Even more -- when unicode is available, it uses special better-looking symbols for drawing.
To try it, run isympy in a unicode-capable terminal such as uxterm
or gnome-terminal
.
= Example =
{{{ $ ./bin/isympy Python 2.4.4 console for SymPy 0.5.6-hg. These commands were executed:
from future import division from sympy import * x, y, z = symbols('xyz') k, m, n = symbols('kmn', integer=True) Basic.set_repr_level(2) # 2D output pprint_try_use_unicode() # try to setup unicode pprint
In [1]: f = Function('f')
In [2]: f(x/(y+1), y) Out[2]: ā x ā fāāāāāā, yā ā1 + y ā
In [3]: sqrt((sqrt(x+1))+1) Out[3]: ā½ā½ā½ā½ā½ā½ā½ā½ā½ā½ā½ā½ā½ā½ā½ ā± ā½ā½ā½ā½ā½ā½ā½ ā²ā± 1 + ā²ā± 1 + x
In [4]: th=Symbol('theta'); ph=Symbol('phi')
In [5]: Integral(sin(th)/cos(ph), (th,0,pi), (ph, 0, 2pi))
Out[5]:
2Ļ Ļ
ā ā
ā® ā® sin(Īø)
ā® ā® āāāāāā dĪø dĻ
ā® ā® cos(Ļ)
ā” ā”
0 0
In [6]: Integral(x**2*sin(y), (x,0,1), (y,0,pi))
Out[6]:
Ļ 1
ā ā
ā® ā® 2
ā® ā® x *sin(y) dx dy
ā” ā”
0 0
In [7]: Mul([Symbol('theta%i' %i) for i in range(1,5)]) Out[7]: ĪøāĪøāĪøāĪøā
In [8]: Symbol('Y_00')(th,ph)**2 == 1/(4pi) Out[8]: 2 1 Yāā (Īø, Ļ) = āāā 4Ļ
In [9]: Matrix([ ...: [1/(4pi), 1], ...: [1, f(x)] ...: ]) Out[9]: ┠⤠⢠1 ℠⢠āāā 1℠⢠4Ļ ā„ ā¢ ā„ ā¢ ā„ ā£ 1 f(x)ā¦
}}}
= This is how it looks like =
in uxterm
:
http://sympy.googlecode.com/svn/materials/web/screenshots/uterm-isympy-unicode.png
and gnome-terminal
:
http://sympy.googlecode.com/svn/materials/web/screenshots/gnome-terminal-unicode.png