Ask Your Question
0

inserting expression into integral with latex and pythonsage1

asked 2015-10-03 20:37:31 +0100

collabmath gravatar image

updated 2015-10-12 19:02:44 +0100

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

Comments

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

fidbc gravatar imagefidbc ( 2015-10-03 20:51:36 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2015-10-04 20:37:19 +0100

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

edit flag offensive delete link more

Comments

sorry it works exactly the same still looking for solution

collabmath gravatar imagecollabmath ( 2015-10-10 03:53:12 +0100 )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

Stats

Asked: 2015-10-03 20:37:31 +0100

Seen: 848 times

Last updated: Oct 04 '15