# Riemann Zeta function visualizations with Python

While playing with mpmpath and it’s Riemann Zeta function evaluator, I came upon those interesting animated plottings using Matplotlib (the source code is in the end of the post).

Riemann zeta function is an analytic function and is defined over the complex plane with one complex variable denoted as “$s$“. Riemann zeta is very important to mathematics due it’s deep relation with primes; the zeta function is given by:

$\zeta(s) = \sum_{n=1}^\infty \frac{1}{n^s} = \frac{1}{1^s} + \frac{1}{2^s} + \frac{1}{3^s} + \cdots$

for $Re(s) > 1$.

So, let $\zeta(s)=v$ where $s = a + b\imath$ and $v = u + k\imath$.

The first plot uses the triplet $(x,y,z)$ coordinates to plot a 3D space where each component is given by:

• $x = Re(v)$ (or $x = u$, previously defined);
• $y = Im(v)$ (or $y = k$, previously defined);
• $z = Im(s)$ (or $z = b$, previously defined);
• The time component used in the animation is called $\theta$ and it’s given by $\theta = Re(s)$ or simply $\theta = a$.

To plot the animation I’ve used the follow intervals:

• For $Re(s)$: from $\left[0.01, 10.0\right)$, this were calculated at every 0.01 step – shown in the plot at top right;
• For $Im(s)$: from $\left[0.1, 200.0\right)$, calculated at every 0.1 step – shown as the $z$ axis.

This plot were done using a fixed interval (no auto scale) for the $(x,y,z)$ coordinates. Where $Re(s) = 1/2$ ($\theta = 1/2$) is when the non-trivial zeroes of Riemann Zeta function lies.

Now see the same plot but this time using auto scale (automatically resized $x,y$ coordinates):

Note the $(x,y)$ auto scaling.

See now from another plotting using a 2D space where each component is given by:

• $x = Im(s)$ (or $x = b$, previously defined);
• $y = Im(v)$ (blue) and $Re(v)$ (green);
• The time component used in the animation is called $\theta$ and it’s given by $\theta = Re(s)$ or simply $\theta = a$.

To plot the animation I’ve used the follow intervals:

• For $Re(s)$: from $\left[0.01, 10.0\right)$, this were calculated at every 0.01 step – shown in title of the plot at top;
• For $Im(s)$: from $\left[0.1, 50.0\right)$, calculated at every 0.1 step – shown as the $x$ axis.

This plot were done using a fixed interval (no auto scale) for the $(x,y)$ coordinates. Where $Re(s) = 1/2$ ($\theta = 1/2$) is when the non-trivial zeroes of Riemann Zeta function lies. The first 10 non-trivial zeroes from Riemann Zeta function is shown as a red dot, when the two series, the $Im(v)$ and $Re(v)$ cross each other on the red dot at the critical line ($Re(s) = 1/2$) is where lies the zeroes of the Zeta Function, note how the real and imaginary part turns away from each other as the $Re(s)$ increases.

Now see the same plot but this time using auto scale (automatically resized $y$ coordinate):

If you are interested in more visualizations of Riemann Zeta function, you’ll like the well-done paper from J. Arias-de-Reyna called “X-Ray of Riemann zeta-function“.

I always liked the way visualization affects the understanding of math functions. Anscombe’s quartet is a clear example of how important visualization is.

The source-code used to create the plot are available here:

Source code for the 2D plots

Source code for the 3D plots

I hope you liked the post ! To make the plots and videos I’ve used matplotlib, mpmath and MEncoder.

– Christian S. Perone

## 8 thoughts to “Riemann Zeta function visualizations with Python”

1. HASSINE SAIDANE says:

Great stuff. I enjoyed it very much. Thank you.

PS. Since you have the programming and the computational capabilities, how would you like to do an extensive search for possible zeat zeros off the crotocal line, but at each imaginary value of the non trivial zeros on the critical line (already computed)? This will help prove or disprove the unresolved issue of the existence of zeta zeros that have the same imginary part as those on the critical line.

2. o0orako0o says:

This is wonderful!

4. JP says:

The quest for ‘what’s rrrreally goin’ on.’ Great stuff. Thank you for this.

5. Awesome post. Inspired by it, I used python code similar to yours to demonstrate how the Riemann-Siegel formula is a great approximation for the Riemann zeta function near the critical line but not away from it. Hence it is a good way for approximating the non-trivial zeros.

Check out the github…

https://github.com/danerf/Riemann-zeta

6. Cesar Cesgrav says:

Very good.

7. JJ says:

You are my hero

This site uses Akismet to reduce spam. Learn how your comment data is processed.