# Revision history [back]

### Unable to simplify function output

I am trying to make a tool that creates a large number of rectangular boxes approximating a 3 dimensional graph. However when I enter in my function value as box height Sage says it is unable to simplify my height to a float approximation. I also do not what to display graph when the bounds are not real numbers. Does anyone know the solutions to my two problems.

 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

#func= function(x = lower_x_bound+(i-1)*delta/numrecs , y = .2)
#show(func)

B =  sum([Box([1/numrecs,.5,function(x = lower_x_bound+(i-1)*delta/numrecs , y = .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)


This is the error I get when it tries to make the box heights.

Error in lines 1-1
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 1, in <module>
File "/projects/454b81d2-ef23-4b95-bd57-5c718a468ea1/.sagemathcloud/sage_server.py", line 1031, in _execute_interact
sage_salvus.interacts[id](vals)
File "/projects/454b81d2-ef23-4b95-bd57-5c718a468ea1/.sagemathcloud/sage_salvus.py", line 216, in __call__
self._f(**dict([(k,self._last_vals[k]) for k in self._args]))
File "", line 26, in interplay
File "/projects/454b81d2-ef23-4b95-bd57-5c718a468ea1/.sagemathcloud/sage_salvus.py", line 2429, in show
s = show0(objs, combine_all=True)
File "/projects/454b81d2-ef23-4b95-bd57-5c718a468ea1/.sagemathcloud/sage_salvus.py", line 2414, in show0
b = show0(a)
File "/projects/454b81d2-ef23-4b95-bd57-5c718a468ea1/.sagemathcloud/sage_salvus.py", line 2402, in show0
salvus.threed(obj, **kwds)
File "/projects/454b81d2-ef23-4b95-bd57-5c718a468ea1/.sagemathcloud/sage_server.py", line 657, in threed
b = g.bounding_box()
File "sage/plot/plot3d/base.pyx", line 1826, in sage.plot.plot3d.base.Graphics3dGroup.bounding_box (/projects/sage/sage-6.9/src/build/cythonized/sage/plot/plot3d/base.c:21855)
v = [obj.bounding_box() for obj in self.all]
File "sage/plot/plot3d/base.pyx", line 2053, in sage.plot.plot3d.base.TransformGroup.bounding_box (/projects/sage/sage-6.9/src/build/cythonized/sage/plot/plot3d/base.c:24768)
cdef Transformation T = self.get_transformation()
File "sage/plot/plot3d/base.pyx", line 2174, in sage.plot.plot3d.base.TransformGroup.get_transformation (/projects/sage/sage-6.9/src/build/cythonized/sage/plot/plot3d/base.c:26552)
self.T = Transformation(self._scale, self._rot, self._trans)
File "sage/plot/plot3d/transform.pyx", line 49, in sage.plot.plot3d.transform.Transformation.__init__ (/projects/sage/sage-6.9/src/build/cythonized/sage/plot/plot3d/transform.c:2785)
self.matrix = m.augment(matrix(RDF, 3, 1, list(trans))) \
File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/sage/matrix/constructor.py", line 729, in _matrix_constructor
return matrix_space.MatrixSpace(ring, nrows, ncols, sparse=sparse)(entries)
File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/sage/matrix/matrix_space.py", line 524, in __call__
return self.matrix(entries, coerce, copy)
File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/sage/matrix/matrix_space.py", line 1442, in matrix
return MC(self, x, copy=copy, coerce=coerce)
File "sage/matrix/matrix_double_dense.pyx", line 234, in sage.matrix.matrix_double_dense.Matrix_double_dense.__init__ (/projects/sage/sage-6.9/src/build/cythonized/sage/matrix/matrix_double_dense.c:3798)
self.set_unsafe(i,j,self._python_dtype(entries[i*self._ncols+j]))
File "sage/symbolic/expression.pyx", line 1368, in sage.symbolic.expression.Expression.__float__ (/projects/sage/sage-6.9/src/build/cythonized/sage/symbolic/expression.cpp:10216)
raise TypeError("unable to simplify to float approximation")
TypeError: unable to simplify to float approximation


This the error with non real bounds like x where I include the graph but not the boxes

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 1, in <module>
File "/projects/454b81d2-ef23-4b95-bd57-5c718a468ea1/.sagemathcloud/sage_server.py", line 1031, in _execute_interact
sage_salvus.interacts[id](vals)
File "/projects/454b81d2-ef23-4b95-bd57-5c718a468ea1/.sagemathcloud/sage_salvus.py", line 216, in __call__
self._f(**dict([(k,self._last_vals[k]) for k in self._args]))
File "", line 19, in interplay
File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/sage/plot/plot3d/plot3d.py", line 868, in plot3d
P=parametric_plot3d.parametric_plot3d((u,v,f), urange, vrange, **kwds)
File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_plot3d.py", line 594, in parametric_plot3d
G = _parametric_plot3d_surface(f, urange, vrange, plot_points=plot_points, boundary_style=boundary_style, **kwds)
File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_plot3d.py", line 704, in _parametric_plot3d_surface
g, ranges = setup_for_eval_on_grid(f, [urange,vrange], plot_points)
File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/sage/plot/misc.py", line 123, in setup_for_eval_on_grid
ranges = [[float(z) for z in r] for r in ranges]
File "sage/symbolic/expression.pyx", line 1368, in sage.symbolic.expression.Expression.__float__ (/projects/sage/sage-6.9/src/build/cythonized/sage/symbolic/expression.cpp:10216)
raise TypeError("unable to simplify to float approximation")
TypeError: unable to simplify to float approximation