# 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)?

edit retag close merge delete

Sort by » oldest newest most voted

There 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_...

more

Great, i did not know about that one ! For the other, which ticket is that ?

( 2017-12-05 04:44:28 -0500 )edit

No 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.

( 2017-12-05 11:30:39 -0500 )edit

@Emmanuel Charpentier, open the ticket anyway, and another ticket for documenting the features.

( 2017-12-06 02:07:43 -0500 )edit

Done : this is Trac#24335, depending on Trac#24331.

( 2017-12-07 04:14:18 -0500 )edit

There use to be a very nice gallery of examples of complex valued functions drawn using mpmath library 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/

more

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.

( 2017-12-05 11:31:05 -0500 )edit
1

Hi @Sébastien, the gallery is now back from brokenland, see http://mpmath.org/gallery/ -- it's a bit thanks to your answer, which prompted me to ask the mpmath list about the gallery, which made Fredrik Johansson revive it. Many thanks to Ask Sage, to @nebuckandazzer, to @Sébastien, to the mpmath list, and to Fredrik!

( 2017-12-06 08:25:44 -0500 )edit

That 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)?

( 2017-12-06 13:11:08 -0500 )edit

You 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])

more