Hi I am trying to use plot functions for the first time in sage - apologies if this is a dumb question for a change.
I have a square matrix M of fixed complex numbers which are then all multiplied by a different phase depending on which column they are in. (In the 2x2 example below M=[a,b;c,d] and column 1 is multiplied by exp(i*theta) and column 2 is multiplied by exp(i*phi) ). I then take another fixed matrix A away from M and take f=det(M-A).abs() as my output. I have explicitly written this formula for A = [1,1;0,0] below. So the function I would like to plot is f as a function of theta and phi (in this case). a = 1/2 b = - i/3 c = 1/4 d = i/5 theta, phi = var('theta,phi') f(theta,phi) = ( (a*exp(i*theta)-1)*d*exp(i*phi) - (b*exp(i*phi)-1)*c*exp(i*theta) ) . abs() plot3d(f, (theta,0,pi), (phi,0,pi)) No matter how I try to do this, even if I explicitly write out the complex conjugates of each element, I get what for me is a record-length screed of error stuff ending in 'TypeError: unable to coerce to a real number', originating in the command 'plot3d(...etc...)'. I have attached a text file with the full output of one of my attempts. I can see that in a way I am asking a lot of the interpreter; but then again I feel I have explicitly made the thing real by the time it gets to be an input for the plot3d function. Is there any way around this, or do I have to start writing complexes as a+bi etc and do it the hard way? Many thanks Gary -- 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 http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Traceback (most recent call last): theta, phi = var('theta,phi') File "", line 1, in <module> File "/tmp/tmpKH82DM/___code___.py", line 13, in <module> plot3d(f,(theta,_sage_const_0 ,pi),(phi,_sage_const_0 ,pi)) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/plot/plot3d/plot3d.py", line 840, in plot3d P=parametric_plot3d.parametric_plot3d((u,v,f), urange, vrange, **kwds) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_plot3d.py", line 513, in parametric_plot3d G = _parametric_plot3d_surface(f, urange, vrange, plot_points=plot_points, boundary_style=boundary_style, **kwds) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/plot/plot3d/parametric_plot3d.py", line 619, in _parametric_plot3d_surface g, ranges = setup_for_eval_on_grid(f, [urange,vrange], plot_points) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/plot/misc.py", line 148, in setup_for_eval_on_grid return fast_float(funcs, *vars,**options), [tuple(range+[range_step]) for range,range_step in zip(ranges, range_steps)] File "fast_eval.pyx", line 1357, in sage.ext.fast_eval.fast_float (sage/ext/fast_eval.c:9278) File "fast_eval.pyx", line 1372, in sage.ext.fast_eval.fast_float (sage/ext/fast_eval.c:9483) File "fast_callable.pyx", line 420, in sage.ext.fast_callable.fast_callable (sage/ext/fast_callable.c:3619) File "expression.pyx", line 8954, in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:36693) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1431, in fast_callable return FastCallableConverter(ex, etb)() File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 213, in __call__ return self.arithmetic(div, div.operator()) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in arithmetic return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in <lambda> return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "fast_callable.pyx", line 685, in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:5588) File "fast_callable.pyx", line 565, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4837) File "expression.pyx", line 8954, in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:36693) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1431, in fast_callable return FastCallableConverter(ex, etb)() File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 214, in __call__ return self.arithmetic(ex, operator) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in arithmetic return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in <lambda> return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "fast_callable.pyx", line 685, in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:5588) File "fast_callable.pyx", line 565, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4837) File "expression.pyx", line 8954, in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:36693) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1431, in fast_callable return FastCallableConverter(ex, etb)() File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 213, in __call__ return self.arithmetic(div, div.operator()) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in arithmetic return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in <lambda> return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "fast_callable.pyx", line 685, in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:5588) File "fast_callable.pyx", line 565, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4837) File "expression.pyx", line 8954, in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:36693) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1431, in fast_callable return FastCallableConverter(ex, etb)() File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 214, in __call__ return self.arithmetic(ex, operator) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in arithmetic return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in <lambda> return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "fast_callable.pyx", line 685, in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:5588) File "fast_callable.pyx", line 565, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4837) File "expression.pyx", line 8954, in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:36693) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1431, in fast_callable return FastCallableConverter(ex, etb)() File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 213, in __call__ return self.arithmetic(div, div.operator()) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in arithmetic return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in <lambda> return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "fast_callable.pyx", line 685, in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:5588) File "fast_callable.pyx", line 565, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4837) File "expression.pyx", line 8954, in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:36693) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1431, in fast_callable return FastCallableConverter(ex, etb)() File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 220, in __call__ return self.composition(ex, operator) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1409, in composition return self.etb.call(function, *ex.operands()) File "fast_callable.pyx", line 685, in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:5588) File "fast_callable.pyx", line 565, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4837) File "expression.pyx", line 8954, in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:36693) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1431, in fast_callable return FastCallableConverter(ex, etb)() File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 213, in __call__ return self.arithmetic(div, div.operator()) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in arithmetic return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1371, in <lambda> return reduce(lambda x,y: self.etb.call(operator, x,y), operands) File "fast_callable.pyx", line 685, in sage.ext.fast_callable.ExpressionTreeBuilder.call (sage/ext/fast_callable.c:5588) File "fast_callable.pyx", line 565, in sage.ext.fast_callable.ExpressionTreeBuilder.__call__ (sage/ext/fast_callable.c:4837) File "expression.pyx", line 8954, in sage.symbolic.expression.Expression._fast_callable_ (sage/symbolic/expression.cpp:36693) File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1431, in fast_callable return FastCallableConverter(ex, etb)() File "/home/sage/sage-5.7/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 204, in __call__ raise err TypeError: unable to coerce to a real number