Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

if statement not working

I am trying to make a sage interactive that switches between dx dy and dy dx. Yet, in my interactive when I press either I see no difference in the latex generated ie the order dx dy or dy dx does not chnage

def  interplay(order= permutations,function= input_box(sin(x*y)),lower_x_bound= input_box(0),upper_x_bound = input_box(1),lower_y_bound=input_box(0),upper_y_bound=input_box(1),showGraph = checkbox(default = False)):



    try:    

       if permutations == "dx dy":              
                 result = integral(integral(function,x,lower_x_bound,upper_x_bound),y,lower_y_bound,upper_y_bound)#function.integrate(x,lower_x_bound,upper_x_bound).integrate(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)
                 # puts expressions inside latex
          else:
                result = integral(integral(function,y,lower_y_bound,upper_y_bound),y,lower_x_bound,upper_x_bound)
                #actually calculates integral
                q="$\int_%s^{%s} \int_%s^%s %s \,dy\,dx = %s $" % (lower_x_bound,upper_x_bound,lower_y_bound,upper_y_bound,function,result)