[ACCEPTED]-Plot a complex function in Mathematica-complex-numbers
Here's my attempt. I winged the color function 4 a bit.
ParametricPlot[
(*just need a vis function that will allow x and y to be in the color function*)
{x, y}, {x, -6, 3}, {y, -3, 3},
(*color and mesh functions don't trigger refinement, so just use a big grid*)
PlotPoints -> 50, MaxRecursion -> 0, Mesh -> 50,
(*turn off scaling so we can do computations with the actual complex values*)
ColorFunctionScaling -> False,
ColorFunction -> (Hue[
(*hue according to argument, with shift so arg(z)==0 is red*)
Rescale[Arg[Zeta[# + I #2]], {-Pi, Pi}, {0, 1} + 0.5], 1,
(*fudge brightness a bit:
0.1 keeps things from getting too dark,
2 forces some actual bright areas*)
Rescale[Log[Abs[Zeta[# + I #2]]], {-Infinity, Infinity}, {0.1, 2}]] &),
(*mesh lines according to magnitude, scaled to avoid the pole at z=1*)
MeshFunctions -> {Log[Abs[Zeta[#1 + I #2]]] &},
(*turn off axes, because I don't like them with frames*)
Axes -> False
]
I haven't thought of a good way to 3 get the mesh lines to vary in color. Easiest 2 is probably to just generate them with ContourPlot
instead 1 of MeshFunctions
.
Here's my variation on the function given 7 by Axel Boldt who was inspired by Jan Homann. Both of the linked 6 to pages have some nice graphics.
ComplexGraph[f_, {xmin_, xmax_}, {ymin_, ymax_}, opts:OptionsPattern[]] :=
RegionPlot[True, {x, xmin, xmax}, {y, ymin, ymax}, opts,
PlotPoints -> 100, ColorFunctionScaling -> False,
ColorFunction -> Function[{x, y}, With[{ff = f[x + I y]},
Hue[(2. Pi)^-1 Mod[Arg[ff], 2 Pi], 1, 1 - (1.2 + 10 Log[Abs[ff] + 1])^-1]]]
]
Then we 5 can make the plot without the contours by 4 running
ComplexGraph[Zeta, {-7, 3}, {-3, 3}]
We can add contours by either copying 3 Brett by using and showing a specific plot mesh 2 in the ComplexGraph:
ComplexGraph[Zeta, {-7, 3}, {-3, 3}, Mesh -> 30,
MeshFunctions -> {Log[Abs[Zeta[#1 + I #2]]] &},
MeshStyle -> {{Thin, Black}, None}, MaxRecursion -> 0]
or by combining with 1 a contour plot like
ContourPlot[Abs[Zeta[x + I y]], {x, -7, 3}, {y, -3, 3}, PlotPoints -> 100,
Contours -> Exp@Range[-7, 1, .25], ContourShading -> None];
Show[{ComplexGraph[Zeta, {-7, 3}, {-3, 3}],%}]
Not a proper answer, for two reasons:
- This is not what you asked for
- I'm shamelessly using Brett's code
Anyway, for 3 me the following is much more clear to interpret 2 (brightness is ... well, just brightness):
Brett's 1 code almost intact:
Plot3D[
Log[Abs[Zeta[x + I y]]], {x, -6, 3}, {y, -3, 3},
(*color and mesh functions don't trigger refinement,so just use a big grid*)
PlotPoints -> 50, MaxRecursion -> 0,
Mesh -> 50,
(*turn off scaling so we can do computations with the actual complex values*)
ColorFunctionScaling -> False,
ColorFunction -> (Hue[
(*hue according to argument,with shift so arg(z)==0 is red*)
Rescale[Arg[Zeta[# + I #2]], {-Pi, Pi}, {0, 1} + 0.5],
1,(*fudge brightness a bit:
0.1 keeps things from getting too dark,
2 forces some actual bright areas*)
Rescale[Log[Abs[Zeta[# + I #2]]], {-Infinity, Infinity}, {0.1, 2}]] &),
(*mesh lines according to magnitude,scaled to avoid the pole at z=1*)
MeshFunctions -> {Log[Abs[Zeta[#1 + I #2]]] &},
(*turn off axes,because I don't like them with frames*)
Axes -> False]
For everyone interested in achieving this 2 in Python, I created cplot. Install with
pip install cplot
This plots 1 the domain-coloring plot of the Taylor polynomial of degree 7 of exp:
import cplot
def exp_taylor(z):
s = 1.0
t = 1.0
for k in range(1, 7):
t *= z / k
s += t
return s
plt = cplot.plot(
exp_taylor,
# or something simpler
# lambda z: z ** 6 + 1,
(-5, +5, 400),
(-5, +5, 400),
)
plt.show()
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.