Two complex color functions

Comments
Bookmark and Share

In the process of graphing some complex valued functions, I figured out a couple of neat coloring schemes that I thought might be worth sharing. Both schemes share the same hue and saturation functions:

$$H = \arg{z}-\frac{\pi}{2}$$
$$S = \abs{\frac{\imag{z}}{z}}$$

They differ in the third component, though. The one which I will arbitrarily designate “color scheme 1” (because I like it better) is defined in HSL color space, and has a luminosity function of

$$L = \frac{1}{2}\biggl[1 - 2^{20}\abs{S - \frac{1}{2}}^{20}\sgn\biggl(S - \frac{1}{2}\biggr)\biggr]$$

where \(S\) is the saturation value. This maps all real or nearly real numbers to white, all imaginary or nearly imaginary numbers to black, and other complex numbers to varying hues depending on their phase.

Illustration of color scheme 1
Illustration of color scheme 1

The other one, “color scheme 2,” has a value (brightness) function of

$$V = 1 - \frac{S}{4}$$

This maps all real or nearly real numbers to white, and all other numbers to varying hues, again depending on their phase. Positive imaginary numbers are red, negative imaginary numbers are cyan.

Illustration of color scheme 2
Illustration of color scheme 2

Note that both functions are undefined at \(z = 0\). If you implement these you’ll have to manually set that point to whatever color you want.

Complex-valued functions are pretty common in modern math and physics, but they’re hard to visualize: since both the input and output of the function are complex numbers, which have two independent components, you would need to make a four-dimensional graph to show the function properly. We typically get around this by plotting the absolute value of the complex function, and using color schemes like these to indicate the phase, when it’s important. The usefulness of these two is that they highlight the regions where the function being plotted is purely real, which is typically an interesting region to focus on.

Since I developed these in Mathematica, I’m attaching a Mathematica notebook containing a reference implementation.