Ask Your Question
1

Unable to simplify function output

asked 2015-10-20 21:48:11 +0100

collabmath gravatar image

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 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-10-22 13:53:03 +0100

stan gravatar image

updated 2015-10-26 10:40:41 +0100

I somtimes get a similar error when I use pylab or matplotlib. Usually it helps if I wrap all values or variables with predefined values as e.g. float(1.6) or float(lower_x_bound). Edit: Sorry, I meant numpy.float instead of float.

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-10-20 21:48:11 +0100

Seen: 378 times

Last updated: Oct 26 '15