2
$\begingroup$

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.

$\endgroup$
5

1 Answer 1

10
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ 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. $\endgroup$
    – Clayton
    Commented Mar 11, 2014 at 16:24
  • $\begingroup$ @Clayton Did you evaluate the definition of FindRoots2D from the other post I linked to? $\endgroup$
    – Szabolcs
    Commented Mar 11, 2014 at 16:28
  • $\begingroup$ 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 :) ). $\endgroup$
    – Clayton
    Commented Mar 11, 2014 at 18:54
  • $\begingroup$ @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. $\endgroup$
    – Szabolcs
    Commented Mar 11, 2014 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.