Re: Complex diagram
- To: mathgroup at smc.vnet.net
- Subject: [mg123521] Re: Complex diagram
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Sat, 10 Dec 2011 07:27:38 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jbni9o$48v$1@smc.vnet.net> <201112091056.FAA03855@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
I would use Set, not SetDelayed, and pre-compute Arg and Abs where possible: Clear[f, abs, arg, simple] simple[expr_] := ComplexExpand@FullSimplify[expr, {-Pi < x < Pi, -Pi > y < Pi}]; f[1][x_, y_] = x + I y; f[2][x_, y_] = 3 x + 2 y I; f[3][x_, y_] = Cos[x + I y] // simple; f[4][x_, y_] = Sin[x + I y] // simple; f[5][x_, y_] = (x + I y)^2 // simple; f[6][x_, y_] = (3 x + 2 y I)^2 // simple; f[7][x_, y_] = Cosh[x + I y] // simple; f[8][x_, y_] = Sinh[x + I y] // simple; Do[abs[k][x_, y_] = f[k][x, y] // Abs // simple; arg[k][x_, y_] = f[k][x, y] // Arg // simple, {k, 1, 8}] GraphicsGrid[ Partition[ Table[Plot3D[abs[k][x, y], {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]}, AxesLabel -> {"x", "y", "z"}, PlotRange -> {{-\[Pi], \[Pi]}, {-\[Pi], \[Pi]}, {0, 2 \[Pi]}}, PlotPoints -> 80, MaxRecursion -> 2, BoxRatios -> 1, Mesh -> 11, MeshFunctions -> {({x, y} \[Function] abs[k][x, y]), ({x, y} \[Function] arg[k][x, y])}, ColorFunctionScaling -> False, ColorFunction -> ({x, y} \[Function] Hue[\[LeftFloor]12 (arg[k][x, y] + \[Pi])/(2 \[Pi])\[RightFloor]/12, 0.5, 1])], {k, 1, 8}], 2], ImageSize -> 72*16] I can't say the speed improvement is tremendous, however! Bobby On Fri, 09 Dec 2011 04:56:35 -0600, Chris Young <cy56 at comcast.net> wrote: > On 2011-12-07 11:22:32 +0000, é�â?? 厚 said: > >> Can we draw complex funtions's diagram in Mathematica? >> >> For example, draw the picture of z=2*x+I*3*y > > Finally got something fast and sharp for complex functions, using > Plot3D and a stepped color function. The trick is to remember that the > number of mesh lines is one less than the number of contours. Only then > will the colors be correspond to the mesh, and, for some reason, > they're more sharply discretized. > > http://home.comcast.net/~cy56/Sharp3DComplexPlots.nb > http://home.comcast.net/~cy56/Sharp3DComplexPlots.png > > f[1][z_] := z; > f[2][z_] := 3 Re[z] + 2 Im[z] I; > f[3][z_] := Cos[z]; > f[4][z_] := Sin[z]; > > f[5][z_] := z^2; > f[6][z_] := (3 Re[z] + 2 Im[z] I)^2; > f[7][z_] := Cosh[z]; > f[8][z_] := Sinh[z]; > > GraphicsGrid[ > Partition[ > Table[ > Plot3D[ > Abs[f[k][x + y I]], > > {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]}, > > AxesLabel -> {"x", "y", "z"}, > PlotRange -> {{-\[Pi], \[Pi]}, {-\[Pi], \[Pi]}, {0, 2 \[Pi]}}, > PlotPoints -> 80, > MaxRecursion -> 2, > BoxRatios -> 1, > Mesh -> 11, > MeshFunctions -> { > ( {x, y} \[Function] Abs[f[k][x + y I]]), > ( {x, y} \[Function] Arg[f[k][x + y I]]) > }, > ColorFunctionScaling -> False, > ColorFunction -> ({x, y} \[Function] > Hue[\[LeftFloor]12 (Arg[f[k][x + y I]] + \[Pi])/( > 2 \[Pi])\[RightFloor]/12, 0.5, 1]) > ], > {k, 1, 8} > ], > 4 > ], > ImageSize -> 72*16 > ] > > > For 2D, ContourPlot works best, with the modulus contours drawn in via > a mesh function. Only one problem, the Sinh function is coming in at > lower resolution than the others for some reason. > > http://home.comcast.net/~cy56/Sharp2DComplexPlots.nb > http://home.comcast.net/~cy56/Sharp2DComplexPlots.png > > f[1][z_] := z; > f[2][z_] := 3 Re[z] + 2 Im[z] I; > f[3][z_] := Cos[z]; > f[4][z_] := Sin[z]; > > f[5][z_] := z^2; > f[6][z_] := (3 Re[z] + 2 Im[z] I)^2; > f[7][z_] := Cosh[z]; > f[8][z_] := Sinh[z]; > > GraphicsGrid[ > Partition[ > Table[ > ContourPlot[ > Arg[f[k][x + y I]], {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]}, > > Contours -> 11, > > ColorFunctionScaling -> False, > ColorFunction -> (arg \[Function] > Hue[0.9 (arg + \[Pi])/(2 \[Pi]), 0.5, 1]), > > Mesh -> 11, > MeshFunctions -> ( {x, y} \[Function] Abs[f[k][x + y I]]), > > PlotRange -> {{-\[Pi], \[Pi]}, {-\[Pi], \[Pi]}}, > PlotPoints -> 40, > MaxRecursion -> 2, > BoxRatios -> 1 > ], > {k, 1, 8} > ], > 4 > ], > ImageSize -> 72*16 > ] > > -- DrMajorBob at yahoo.com
- References:
- Re: Complex diagram
- From: Chris Young <cy56@comcast.net>
- Re: Complex diagram