# [IPython-dev] SymPy printing in the ipython notebook

Richard Johns rjohns67 at gmail.com
Fri Apr 4 02:34:11 EDT 2014

I attempted to follow the examples in

http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/notebooks/SymPy%20Examples.ipynb

If I open a new notebook and carry out the steps below the output is
mathematically correct but it isn't displayed in latex/mathjax format:

from IPython.display import display

from sympy.interactive import printing
printing.init_printing()

from __future__ import division
import sympy as sym
from sympy import *
x, y, z = symbols("x y z")
k, m, n = symbols("k m n", integer=True)
f, g, h = map(Function, 'fgh')

Rational(3,2)*pi + exp(I*x) / (x**2 + y)

The output is:

3*pi/2 + exp(I*x)/(x**2 + y)

SoftwareVersionPython2.7.3 (default, Feb 27 2014, 20:00:17) [GCC 4.6.3]
IPython2.0.0OSposix [linux2]numpy1.6.1matplotlib1.1.1rcscipy0.9.0Thu Apr 03
00:02:41 2014 MST

If I open a terminal in the same directory and repeat these steps the
output is displayed in a pretty printing format:

rj at rjslptp:~\$ ipython
Python 2.7.3 (default, Feb 27 2014, 20:00:17)

IPython 2.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In : from IPython.display import display

In :

In : from sympy.interactive import printing

In : printing.init_printing()

In :

In : from __future__ import division

In : import sympy as sym

In : from sympy import *

In : x, y, z = symbols("x y z")

In : k, m, n = symbols("k m n", integer=True)

In : f, g, h = map(Function, 'fgh')

In : Rational(3,2)*pi + exp(I*x) / (x**2 + y)
ⅈ⋅x
3⋅π    ℯ
─── + ──────
2     2
x  + y

I imagine I'm missing something simple but I haven't been able to figure
out what it is. Any help would be appreciated.

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140403/bd39b7f7/attachment.html>