Ask Your Question
1

sage interactive not working the same in website as mathcloud

asked 2015-12-27 05:59:25 +0100

collabmath gravatar image

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("Please enter better inputs")
    print(e)
html("<p> done</p>")


</div>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-12-28 09:45:07 +0100

slelievre gravatar image

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("Please enter better inputs")
    print(e)
html("<p>Done</p>")
</div>
edit flag offensive delete link more

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-12-27 05:59:25 +0100

Seen: 356 times

Last updated: Dec 28 '15