Ask Your Question
1

sage interactive not working the same in website as mathcloud

asked 9 years ago

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

1 Answer

Sort by » oldest newest most voted
0

answered 9 years ago

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

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: 365 times

Last updated: Dec 28 '15