Ask Your Question

inserting expression into integral with latex and pythonsage1

asked 2015-10-03 13:37:31 -0500

collabmath gravatar image

updated 2015-10-12 12:02:44 -0500

FrédéricC gravatar image

I am trying to write some code where the user enters in a expression into a sage interactive and then my programs display the integral in latex. For example the user might enter in x^2 or sin(x) as bounds in my program. However,neither of these expressions works. when I use sin(x) as bound the s shows up as a bound but the in(X) shows up in the expression being integrated. when I put x^2 as a bound the integral does not show up and I get the message "Double Exponents use braces to clarify".

 s = "$\int_{2}^{3}  \int_{4}^{5} {0} \,dxdy = {1} $"

p = s.format(function, result,lower_x_bound,upper_x_bound,lower_y_bound,upper_y_bound)

html("%s" %p)
edit retag flag offensive close merge delete


What are all the other variables in your example? Just so that we can try reproducing the error.

fidbc gravatar imagefidbc ( 2015-10-03 13:51:36 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2015-10-04 13:37:19 -0500

vdelecroix gravatar image


You will get the same error with


The right way to do it is to enclose the expression in exponent with "{" and "}"


In your example, because you use format, these must be double curly braces. In other words

 s = "$\int_{{{2}}}^{{{3}}}  \int_{{{4}}}^{{{5}}} {0} \,dxdy = {1} $"


edit flag offensive delete link more


sorry it works exactly the same still looking for solution

collabmath gravatar imagecollabmath ( 2015-10-09 20:53:12 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-10-03 13:37:31 -0500

Seen: 223 times

Last updated: Oct 04 '15