Ask Your Question
0

inserting expression into integral with latex and pythonsage1

asked 9 years ago

collabmath gravatar image

updated 9 years ago

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)
Preview: (hide)

Comments

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

fidbc gravatar imagefidbc ( 9 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 9 years ago

vdelecroix gravatar image

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

Preview: (hide)
link

Comments

sorry it works exactly the same still looking for solution

collabmath gravatar imagecollabmath ( 9 years ago )

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

Stats

Asked: 9 years ago

Seen: 987 times

Last updated: Oct 04 '15