[sage-support] Re: Plotting complex functions in imaginary and real parts
the following works for me: sage: var('x y'); : cmsel = [colormaps['gnuplot2'](i) for i in sxrange(0,1,0.02)] : plot3d(lambda x,y:((1/(sqrt((2**2)*pi)))*(x+I*y)*exp(-((0.25)*((x+I*y)**2.imag_part(),(x,-3*pi,3*pi),(y,0,2),adaptive=True, : color=cmsel) Note that I removed "math." prefix from sqrt() and put the brackets at the right places. On Monday, June 26, 2017 at 1:27:45 PM UTC+1, Fjordforsk A/S wrote: > > Hi, I tried to use a command found online for plotting complex and real > components of a function: > > var('x y'); > cmsel = [colormaps['gnuplot2'](i) for i in sxrange(0,1,0.02)] > plot3d(lambda > x,y:(1/(math.sqrt((2**2)*pi)))*(x+I*y)*exp(-((0.25)*((x+I*y)**2.imag_part(),(x,-3*pi,3*pi),(y,0,2),adaptive=True,color=cmsel) > > however, it does not work, no matter how the brackets are ordered. Is > there a formatting problem here? > > Thanks > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Plotting complex functions in imaginary and real parts
Note, that when brackets are corrected it gives the following result: TypeError Traceback (most recent call last) in () > 1 plot3d(lambda x,y:(Integer(1)/(math.sqrt((Integer(2)**Integer(2))*pi)))*(x+I*y)*exp(-((RealNumber('0.25'))*((x+I*y)**Integer(2.imag_part(),(x,-Integer(3)*pi,Integer(3)*pi),(y,Integer(0),Integer(2)),adaptive=True,color=cmsel) /home/sem/SageMath/local/lib/python2.7/site-packages/sage/plot/plot3d/plot3d.pyc in plot3d(f, urange, vrange, adaptive, transformation, **kwds) 1035 raise ValueError('unknown transformation type') 1036 elif adaptive: -> 1037 P = plot3d_adaptive(f, urange, vrange, **kwds) 1038 else: 1039 u=fast_float_arg(0) /home/sem/SageMath/local/lib/python2.7/site-packages/sage/plot/plot3d/plot3d.pyc in plot3d_adaptive(f, x_range, y_range, color, grad_f, max_bend, max_depth, initial_depth, num_colors, **kwds) 1118 plot = TrianglePlot(factory, g, (xmin, xmax), (ymin, ymax), g = grad_f, 1119 min_depth=initial_depth, max_depth=max_depth, -> 1120 max_bend=max_bend, num_colors = None) 1121 1122 P = IndexFaceSet(plot._objects) /home/sem/SageMath/local/lib/python2.7/site-packages/sage/plot/plot3d/tri_plot.pyc in __init__(self, triangle_factory, f, min_x__max_x, min_y__max_y, g, min_depth, max_depth, num_colors, max_bend) 288 289 # jump in and start building blocks --> 290 outer = self.plot_block(min_x, mid_x, max_x, min_y, mid_y, max_y, sw_z, nw_z, se_z, ne_z, mid_z, 0) 291 292 # build the boundary triangles /home/sem/SageMath/local/lib/python2.7/site-packages/sage/plot/plot3d/tri_plot.pyc in plot_block(self, min_x, mid_x, max_x, min_y, mid_y, max_y, sw_z, nw_z, se_z, ne_z, mid_z, depth) 407 408 # recurse into the sub-squares --> 409 sw = self.plot_block(min_x, qtr1_x, mid_x, min_y, qtr1_y, mid_y, sw_z, mid_w_z, mid_s_z, mid_z, mid_sw_z, sw_depth) 410 nw = self.plot_block(min_x, qtr1_x, mid_x, mid_y, qtr3_y, max_y, mid_w_z, nw_z, mid_z, mid_n_z, mid_nw_z, nw_depth) 411 se = self.plot_block(mid_x, qtr3_x, max_x, min_y, qtr1_y, mid_y, mid_s_z, mid_z, se_z, mid_e_z, mid_se_z, se_depth) /home/sem/SageMath/local/lib/python2.7/site-packages/sage/plot/plot3d/tri_plot.pyc in plot_block(self, min_x, mid_x, max_x, min_y, mid_y, max_y, sw_z, nw_z, se_z, ne_z, mid_z, depth) 407 408 # recurse into the sub-squares --> 409 sw = self.plot_block(min_x, qtr1_x, mid_x, min_y, qtr1_y, mid_y, sw_z, mid_w_z, mid_s_z, mid_z, mid_sw_z, sw_depth) 410 nw = self.plot_block(min_x, qtr1_x, mid_x, mid_y, qtr3_y, max_y, mid_w_z, nw_z, mid_z, mid_n_z, mid_nw_z, nw_depth) 411 se = self.plot_block(mid_x, qtr3_x, max_x, min_y, qtr1_y, mid_y, mid_s_z, mid_z, se_z, mid_e_z, mid_se_z, se_depth) /home/sem/SageMath/local/lib/python2.7/site-packages/sage/plot/plot3d/tri_plot.pyc in plot_block(self, min_x, mid_x, max_x, min_y, mid_y, max_y, sw_z, nw_z, se_z, ne_z, mid_z, depth) 407 408 # recurse into the sub-squares --> 409 sw = self.plot_block(min_x, qtr1_x, mid_x, min_y, qtr1_y, mid_y, sw_z, mid_w_z, mid_s_z, mid_z, mid_sw_z, sw_depth) 410 nw = self.plot_block(min_x, qtr1_x, mid_x, mid_y, qtr3_y, max_y, mid_w_z, nw_z, mid_z, mid_n_z, mid_nw_z, nw_depth) 411 se = self.plot_block(mid_x, qtr3_x, max_x, min_y, qtr1_y, mid_y, mid_s_z, mid_z, se_z, mid_e_z, mid_se_z, se_depth) /home/sem/SageMath/local/lib/python2.7/site-packages/sage/plot/plot3d/tri_plot.pyc in plot_block(self, min_x, mid_x, max_x, min_y, mid_y, max_y, sw_z, nw_z, se_z, ne_z, mid_z, depth) 407 408 # recurse into the sub-squares --> 409 sw = self.plot_block(min_x, qtr1_x, mid_x, min_y, qtr1_y, mid_y, sw_z, mid_w_z, mid_s_z, mid_z, mid_sw_z, sw_depth) 410 nw = self.plot_block(min_x, qtr1_x, mid_x, mid_y, qtr3_y, max_y, mid_w_z, nw_z, mid_z, mid_n_z, mid_nw_z, nw_depth) 411 se = self.plot_block(mid_x, qtr3_x, max_x, min_y, qtr1_y, mid_y, mid_s_z, mid_z, se_z, mid_e_z, mid_se_z, se_depth) /home/sem/SageMath/local/lib/python2.7/site-packages/sage/plot/plot3d/tri_plot.pyc in plot_block(self, min_x, mid_x, max_x, min_y, mid_y, max_y, sw_z, nw_z, se_z, ne_z, mid_z, depth) 364 #should work a bit better because of the density of floating-point 365 #numbers near zero. --> 366 norm_w = crossunit(sw_v, nw_v) 367 norm_n = crossunit(nw_v, ne_v) 368 norm_e = crossunit(ne_v, se_v) /home/sem/SageMath/local/lib/python2.7/site-packages/sage/plot/plot3d/tri_plot.pyc in crossunit(u, v) 567 """ 568 p = (u[1]*v[2] - v[1]*u[2], u[0]*v[2] - v[0]*u[2], u[0]*v[1] - u[1]*v[0])
[sage-support] Plotting complex functions in imaginary and real parts
Hi, I tried to use a command found online for plotting complex and real components of a function: var('x y'); cmsel = [colormaps['gnuplot2'](i) for i in sxrange(0,1,0.02)] plot3d(lambda x,y:(1/(math.sqrt((2**2)*pi)))*(x+I*y)*exp(-((0.25)*((x+I*y)**2.imag_part(),(x,-3*pi,3*pi),(y,0,2),adaptive=True,color=cmsel) however, it does not work, no matter how the brackets are ordered. Is there a formatting problem here? Thanks -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Further on plotting functions
Thanks, that fixed it. Trying this variant with colors: var('x y'); cmsel = [colormaps['gnuplot2'](i) for i in sxrange(0,1,0.02)] plot3d(lambda x,y:(1/(math.sqrt(2**2)*pi))*(x+I*y)*exp(-(0.25)((x+I*y)**2)),(x,-2*pi,2*pi),(y,-2*pi,2*pi),adaptive=True,color=cmsel) But something stops here. Is this a wrong type of way of plotting that function? mandag 26. juni 2017 13.25.58 UTC+2 skrev Eric Gourgoulhon følgende: > > > > Le lundi 26 juin 2017 13:05:27 UTC+2, Fjordforsk A/S a écrit : >> >> Hello, I tried a different variant of the previous plot: >> >> def f(x,y): >> return math.sqrt(2**3))*exp(-(x**2 + y**2) >> P = plot3d(f,(-3,3),(-3,3), adaptive=True, color=rainbow(60, 'rgbtuple'), >> max_bend=.1, max_depth=15) >> P.show() >> >> however, this also does not show. >> >> > Works for me, provided the parentheses in the definition of f are well > placed: > def f(x,y): > return math.sqrt(2**3)*exp(-(x**2 + y**2)) > > Best wishes, > > Eric. > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Further on plotting functions
Le lundi 26 juin 2017 13:05:27 UTC+2, Fjordforsk A/S a écrit : > > Hello, I tried a different variant of the previous plot: > > def f(x,y): > return math.sqrt(2**3))*exp(-(x**2 + y**2) > P = plot3d(f,(-3,3),(-3,3), adaptive=True, color=rainbow(60, 'rgbtuple'), > max_bend=.1, max_depth=15) > P.show() > > however, this also does not show. > > Works for me, provided the parentheses in the definition of f are well placed: def f(x,y): return math.sqrt(2**3)*exp(-(x**2 + y**2)) Best wishes, Eric. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Plottig functions
Hi, Le lundi 26 juin 2017 12:31:44 UTC+2, Fjordforsk A/S a écrit : > > Hello, I am having trouble plotting this function: > > sage: plot3d((math.sqrt(2**3))*math.exp(-(x**2 + y**2)), (x, 0, 5 ), (y, > 0, 5)) > > > Do not use the exp from the math module, but directly Sage's function exp: plot3d((sqrt(2**3))*exp(-(x**2 + y**2)), (x, 0, 5 ), (y, 0, 5)) Best wishes, Eric. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Further on plotting functions
Hello, I tried a different variant of the previous plot: def f(x,y): return math.sqrt(2**3))*exp(-(x**2 + y**2) P = plot3d(f,(-3,3),(-3,3), adaptive=True, color=rainbow(60, 'rgbtuple'), max_bend=.1, max_depth=15) P.show() however, this also does not show. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Plottig functions
Hello, I am having trouble plotting this function: sage: plot3d((math.sqrt(2**3))*math.exp(-(x**2 + y**2)), (x, 0, 5 ), (y, 0, 5)) plot3d((math.sqrt(Integer(2)**Integer(3)))*math.exp(-(x**Integer(2) + y**Integer(2))), (x, Integer(0), Integer(5) ), (y, Integer(0), Integer(5))) /home/sem/SageMath/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.__float__ (/home/sem/SageMath/src/build/cythonized/sage/symbolic/expression.cpp:11265)() 1411 raise 1412 except TypeError: -> 1413 raise TypeError("unable to simplify to float approximation") 1414 return ret 1415 TypeError: unable to simplify to float approximation I can't find the error here. Can anyone help? Many Thanks! -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.