# sage interactive not working the same in website as mathcloud

I made a sage interactive. It works great on math cloud. However when I copy paste and format into html and make it online. The interactive says that it does not have enough arguments to format string. Why would this happen if it is the same code? Here is my code:

<h2>Double integrater</h2>
Alternative to Mathematica double integrater. Way Better!
<div id="mycell">
x,y = var('x,y')
html("<h1>Double Integrator<h1>")
@interact
def  interplay(function= input_box(x*y),lower_x_bound= input_box(0),upper_x_bound = input_box(x),lower_y_bound=input_box(0),upper_y_bound=input_box(1),dydx = checkbox(default = False)):
try:
if dydx == False:
result = integral(integral(function,x,lower_x_bound,upper_x_bound),y,lower_y_bound,upper_y_bound)

q ="$\int_{%s}^{%s} \int_{%s}^{%s} %s \,dx\,dy = %s$" % (lower_y_bound, upper_y_bound,lower_x_bound,upper_x_bound,function,result)

else:
result = integral(integral(function,y,lower_y_bound,upper_y_bound),x,lower_x_bound,upper_x_bound)
q ="$\int_{%s}^{%s} \int_{%s}^{%s} %s \,dx\,dy = %s$" % (lower_y_bound, upper_y_bound,lower_x_bound,upper_x_bound,function,result)
pretty_print(html("%s" %q))
except Exception as e :
print(e)
html("<p> done</p>")

</div>

edit retag close merge delete

Sort by ยป oldest newest most voted

Not clear to me what the problem may be. To help others explore, here is a slightly edited version of the original poster's code.

<h2>Double integrator</h2>
<p>Alternative to Mathematica's double integrator. Way better!</p>
<div id="mycell">
x, y = var('x y')
html("<h1>Double Integrator</h1>")
@interact
def interplay(function=input_box(x*y),
lower_x_bound=input_box(0),
upper_x_bound=input_box(x),
lower_y_bound=input_box(0),
upper_y_bound=input_box(1),
dydx=checkbox(default=False)):
try:
if dydx is False:
result = integral(integral(function, x, lower_x_bound, upper_x_bound),
y, lower_y_bound, upper_y_bound)
q = r"$\int_{%s}^{%s} \int_{%s}^{%s} %s \,dx\,dy = %s$" % (
lower_y_bound, upper_y_bound,
lower_x_bound, upper_x_bound,
function, result)
else:
result = integral(integral(function, y, lower_y_bound, upper_y_bound),
x, lower_x_bound, upper_x_bound)
q = r"$\int_{%s}^{%s} \int_{%s}^{%s} %s \,dx\,dy = %s$" % (
lower_y_bound, upper_y_bound,
lower_x_bound, upper_x_bound,
function, result)
pretty_print(html("%s" % q))
except Exception as e :
print(e)
html("<p>Done</p>")
</div>

more