# inserting expression into integral with latex and pythonsage1

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 close merge delete

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

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

Sort by » oldest newest most voted

Hello,

You will get the same error with

html("$a^b^c$")


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

html("$a^{b^c}$")


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}$"


Vincent

more

sorry it works exactly the same still looking for solution

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