colinfang colinfang - 4 years ago 247
Python Question

How to pretty print in ipython notebook via sympy? pprint only prints Unicode version

from sympy import symbols, Function
import sympy.functions as sym
from sympy import init_printing
from sympy import pprint
from sympy import Symbol

x = Symbol('x')

# If a cell contains only the following, it will render perfectly.
(pi + x)**2

# However I would like to control what to print in a function,
# so that multiple expressions can be printed from a single notebook cell.
pprint((pi + x)**2)

I tried
, the former only prints Unicode version, and the latter doesn't do pretty prints.

Answer Source

you need to use display:

from IPython.display import display


It will choose the appropriate representation (text/LaTex/png...)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download