I have gotten into the habit of plotting complex-valued functions on a plane using a color-function along the lines of
Function[{z}, Hue[Arg[z]/(2 π), 1, Abs[z]]].
For example, the following code generates an interesting image of the sum of 5 spherical wave sources (without 1/r decay included):
i = 130;
ω = 2.0 π i/50;
n = 5;
L1 = 3.0 - δ/2;
L2 = 4.0 - δ/2;
δ = 0.01;
f = Compile[{{x, _Real}, {y, _Real}},
Evaluate[Sum[Exp[ω I Sqrt[(x - 1.0 Cos[θ])^2 + (y -
1.0 Sin[θ])^2]], {θ, 2 π/n, 2 π,
2 π/n}]]];
ArrayPlot[
Table[f[x, y], {x, -L1, L1, δ}, {y, -L2, L2, δ}],
Frame -> False,
ColorFunction -> Function[{z}, Hue[Arg[z]/(2 π), 1, Abs[z/2]]],
ColorFunctionScaling -> False, PixelConstrained -> {1, 1}]

I have two questions. The second is a little more important than the first.
Exchanging
ArrayPlotwithListDensityPlotin the above example either simply yields a blank image or flat-out crashes my MathKernel. I believe this is becauseListDensityPlotsees the complex-valued array, freaks out because they're not real, and spits out a blank plot even though it has a user-supplied color-function for handling the complex entries of the array. Is there any way of gettingListDensityPlotto properly use this color-function?The example I gave above is pretty slow. The construction of the array alone takes 1.26 seconds on my machine, whereas the displaying of the code cited above takes 10.27 seconds (it's just an 800 by 600 pixel plot). Replacing the phase-amplitude
ColorFunctionI used above with the built-in functionGrayLevel(and applyingAbsto the array) gives a timing of 2.43 seconds, and using the defaultArrayPlotscheme by removing the references toColorFunctionaltogether executes in 1.52 seconds. Subtracting the time to build the array itself, the phase-amplitude color function generates a plot in 9.01 seconds,GrayLevelexecutes in 1.17 seconds, and the default scheme executes in 0.26 seconds. I am attempting to generate a movie, and 10 seconds to generate each frame is a bit on the slow side. Is there a way to compile this color function to make it run as fast as default, or perhaps as fast asGrayLevel?
For reference purposes, I am running on a 2008 Penryn Dual-Core MacBook and Mathematica 9.0.


