After playing around with **SAGE-Math** over the last week I discovered that it is possible to plot complex-valued functions. Unfortunately complex functions are functions from $\mathbb{C}$ to $\mathbb{C}$ which means that unless you are pretty good at visualising things in four dimensions it can be tricky to visualise them. A function from $\mathbb{R}$ to $\mathbb{R}$ such as $y=x^{3}-5x^{2}+4x+14$, which is a function from a one-dimensional space to another one-dimensional space, can be displayed on the familiar two-dimensional $x$-$y$-axes as in the diagram below.

However, with a function from $\mathbb{C}$ to $\mathbb{C}$ we are taking points from a two-dimensional space to another two-dimensional space so we would need four dimensions to plot the graph of the function. I don’t know about you but I’ve never really got the hang of seeing things in four dimensions so we have to have a different way of displaying the data. **This is where SAGE comes in useful.**

Here is a plot of the function $f(z)=\dfrac{z^{2}}{1+z^{4}}$ that I put into SAGE to plot.

The code that I used to do this is surprisingly simple:

p = complex_plot(lambda z: (z^2)/(1+z^4), (-2, 2), (-2, 2));p

The plot shows what happens to each complex number after it has been transformed. **The colours in the plot correspond to different behaviours of the function.**

In the plot above, zero is the only point that is mapped by the function to zero – notice how the colours are quite dark near the origin; this means that these points are mapped to other points in the complex plane of small magnitudes. Darker colours correspond to points that are mapped to complex numbers of relatively small magnitudes and lighter shades represent points that are mapped to complex numbers of larger magnitudes. As you move out from the centre the colours become lighter and there are white spots at the points $\dfrac{1}{\sqrt{2}}(1+i), \dfrac{1}{\sqrt{2}}(1-i), \dfrac{1}{\sqrt{2}}(i-1), -\dfrac{1}{\sqrt{2}}(1+i)$ these are the singularities, or poles, of the function – these are the points that can be considered as being mapped to infinity.

The plot has a certain degree of symmetry – any points that are the same colour are mapped by the function to the same point. For example $z=1+\dfrac{3}{2}i$ and $z=-1-\dfrac{3}{2}i$ are mapped to the same point and are therefore the same colour on the plot. I’m sure that I will be able to use these plots in the future – here’s a few more that I managed to create of the functions $f(z)=\dfrac{\mathrm{sin}(3z)}{1+z^{4}},\; f(z)=z^{2}$ and $f(z)=\dfrac{z^{3}-3z^{2}+4}{z^{4}-2z^{2}+12}$