Ask Your Question

Revision history [back]

Thank you for the rapid answer, this way it worked for me. However, I have another question as my function involes more terms. The problem occurs also when I do the following:

var('y')

T = RealDistribution('gaussian',1) plot3d(lambda x,y: log(1/(2pix)) + log(T.cum_distribution_function((1-y)/x)), (x,-2,2), (y,-2,2))

While the log() in the second term seems to be no problem, the log() in the first term somehow breaks something, and I get the following long error message:

TypeError                                 Traceback (most recent call last)

<ipython-input-1-6c109b6281a7> in <module>() 1 var('y') 2 T = RealDistribution('gaussian',Integer(1)) ----> 3 plot3d(lambda x,y: log(Integer(1)/(Integer(2)pix)) + log(T.cum_distribution_function((Integer(1)-y)/x)), (x,-Integer(2),Integer(2)), (y,-Integer(2),Integer(2)))

/home/sageserver/sage/ipython/IPython/core/displayhook.pyc in __call__(self, result) 245 self.start_displayhook() 246 self.write_output_prompt() --> 247 format_dict, md_dict = self.compute_format_data(result) 248 self.write_format_data(format_dict, md_dict) 249 self.update_user_ns(result)

/home/sageserver/sage/ipython/IPython/core/displayhook.pyc in compute_format_data(self, result) 155 156 """ --> 157 return self.shell.display_formatter.format(result) 158 159 def write_format_data(self, format_dict, md_dict=None):

/home/sageserver/sage/ipython/IPython/core/formatters.pyc in format(self, obj, include, exclude) 150 md = None 151 try: --> 152 data = formatter(obj) 153 except: 154 # FIXME: log the exception

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/misc/displayhook.pyc in __call__(self, obj) 503 sage: fmt.set_display('simple') 504 """ --> 505 if self.try_format_graphics(obj): 506 return '' 507 s = self.try_format_obj(obj)

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/misc/displayhook.pyc in try_format_graphics(self, obj) 400 from sage.structure.sage_object import SageObject 401 if isinstance(obj, SageObject) and hasattr(obj, '_graphics_'): --> 402 return obj._graphics_() 403 return False 404

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/base.so in sage.plot.plot3d.base.Graphics3d._graphics_ (sage/plot/plot3d/base.c:3233)()

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/base.so in sage.plot.plot3d.base.Graphics3d.show (sage/plot/plot3d/base.c:12029)()

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/base.so in sage.plot.plot3d.base.Graphics3d._prepare_for_jmol (sage/plot/plot3d/base.c:8064)()

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/base.so in sage.plot.plot3d.base.Graphics3d._box_for_aspect_ratio (sage/plot/plot3d/base.c:8679)()

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/base.so in sage.plot.plot3d.base.Graphics3d._safe_bounding_box (sage/plot/plot3d/base.c:4275)()

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_surface.so in sage.plot.plot3d.parametric_surface.ParametricSurface.bounding_box (sage/plot/plot3d/parametric_surface.c:3625)()

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_surface.so in sage.plot.plot3d.parametric_surface.ParametricSurface.triangulate (sage/plot/plot3d/parametric_surface.c:4228)()

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_surface.so in sage.plot.plot3d.parametric_surface.ParametricSurface.triangulate (sage/plot/plot3d/parametric_surface.c:4157)()

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_surface.so in sage.plot.plot3d.parametric_surface.ParametricSurface.eval_grid (sage/plot/plot3d/parametric_surface.c:5955)()

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.__float__ (sage/symbolic/expression.cpp:7716)()

TypeError: unable to simplify to float approximation

click to hide/show revision 2
No.2 Revision

Thank you for the rapid answer, this way it worked for me. However, I have another question as my function involes more terms. The problem occurs also when I do the following:

 var('y')

T = RealDistribution('gaussian',1) plot3d(lambda x,y: log(1/(2pix)) log(1/(2*pi*x)) + log(T.cum_distribution_function((1-y)/x)), (x,-2,2), (y,-2,2))

(y,-2,2))

While the log() in the second term seems to be no problem, the log() in the first term somehow breaks something, and I get the following long error message:

 TypeError                                 Traceback (most recent call last)

<ipython-input-1-6c109b6281a7> in <module>() 1 var('y') 2 T = RealDistribution('gaussian',Integer(1)) ----> 3 plot3d(lambda x,y: log(Integer(1)/(Integer(2)pix)) log(Integer(1)/(Integer(2)*pi*x)) + log(T.cum_distribution_function((Integer(1)-y)/x)), (x,-Integer(2),Integer(2)), (y,-Integer(2),Integer(2)))

(y,-Integer(2),Integer(2))) /home/sageserver/sage/ipython/IPython/core/displayhook.pyc in __call__(self, result) 245 self.start_displayhook() 246 self.write_output_prompt() --> 247 format_dict, md_dict = self.compute_format_data(result) 248 self.write_format_data(format_dict, md_dict) 249 self.update_user_ns(result)

self.update_user_ns(result) /home/sageserver/sage/ipython/IPython/core/displayhook.pyc in compute_format_data(self, result) 155 156 """ --> 157 return self.shell.display_formatter.format(result) 158 159 def write_format_data(self, format_dict, md_dict=None):

md_dict=None): /home/sageserver/sage/ipython/IPython/core/formatters.pyc in format(self, obj, include, exclude) 150 md = None 151 try: --> 152 data = formatter(obj) 153 except: 154 # FIXME: log the exception

exception /home/sageserver/sage/local/lib/python2.7/site-packages/sage/misc/displayhook.pyc in __call__(self, obj) 503 sage: fmt.set_display('simple') 504 """ --> 505 if self.try_format_graphics(obj): 506 return '' 507 s = self.try_format_obj(obj)

self.try_format_obj(obj) /home/sageserver/sage/local/lib/python2.7/site-packages/sage/misc/displayhook.pyc in try_format_graphics(self, obj) 400 from sage.structure.sage_object import SageObject 401 if isinstance(obj, SageObject) and hasattr(obj, '_graphics_'): --> 402 return obj._graphics_() 403 return False 404

/home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/base.so in sage.plot.plot3d.base.Graphics3d._graphics_ (sage/plot/plot3d/base.c:3233)()

(sage/plot/plot3d/base.c:3233)() /home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/base.so in sage.plot.plot3d.base.Graphics3d.show (sage/plot/plot3d/base.c:12029)()

(sage/plot/plot3d/base.c:12029)() /home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/base.so in sage.plot.plot3d.base.Graphics3d._prepare_for_jmol (sage/plot/plot3d/base.c:8064)()

(sage/plot/plot3d/base.c:8064)() /home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/base.so in sage.plot.plot3d.base.Graphics3d._box_for_aspect_ratio (sage/plot/plot3d/base.c:8679)()

(sage/plot/plot3d/base.c:8679)() /home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/base.so in sage.plot.plot3d.base.Graphics3d._safe_bounding_box (sage/plot/plot3d/base.c:4275)()

(sage/plot/plot3d/base.c:4275)() /home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_surface.so in sage.plot.plot3d.parametric_surface.ParametricSurface.bounding_box (sage/plot/plot3d/parametric_surface.c:3625)()

(sage/plot/plot3d/parametric_surface.c:3625)() /home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_surface.so in sage.plot.plot3d.parametric_surface.ParametricSurface.triangulate (sage/plot/plot3d/parametric_surface.c:4228)()

(sage/plot/plot3d/parametric_surface.c:4228)() /home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_surface.so in sage.plot.plot3d.parametric_surface.ParametricSurface.triangulate (sage/plot/plot3d/parametric_surface.c:4157)()

(sage/plot/plot3d/parametric_surface.c:4157)() /home/sageserver/sage/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_surface.so in sage.plot.plot3d.parametric_surface.ParametricSurface.eval_grid (sage/plot/plot3d/parametric_surface.c:5955)()

(sage/plot/plot3d/parametric_surface.c:5955)() /home/sageserver/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.__float__ (sage/symbolic/expression.cpp:7716)()

(sage/symbolic/expression.cpp:7716)() TypeError: unable to simplify to float approximation

approximation