Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPython Notebook output latex or mathjax

How do you get iPython to output results using latex?

For example, like on this page: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/master/examples/notebooks/SymPy%20Examples.ipynb

If I execute the code:

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

I get output:

Out[13]: 3*pi/2 + exp(I*x)/(x**2 + y)

I want to see output in latex as shown in the link above.

like image 908
Riina Avatar asked Jun 12 '26 01:06

Riina


1 Answers

An updated answer for those googlers:

from IPython.display import Math
Math('3 \cdot \\frac{\pi}{2} + e^{\\frac{I*x}{x^2 + y}}')

A bit more clumsy than SymPy, but doesn't need an extra package.

like image 79
arve0 Avatar answered Jun 14 '26 13:06

arve0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!