Sage Interactive has Attribute error
Herr is my code for a double integrator interactive I am making that both make a double integral and shows a graph with added rectangles. However in my code I get an attribute error I don't know.
from sage.plot.plot3d.shapes import Box
x,y = var('x,y')
html("<h1>triple integrater<h1>")
permutations = ["dx dy","dy dx"]
@interact
def interplay(order= permutations,function= input_box(sin(x*y)),lower_x_bound= input_box(0.1.1),upper_x_bound = input_box(1),lower_y_bound=input_box(0),upper_y_bound=input_box(1),showGraph = checkbox(default = False), numrecs= input_box(50)):
if permutations == "dx dy":
result = integral(integral(function,x,lower_x_bound,upper_x_bound),y,lower_y_bound,upper_y_bound)+function(lower_x_bound,lower_y_bound)+function(lower_x_bound,lower_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 $" % (lower_y_bound, upper_y_bound,lower_x_bound,upper_x_bound,function)
# 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 $" % (lower_x_bound,upper_x_bound,lower_y_bound,upper_y_bound,function)
#if type(lower_x_bound)!=float or type(upper_x_bound)!=float or type(lower_y_bound)!= float or type(upper_y_bound)!= float :
if lower_x_bound in RR or upper_x_bound in RR or lower_y_bound in RR or lower_y_bound in RR:
#check if bounds are are real before graphing because I do nto know how to graph with x as a bound.
showGraph = True
html("Can only grah numerical bounds")
else:
showGraph = False
if showGraph == True :
graph = plot3d(function,(x,lower_x_bound,upper_x_bound),(y,lower_y_bound,upper_y_bound),fill=True,color = "orange",spin = 4)
html("<h3>Graph of Integrated Region</h3>")
delta = upper_x_bound - lower_x_bound
B = sum([Box([1/numrecs,.5,abs(function(lower_x_bound+(i-1)*delta/numrecs , .2))], color="orange").translate((lower_x_bound+delta*i/numrecs,0,function(lower_x_bound+i*delta/numrecs)/2)) for i in [0..numrecs]])
#makes a whole bunch of rectangels which approximate graph of function being integrated
show(graph+B)
html("<h3>Numerical Result</h3>")
#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" %q)
#shows the result
I am getting this error. I do not know what it means.
Error in lines 5-29
Traceback (most recent call last):
File "/projects/454b81d2-ef23-4b95-bd57-5c718a468ea1/.sagemathcloud/sage_server.py", line 881, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 2, in <module>
File "sage/structure/element.pyx", line 418, in sage.structure.element.Element.__getattr__ (/projects/sage/sage-6.9/src/build/cythonized/sage/structure/element.c:4670)
return getattr_from_other_class(self, P._abstract_element_class, name)
File "sage/structure/misc.pyx", line 259, in sage.structure.misc.getattr_from_other_class (/projects/sage/sage-6.9/src/build/cythonized/sage/structure/misc.c:1771)
raise dummy_attribute_error
AttributeError: 'sage.rings.real_mpfr.RealLiteral' object has no attribute 'gen'
There are quite a few other errors or deprecation warnings in this code too, though. I recommend starting a bit from scratch, it's all quite fixable but doing so for someone other than the author will be somewhat time-consuming (I just tried...)
This fixed the attribute error Thank you