ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 05 Apr 2017 14:12:00 +0200complex numbers and parametric curveshttps://ask.sagemath.org/question/8739/complex-numbers-and-parametric-curves/I would like to be able to plot a 2d parametric plot of zeta(t+I), -2 <= t <= 2, where I is the square root of -1.
But complex numbers and parametric plots seem to barf at each other.
I tried many variants of the following code:
parametric_plot( (zeta(t+I).real(), zeta(t +I).imag()), (t, -2, 2))
But I get the following kind of response:
TypeError: Unable to convert 1.00000000000000*I to float; use abs() or
real_part() as desired
Sun, 26 Feb 2012 04:09:02 +0100https://ask.sagemath.org/question/8739/complex-numbers-and-parametric-curves/Answer by imarobot for <p>I would like to be able to plot a 2d parametric plot of zeta(t+I), -2 <= t <= 2, where I is the square root of -1. </p>
<p>But complex numbers and parametric plots seem to barf at each other. </p>
<p>I tried many variants of the following code:</p>
<p>parametric_plot( (zeta(t+I).real(), zeta(t +I).imag()), (t, -2, 2))</p>
<p>But I get the following kind of response:</p>
<p>TypeError: Unable to convert 1.00000000000000*I to float; use abs() or
real_part() as desired</p>
https://ask.sagemath.org/question/8739/complex-numbers-and-parametric-curves/?answer=37176#post-id-37176I cannot say for sure because I haven't check that but using line is not equivalent to using parametric_plot as I would expect parametric_plot to use finer drawing techniques than just a collection of connected lines.
You could the 'lambda trick' use instead :
parametric_plot ((lambda t : zeta (I + t) . real (), lambda t : zeta (I + t) . imag ()), (t, -2 , 2))
The drawback is that this computes the value of the function twice which isn't very elegant.
The lambda trick is necessary every time you need to use a complex function with drawing/solving equations with sage. This is possible that optimization techniques relying on formal expression expect these expressions to be real valued.Wed, 05 Apr 2017 14:12:00 +0200https://ask.sagemath.org/question/8739/complex-numbers-and-parametric-curves/?answer=37176#post-id-37176Answer by achrzesz for <p>I would like to be able to plot a 2d parametric plot of zeta(t+I), -2 <= t <= 2, where I is the square root of -1. </p>
<p>But complex numbers and parametric plots seem to barf at each other. </p>
<p>I tried many variants of the following code:</p>
<p>parametric_plot( (zeta(t+I).real(), zeta(t +I).imag()), (t, -2, 2))</p>
<p>But I get the following kind of response:</p>
<p>TypeError: Unable to convert 1.00000000000000*I to float; use abs() or
real_part() as desired</p>
https://ask.sagemath.org/question/8739/complex-numbers-and-parametric-curves/?answer=13303#post-id-13303sage: line([zeta(I + t) for t in srange(-2,2,0.1)])
http://www.sagemath.org/doc/reference/sage/plot/plot.html
http://www.sagemath.org/doc/constructions/plotting.html
http://www.sagemath.org/doc/reference/sage/plot/complex_plot.htmlSun, 26 Feb 2012 08:27:58 +0100https://ask.sagemath.org/question/8739/complex-numbers-and-parametric-curves/?answer=13303#post-id-13303Comment by bbartlett for <p>sage: line([zeta(I + t) for t in srange(-2,2,0.1)]) </p>
<p><a href="http://www.sagemath.org/doc/reference/sage/plot/plot.html">http://www.sagemath.org/doc/reference...</a></p>
<p><a href="http://www.sagemath.org/doc/constructions/plotting.html">http://www.sagemath.org/doc/construct...</a></p>
<p><a href="http://www.sagemath.org/doc/reference/sage/plot/complex_plot.html">http://www.sagemath.org/doc/reference...</a></p>
https://ask.sagemath.org/question/8739/complex-numbers-and-parametric-curves/?comment=20207#post-id-20207Ok, thank you. But this shows that parametric_plot doesn't work very well...?Tue, 28 Feb 2012 05:39:24 +0100https://ask.sagemath.org/question/8739/complex-numbers-and-parametric-curves/?comment=20207#post-id-20207