Mathematica Version 6 Compatibility Information
(continued)

This notebook continues Chapter by Chapter observations. Don't forget to look at the introduction in the first notebook!

7 Symmetric chaos in the complex plane

7.2 \[MathematicaIcon] A movie of a symmetry-increasing bifurcation

This is almost just a case of replacing Do by Manipulate. Here there are are some embedded semi-colons which also need deleting! You need to load makedata and MakeMap from earlier in Chapter 7, then execute the following.

MakeMap[λ_, α_, β_, γ_, m_, ω_:0, δ_:0, p_:1] = 
Compile[{{z, _Complex}},
((λ + α*z*Conjugate[z] + β*Re[z^m] + δ*Abs[z]*Cos[Arg[z]*m*p] + I ω)*z + 
γ*Conjugate[z]^(m-1))];

makedata[func_, n_] := 
Module[{start=Nest[func, 0.5+0.5I,2000]},
NestList[func,start,n]];

ScaledSymChaos[myfunc_, n_, color_, size_, range_:1]:=
Module[{data},
data = makedata[myfunc,n];
ListPlot[Map[{Im[#],Re[#]}&, data],
PlotStyle -> {PointSize[size],color},  
AspectRatio -> 1, Axes -> None,
PlotRange -> {{-range, range},{-range, range}}]]

Manipulate[
(tri = MakeMap[2.16+0.005*k,-1.0, 0.0,-0.5, 3];
frame[k] = ScaledSymChaos[tri, 2000, RGBColor[0,0,1], 0.01, 2.0]),{k, 0, 35},
SaveDefinitions -> True]

8 Complex functions

8.5 \[MathematicaIcon] Branch points and cuts

This is a good point to go into a subtle change to the way Plot3D works. The amount of meshing on the surface has been separated from the number of points used to plot the surface. Previously, in 5.2 or before, the meshing would be implied by the value of PlotPoints. Now it needs to be specified separately. This is a good thing as you can more easily get a finely calculated surface without it being obliterated by the mesh. The lighting model has been changed slightly as well, but this is not a big deal. So here is perhaps a better version of the first graphic — you might like to experiment with the other plots.

Plot3D[Im[Sqrt[(x + I y)]], {x, -3, 3}, {y, -3, 3},
		PlotPoints -> 40, Mesh -> 30]

Note that the system now locates the branch cuts!!

8.7 \[MathematicaIcon] Visualization of complex functions

This is a good point to explain one side-effect of the nice new rendering features in the front ends. You might find that very thin lines, that you have set in order to produce fine detailed hard copy, might almost disappear in the front end. This is because the front end appears to use grey shade based on the proportion of the pixels that are occupied. 

One point that you should note is that the ComplexMap package is now obsolete as there are enhancements to ParametricPlot that deal with complex maps. You can see some examples if you click on the compatibility guide link that comes up below.

Needs["Graphics`ComplexMap`"]

This last command will complain but works fine!

SetOptions[ParametricPlot, PlotStyle -> AbsoluteThickness[0.1]];

CartesianMap[Sin, {-2, 2, 0.1}, {-2, 2, 0.1}, PlotRange -> All, PlotPoints -> 60]

Try executing the following for contrast.

SetOptions[ParametricPlot, PlotStyle -> AbsoluteThickness[1]];

CartesianMap[Sin, {-2, 2, 0.1}, {-2, 2, 0.1}, PlotRange -> All, PlotPoints -> 60]

In the book I tried to use compromise settings that produced reasonable hard copy and reasonable on screen display. You might find for your own purposes that you want to produce two versions.

If you want to make the code version 6 native, and give up compatibility with earlier versions, here is the new way of making these plots:

ParametricPlot[Through[{Re, Im}[Sin[x+ I*y]]], {x, -2, 2}, {y, -2, 2}, PlotRange -> All, PlotPoints -> 60]

8.8 \[MathematicaIcon] Three-dimensional views of a complex function

The way colouring works with Plot3D has also been changed along lines similar to those already discussed for ParametricPlot3D. The definition of ComplexPlot3D, that uses the phase of the function to colour the surface, therefore needs a little modification. Here is the M6 version:

Unprotect[Arg];Arg[0] = 0 ;

ComplexPlot3D[func_, xrange_, yrange_, options___] :=
Plot3D[Abs[func[x + I y]],xrange, yrange, options, ColorFunction ->  (Hue[N[(Pi+Arg[func[#1 + I #2]])/(2 Pi)]]&),
ColorFunctionScaling -> False]

This works fine with the examples for sine and gamma — here is the sine plot.

ComplexPlot3D[Sin, {x, -2, 2}, {y, -2, 2},
	PlotPoints -> 30, Mesh -> False, FaceGrids -> All]

At the time of writing this function was still behaving somewhat inconsistently with pure functions in my test copy of M6, but I was also having problems with my keyboard mapping and am not completely confident that # is behaving as it should. Also the kernel was being a little forgetful about remembering functions. It is reliable, however, to first define the function and then use it:

myfunc[z_] := Exp[-z^2]*Erfc[-I*z]

ComplexPlot3D[myfunc, {x, -2, 2}, {y, -2, 2},PlotPoints -> 30, Mesh -> False, FaceGrids -> All,
	ViewPoint -> {2,2,1}, PlotRange -> All]

Alternative routines

These need a similar modification to the colouring algorithm:

Whacky[x_] := If[EvenQ[Floor[x]], RGBColor[0,0,0], RGBColor[1,1,1]]

WhackyComplexPlot3D[{func_,  levels_}, xrange_, yrange_, options___] :=
Plot3D[Abs[func[x + I y]],xrange, yrange, options, ColorFunction ->  (Whacky[N[levels*(Pi+Arg[func[#1 + I #2]])/(2 Pi)]]&),
ColorFunctionScaling -> False]

The lighting has also been modified. It is a bad idea to turn it off as the graphics now disappear completely. If you object to the blue tinge to the following you might like to fiddle with the lighting. I have not been able to get rid of the blue tinge a the time of final editing despite making all the light sources white. (Possible bug)

WhackyComplexPlot3D[{Sin, 20}, {x, -2, 2}, {y, -2, 2},PlotPoints -> 100, Mesh -> False, PlotRange -> All, ViewPoint -> {2, 2, 4}]

I am having similar problems with the pure function deployment, as above.

8.9 \[MathematicaIcon] Holey and checkerboard plots

This works fine if you delete the Lighting control.

HoleyPlot3D[{f_,g_,h_},{u_,v_},{c_,d_},{n_,m_},
{cola_}, opts___] := 
Module[{data, plotdata},
data = Table[N[Through[{f, g, h}
[u+x*(v-u)/(n-1),c+y*(d-c)/(m-1)]]],
{x,0,n-1},{y,0,m-1}];
plotdata = Table[{cola,
Polygon[{data[[x,y]],data[[x+1,y]],
data[[x+1,y+1]],data[[x,y+1]]}]},
{x,1,n-1},{y,If[EvenQ[x], 2, 1],m-1, 2}];
Show[Graphics3D[plotdata], opts, Boxed -> False]]

The colour directive you supply can take a fourth parameter that is the opacity. Here is a green figure with the transparency turned on:

HoleyPlot3D[{((#1)*Cos[#2]&),((#1)*Sin[#2]&), 
((#1)^(1/4)*Cos[(#2)/4]&)},
{0.01,1},{0, 8 Pi},{15,120}, {RGBColor[0,1,0,0.5]}, ViewPoint -> {-3, -3, 0}]

By filling in a second colour rather than a hole we obtain the following:

ChekerPlot3D[{f_,g_,h_},{u_,v_},{c_,d_},{n_,m_},
{cola_, colb_}, opts___] := 
Module[{data, plotdata},
data = Table[N[Through[{f, g, h}
[u+x*(v-u)/(n-1),c+y*(d-c)/(m-1)]]],
{x,0,n-1},{y,0,m-1}];
plotdata = Table[{If[EvenQ[x+y], cola, colb],
Polygon[{data[[x,y]],data[[x+1,y]],
data[[x+1,y+1]],data[[x,y+1]]}]},
{x,1,n-1},{y,1, m-1}];
Show[Graphics3D[plotdata], opts, Boxed -> False]]

Here is a filled-in checkerboard plot of the (real part of the) cube root function, this time with a transparent grey in the second slot. This is also a really good place to try out real time rotation!

ChekerPlot3D[{((#1)*Cos[#2]&),((#1)*Sin[#2]&), 
((#1)^(1/3)*Cos[(#2)/3]&)},
{0.01,1},{0, 6 Pi},{15,120}, {RGBColor[1,1,0], RGBColor[0, 0, 0, 0.5]},
ViewPoint -> {-3, -3, 0}]

Astute readers will note that we really only need the second function now, because zero opacity is as good as a hole!