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.Thu, 07 Dec 2017 11:14:18 +0100How to visualise complex functions on a disk?https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/Let $f$ be a function on the unit disk $\mathbb{D}$. I want to look at the images of $f(\mathbb{D})$?
How to do this?
How to see the contours of $|f(z)|$?
How to see the argument (if possible)?Mon, 04 Dec 2017 10:08:48 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/Answer by tmonteil for <p>Let $f$ be a function on the unit disk $\mathbb{D}$. I want to look at the images of $f(\mathbb{D})$?</p>
<p>How to do this?</p>
<p>How to see the contours of $|f(z)|$? </p>
<p>How to see the argument (if possible)?</p>
https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?answer=39940#post-id-39940You should give more details on how is your function defined, the answer depends on this. Let me assume that you have a symbolic function like:
f(x,y) = cos(x+I*y)
You can see its norm as follows:
plot3d(lambda x,y: abs(f(x,y)),[-5,5],[-1,1])
You can see its argument as follows (note that you will have a discontinuity at -pi=pi):
plot3d(lambda x,y: arg(f(x,y)),[-5,5],[-1,1])
Mon, 04 Dec 2017 10:54:30 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?answer=39940#post-id-39940Answer by Sébastien for <p>Let $f$ be a function on the unit disk $\mathbb{D}$. I want to look at the images of $f(\mathbb{D})$?</p>
<p>How to do this?</p>
<p>How to see the contours of $|f(z)|$? </p>
<p>How to see the argument (if possible)?</p>
https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?answer=39951#post-id-39951There use to be a [very nice gallery](http://mpmath.googlecode.com/svn/gallery/gallery.html) of examples of complex valued functions drawn using [mpmath library](http://docs.sympy.org/0.6.7/modules/mpmath/basics.html) available in Sage through SymPy, but it is too bad, the link is now broken. Maybe it can be restored by exporting the google code repository?
**UPDATE**: Thanks to Samuel Lelièvre and Fredrik Johansson, the gallery is back online: http://mpmath.org/gallery/Tue, 05 Dec 2017 14:38:15 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?answer=39951#post-id-39951Comment by Emmanuel Charpentier for <p>There use to be a <a href="http://mpmath.googlecode.com/svn/gallery/gallery.html">very nice gallery</a> of examples of complex valued functions drawn using <a href="http://docs.sympy.org/0.6.7/modules/mpmath/basics.html">mpmath library</a> available in Sage through SymPy, but it is too bad, the link is now broken. Maybe it can be restored by exporting the google code repository?</p>
<p><strong>UPDATE</strong>: Thanks to Samuel Lelièvre and Fredrik Johansson, the gallery is back online: <a href="http://mpmath.org/gallery/">http://mpmath.org/gallery/</a></p>
https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39954#post-id-39954```matplotlib``` graphs may be nice and come in handy. However, you have to be aware that they are not Sage "graphical objects" : you are on your own when it comes to using them.
Second point : the current 3D abilities of ```matplotlib``` are a bit limited. Especially, there is no, as far as I know, dynamic rendering, allowing scaling/rotation as allowed by the dynamic viewers used by Sage. What you get is a static image, similar to what Tachyon gives you.Tue, 05 Dec 2017 18:31:05 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39954#post-id-39954Comment by slelievre for <p>There use to be a <a href="http://mpmath.googlecode.com/svn/gallery/gallery.html">very nice gallery</a> of examples of complex valued functions drawn using <a href="http://docs.sympy.org/0.6.7/modules/mpmath/basics.html">mpmath library</a> available in Sage through SymPy, but it is too bad, the link is now broken. Maybe it can be restored by exporting the google code repository?</p>
<p><strong>UPDATE</strong>: Thanks to Samuel Lelièvre and Fredrik Johansson, the gallery is back online: <a href="http://mpmath.org/gallery/">http://mpmath.org/gallery/</a></p>
https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39971#post-id-39971Hi @Sébastien, the gallery is now back from brokenland, see
[http://mpmath.org/gallery/](http://mpmath.org/gallery/)
-- it's a bit thanks to your answer, which prompted me to
[ask the mpmath list about the gallery](https://groups.google.com/d/topic/mpmath/Yi8Pamc2T8g),
which made Fredrik Johansson revive it.
Many thanks to Ask Sage, to @nebuckandazzer, to @Sébastien, to the mpmath list, and to Fredrik!Wed, 06 Dec 2017 15:25:44 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39971#post-id-39971Comment by kcrisman for <p>There use to be a <a href="http://mpmath.googlecode.com/svn/gallery/gallery.html">very nice gallery</a> of examples of complex valued functions drawn using <a href="http://docs.sympy.org/0.6.7/modules/mpmath/basics.html">mpmath library</a> available in Sage through SymPy, but it is too bad, the link is now broken. Maybe it can be restored by exporting the google code repository?</p>
<p><strong>UPDATE</strong>: Thanks to Samuel Lelièvre and Fredrik Johansson, the gallery is back online: <a href="http://mpmath.org/gallery/">http://mpmath.org/gallery/</a></p>
https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39979#post-id-39979That is really sweet; if possible maybe it should be added to the Sage documentation as a link as well. Is it faster than `complex_plot` (I don't recall if that uses mpmath generically under the hood when possible)?Wed, 06 Dec 2017 20:11:08 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39979#post-id-39979Answer by Emmanuel Charpentier for <p>Let $f$ be a function on the unit disk $\mathbb{D}$. I want to look at the images of $f(\mathbb{D})$?</p>
<p>How to do this?</p>
<p>How to see the contours of $|f(z)|$? </p>
<p>How to see the argument (if possible)?</p>
https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?answer=39942#post-id-39942There is a nice ```complex_plot``` function which maps the argument of the function's value to the color of the representative point, and its modulus to tthe brightness. This may or may not be what you want.
Yon can also give a 3D representation using a colored 3D surface, mapping modulus to ```z``` and argument to color. The proble is, of course, what to do with poles ?
I have written this a couple times already, but not yet filed a ticket for that. If you're interested, I may post my code here, but don't expect miracles : it will be _s-l-o-w_...Mon, 04 Dec 2017 19:29:19 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?answer=39942#post-id-39942Comment by tmonteil for <p>There is a nice <code>complex_plot</code> function which maps the argument of the function's value to the color of the representative point, and its modulus to tthe brightness. This may or may not be what you want.</p>
<p>Yon can also give a 3D representation using a colored 3D surface, mapping modulus to <code>z</code> and argument to color. The proble is, of course, what to do with poles ?</p>
<p>I have written this a couple times already, but not yet filed a ticket for that. If you're interested, I may post my code here, but don't expect miracles : it will be _s-l-o-w_...</p>
https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39950#post-id-39950Great, i did not know about that one ! For the other, which ticket is that ?Tue, 05 Dec 2017 11:44:28 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39950#post-id-39950Comment by Emmanuel Charpentier for <p>There is a nice <code>complex_plot</code> function which maps the argument of the function's value to the color of the representative point, and its modulus to tthe brightness. This may or may not be what you want.</p>
<p>Yon can also give a 3D representation using a colored 3D surface, mapping modulus to <code>z</code> and argument to color. The proble is, of course, what to do with poles ?</p>
<p>I have written this a couple times already, but not yet filed a ticket for that. If you're interested, I may post my code here, but don't expect miracles : it will be _s-l-o-w_...</p>
https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39953#post-id-39953No ticket yet. I'll keep you posted here... But I already have my load of late tickets...
The problem is that 3D surface coloring and the ability to let "holes" in them are founded on _undocumented_ abilities of our 3D infrastructure. Writing new code using them is risky if those features remain undocumented.Tue, 05 Dec 2017 18:30:39 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39953#post-id-39953Comment by slelievre for <p>There is a nice <code>complex_plot</code> function which maps the argument of the function's value to the color of the representative point, and its modulus to tthe brightness. This may or may not be what you want.</p>
<p>Yon can also give a 3D representation using a colored 3D surface, mapping modulus to <code>z</code> and argument to color. The proble is, of course, what to do with poles ?</p>
<p>I have written this a couple times already, but not yet filed a ticket for that. If you're interested, I may post my code here, but don't expect miracles : it will be _s-l-o-w_...</p>
https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39969#post-id-39969@Emmanuel Charpentier, open the ticket anyway, and another ticket for documenting the features.Wed, 06 Dec 2017 09:07:43 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39969#post-id-39969Comment by Emmanuel Charpentier for <p>There is a nice <code>complex_plot</code> function which maps the argument of the function's value to the color of the representative point, and its modulus to tthe brightness. This may or may not be what you want.</p>
<p>Yon can also give a 3D representation using a colored 3D surface, mapping modulus to <code>z</code> and argument to color. The proble is, of course, what to do with poles ?</p>
<p>I have written this a couple times already, but not yet filed a ticket for that. If you're interested, I may post my code here, but don't expect miracles : it will be _s-l-o-w_...</p>
https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39991#post-id-39991Done : this is [Trac#24335](https://trac.sagemath.org/ticket/24335), depending on [Trac#24331](https://trac.sagemath.org/ticket/24331).Thu, 07 Dec 2017 11:14:18 +0100https://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/?comment=39991#post-id-39991