I want to compute and plot $\Re(\zeta(x+iy)^2)$ and $\Im(\zeta(x+iy)^2)$. How can I do that with Mathematica?
2 Answers
Just use the corresponding commands. They are like the ones you have used, but with Capitals. Mathematica functions have square brackets. I can use these commands to define two functions
realpart[x_, y_] = Re[(Zeta[x + \[ImaginaryJ] y])^2];
imagpart[x_, y_] = Im[(Zeta[x + \[ImaginaryJ] y])^2];
And then I can plot the result
ContourPlot[realpart[x, y], {x, -1, 1}, {y, -1, 1}]
ContourPlot[imagpart[x, y], {x, -1, 1}, {y, -1, 1}]
Or more nicely using some Options and adding a Legend
ContourPlot[realpart[x, y], {x, -1, 1}, {y, -1, 1}, LabelStyle -> 15, FrameLabel -> {"x", "y"}, Contours -> 15, PlotRange -> {All, All, {-15, 15}}, PlotLegends -> Automatic]
ContourPlot[imagpart[x, y], {x, -1, 1}, {y, -1, 1}, LabelStyle -> 15, FrameLabel -> {"x", "y"}, Contours -> 15, PlotRange -> {Automatic, Automatic, {-15, 15}}, PlotLegends -> Automatic]
Which will look like:
Why should one have to explicitly break apart a complex-valued function of a complex variable into its real and imaginary parts just to do plotting, when Mathematica already is so adept at calculating directly with complex numbers? In fact, you don't: you could use David Park's Presentations add-on (http://home.comcast.net/~djmpark/DrawGraphicsPage.html), as follows.
Column[{
Draw2D[
{
ComplexCartesianContour[Zeta[z]^2, {z, -1 - I, 1 + I}, Re,
Contours -> 23]
},
Frame -> True, FrameLabel -> {Re[z], Im[z]}, RotateLabel -> False,
PlotLabel -> Row[{"Real part of ", Zeta[z]^2}], BaseStyle -> 12,
AspectRatio -> 1, ImageSize -> Scaled[0.5]],
Draw2D[
{
ComplexCartesianContour[Zeta[z]^2, {z, -1 - I, 1 + I}, Im,
Contours -> 23]
},
Frame -> True, FrameLabel -> {Re[z], Im[z]}, RotateLabel -> False,
PlotLabel -> Row[{"Imaginary part of ", Zeta[z]^2}],
BaseStyle -> 12, AspectRatio -> 1, ImageSize -> Scaled[0.5]]
}]