# Plotting Zeros of a Complex Variable

I'm trying to plot the zeros within a certain distance from the origin using Mathematica of a given function (in my case, partial sums of the Zeta Function). I've tried plugging in simple functions, such as 1+2^(-s), but the program keeps throwing an error (it won't even show a plot). I am a beginner with Mathematica; will someone explain how to perform the task at hand or point me to some examples?

I've found a few references, but they all seemed centered around learning the programming language as a whole. If possible, I want to avoid this for now and put it off until the summer when I'll have more time to sit down and play with it.

-
Could you please post your attempt ? – b.gatessucks Mar 10 '14 at 19:46
@b.gatessucks: Yes, but I'll need to wait until tomorrow. The code I used is on my office computer. Sorry for the inconvenience. – Clayton Mar 10 '14 at 19:48
Step-by-step; here, here, here, here, here or here – Sektor Mar 10 '14 at 20:00
The code I used is on my office computer You are saying you do not have GoToMyPc installed? (I hear this commerical ad on radio for gotomypc , the techguy show) and thought this is good time to say it :) – Nasser Mar 10 '14 at 20:44
– Artes Mar 10 '14 at 21:27

You can use Stan Wagon's FindRoots2D function for conveniently finding all zeros in a region. When using this function, you'll need to explicitly break the complex function into Re and Im parts and find the points where both are zero.

I'm going to give you an example that you can modify for your purposes. Make sure to evaluate the definition of FindRoot2D first.

Partial sums of the Riemann ζ are given by HarmonicNumber in Mathematica. As a beginner, be sure to always expand the Details section of documentation pages. There's a lot of important and useful information "hidden" there, for example every special function has a precise definition in this section.

Let's sum up to n:

n = 10;


Then the function is HarmonicNumber[n, x + I y]. Let's find its zeros (be sure to evaluate the definition from here first):

zeros = FindRoots2D[{Re[HarmonicNumber[n, x + I y]], Im[HarmonicNumber[n, x + I y]]}, {x, -4, 12}, {y, -12, 12}]


These are some colours from an old package I like to use:

mediumSeaGreen = RGBColor[0.235298, 0.702002, 0.443098];
violet = RGBColor[0.559999, 0.370006, 0.599994];
orangeRed = RGBColor[1., 0.270608, 0.];


Now let's plot the zeros, together with the contours of zero real and imaginary parts:

ContourPlot[{Re[HarmonicNumber[n, x + I y]] == 0, Im[HarmonicNumber[n, x + I y]] == 0}, {x, -4, 10}, {y, -12, 12},
MaxRecursion -> 3,  (* this is to make it smoother at the expense of more computation *)
ContourStyle -> {Directive[Thick, mediumSeaGreen], Directive[Thick, violet]}, (* this is to make it prettier *)
Epilog -> {PointSize[0.02], orangeRed, Point[zeros]} (* this is to plot the roots as big orange dots *)
]


The reason why I plotted the contours as well is that this FindRoots2D function also uses ContourPlot to come up with initial estimates for the roots, which it then improves using FindRoot.

You'll find all the functions and options I used in the documentation. This example is to show you how to put them together. Note: The things I put in Epilog are the same types of graphics primitives you can use in Graphics.

-
To begin with, I tried simply copying and pasting everything and running individually: I set n=10, copied the zeros formula, the colors, then the contour plot. My picture comes out similar to yours, but the zeros don't have the orange dots. To give you an idea, on page 4 of cecm.sfu.ca/personal/pborwein/PAPERS/P172.pdf is what I'm looking for. Sorry for the inconvenience; your answer seems superb! I have upvoted it because it gets me closer to where I want to be. – Clayton Mar 11 '14 at 16:24
@Clayton Did you evaluate the definition of FindRoots2D from the other post I linked to? – Szabolcs Mar 11 '14 at 16:28
You were right; I read over that part the first time. Sorry it took so long to reply. As I went to reply earlier, the computer had quite a few troubles. (It has cooled down; fine now :) ). – Clayton Mar 11 '14 at 18:54
@Clayton You can also use Reduce to find zeros, for example, Reduce[HarmonicFunction[3,s]==0 && Abs[s] < 50, s]. Reduce is supposed to be able to return all roots in the specified region (in other words: it's supposed to be able to prove that there are no other roots than what it returns). On the downside, Reduce will be both slow and might not work at all if n is large (in my example above it's only 3). This functionality of Reduce` is described here. – Szabolcs Mar 11 '14 at 22:52