A small Python script demonstrating how to use the mpmath library to numerically approximate a few nontrivial zeros of the Riemann zeta function on the critical line ((\mathrm{Re}(s) = 1/2)).
- Uses mpmath to evaluate (\zeta(s)) for complex (s).
- Demonstrates root-finding on the line (\mathrm{Re}(s) = 0.5).
- Illustrates how one might identify the imaginary part (t) such that (\zeta(0.5 + i,t) = 0).
- Educational example, not optimized for large-scale zero searches.
- Pipenv for virtual environment and dependency management.
- Basic Python 3 environment.
-
Clone or download this repository.
-
Navigate into the project folder (where
Pipfile
will reside once created). -
Create and activate a Pipenv environment:
pipenv --python 3.9 pipenv shell
Replace
3.9
with whatever version of Python 3 you prefer. -
Install the dependencies:
pipenv install mpmath
This will add
mpmath
to your Pipfile and lockfile.
Once inside the Pipenv shell, simply run:
python zeta_zeros.py
where zeta_zeros.py
is the Python script containing the code to:
- Define a function to locate zeros via
mp.findroot
. - Loop over a set of guesses and print out the approximate zero locations.
- Verify each zero is numerically close to 0 in value.
Example Output might look like:
Zero #1 near t = 14.134725141734693
zeta(0.5 + i*14.134725141734693) ≈ (-2.23e-22 + 1.01e-22j)
Zero #2 near t = 21.022039638771555
zeta(0.5 + i*21.022039638771555) ≈ (3.11e-24 + 8.12e-24j)
...
- Precision: By default,
mpmath
uses moderate precision (~15–16 digits). If you explore higher zeros or require more accuracy, increase the precision withmp.mp.prec = 200
(or higher). - Performance: This script is not optimized for large-scale searches. Real-world verification of zeros uses the Riemann–Siegel formula, Turing’s method, and other sophisticated techniques.
- No Guarantee of Missing/Extra Zeros: This simple approach checks around specific guesses and uses
mp.findroot
. A thorough sweep (Turing’s method) is required to ensure no zeros are missed in each interval.
This code is provided under an MIT License. Feel free to use or modify it for educational or personal research purposes.