How to print LaTex in Python 3 Jupyter Notebook

Viewed 3749

I'm currently in a python class, and we're learning about some of scipy's functions - my question is only vaguely related to that. We were tasked with creating a .quad code to solve the integral:

Definite Integral

I came up with:

def int1(x):

return (x**2*math.exp(-x)*math.sin(x))

integral1 = quad(int1,0,10)

print('Int[0,10](x^2*e^(-x)*sin(x) dx) = {:}'.format(integral1[0]))

This solves the question, but I would like to present my answer in a more elegant form. I'd love to have the integral print out in LaTex; I know in Markup mode, I can write this as:

$$ \int_{0}^{10}x^2e^{-x}\sin(x) \,dx $$

Is there any way to have the print() function output the integral in LaTex, followed by an = then the value?

I'm programming in Anaconda3 through a Jupyter Notebook on Windows.

0 Answers
Related