title: Plot a complex function in Mathematica
body: <p>How can I make a Mathematica graphics that copies the behaviour of <a href="https://doc.sagemath.org/html/en/reference/plotting/sage/plot/complex_plot.html" rel="nofollow noreferrer">complex_plot</a> in sage? i.e.</p>
  <blockquote>
  <p>... takes a complex function of one
  variable,  and plots output of the
  function over the specified xrange and
  yrange as demonstrated below. The
  magnitude of the output is indicated
  by the brightness (with zero being
  black and infinity being white) while
  the argument is represented by the hue
  (with red being positive real, and
  increasing through orange, yellow, ...
  as the argument increases).</p>
  </blockquote>
  <p>Here's an example (stolen from M. Hampton of <a href="http://neutraldrifts.blogspot.com/" rel="nofollow noreferrer">Neutral Drifts</a>) of the zeta function with overlayed contours of absolute value:</p>
  <p><img src="https://i.stack.imgur.com/83CFP.png" alt="zeta function complex_plot" /></p>
  <p>In the Mathematica documentation page <a href="http://reference.wolfram.com/mathematica/guide/FunctionsOfComplexVariables.html" rel="nofollow noreferrer">Functions Of Complex Variables</a> it says that you can visualize complex functions using <code>ContourPlot</code> and <code>DensityPlot</code> &quot;potentially coloring by phase&quot;. But the problem is in both types of plots, <code>ColorFunction</code> only takes a single variable equal to the contour or density at the point - so it seems impossible to make it colour the phase/argument while plotting the absolute value. Note that this is not a problem with <code>Plot3D</code> where all 3 parameters <code>(x,y,z)</code> get passed to <code>ColorFunction</code>.</p>
  <p>I know that there are other ways to visualize complex functions - such as the &quot;neat example&quot; in the <a href="http://reference.wolfram.com/mathematica/ref/Plot3D.html#347161167" rel="nofollow noreferrer">Plot3D docs</a>, but that's not what I want.</p>
  <p>Also, I do have <a href="https://stackoverflow.com/questions/5385103/plot-a-complex-function-in-mathematica/5386801#5386801">one solution below</a> (that has actually been used to generate some graphics used in Wikipedia), but it defines a fairly low level function, and I think that it should be possible with a high level function like <code>ContourPlot</code> or <code>DensityPlot</code>. Not that this should stop you from giving your favourite approach that uses a lower level construction!</p>
  <hr />
  <p><strong>Edit:</strong>  There were some nice articles by Michael Trott in the Mathematica journal on:<br />
  Visualizing Riemann surfaces <a href="http://library.wolfram.com/infocenter/Articles/3014/" rel="nofollow noreferrer">of algebraic functions</a>, <a href="http://library.wolfram.com/infocenter/Articles/901/" rel="nofollow noreferrer">IIa</a>, <a href="http://library.wolfram.com/infocenter/Articles/1987/" rel="nofollow noreferrer">IIb</a>, <a href="http://library.wolfram.com/infocenter/Articles/3900/" rel="nofollow noreferrer">IIc</a>, <a href="http://library.wolfram.com/infocenter/Articles/4556/" rel="nofollow noreferrer">IId</a>.<br />
  Visualizing Riemann surfaces <a href="http://library.wolfram.com/examples/riemannsurface/" rel="nofollow noreferrer">demo</a>.<br />
  <a href="http://www.mathematica-journal.com/issue/v10i4/Corner10-4.html" rel="nofollow noreferrer">The Return of Riemann surfaces (updates for Mma v6)</a></p>
  <p>Of course, Michael Trott wrote the <a href="http://www.mathematicaguidebooks.org/" rel="nofollow noreferrer">Mathematica guide books</a>, which contain many beautiful graphics, but seem to have fallen behind the accelerated Mathematica release schedule!</p>