Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7073
| From | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Complex diagram |
| Date | 2011-12-10 12:31 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jbvjfi$iuv$1@smc.vnet.net> (permalink) |
| References | <jbni9o$48v$1@smc.vnet.net> <201112091056.FAA03855@smc.vnet.net> |
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@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@yahoo.com
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Complex diagram 道 厚 <shlwell1988@gmail.com> - 2011-12-07 11:22 +0000 Re: Complex diagram "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-12-08 10:23 +0000 Re: Complex diagram Chris Young <cy56@comcast.net> - 2011-12-08 10:30 +0000 Re: Complex diagram Simon <simonjtyler@gmail.com> - 2011-12-08 10:33 +0000 Re: Complex diagram Chris Young <cy56@comcast.net> - 2011-12-09 11:01 +0000 Re: Complex diagram DrMajorBob <btreat1@austin.rr.com> - 2011-12-10 12:31 +0000
csiph-web