A Numerical Deep Dive
Dirichlet L-functions are among the most beautiful objects in analytic number theory. In this post, we’ll explore a concrete minimization problem involving them, then solve it numerically with Python — complete with 2D and 3D visualizations.
What is a Dirichlet L-function?
For a Dirichlet character $\chi$ modulo $q$, the associated L-function is defined as:
$$L(s, \chi) = \sum_{n=1}^{\infty} \frac{\chi(n)}{n^s}, \quad \text{Re}(s) > 1$$
It extends analytically to the whole complex plane (for non-principal $\chi$). On the critical line $s = \frac{1}{2} + it$, $L(s,\chi)$ is complex-valued. The modulus $|L(\frac{1}{2}+it, \chi)|$ is real and non-negative, and finding its minima is a central topic in analytic number theory.
The Problem
Problem statement: For the non-principal Dirichlet character $\chi_4$ modulo $4$ (the unique non-trivial character mod 4), defined by:
$$\chi_4(n) = \begin{cases} 1 & n \equiv 1 \pmod{4} \ -1 & n \equiv 3 \pmod{4} \ 0 & 2 \mid n \end{cases}$$
find the local minima of $|L(\tfrac{1}{2}+it, \chi_4)|$ for $t \in [0, 50]$, and also visualize $|L(\sigma + it, \chi_4)|$ in the region $\sigma \in [0.2, 1.2]$, $t \in [0, 30]$.
This is related to the Generalized Riemann Hypothesis (GRH), which asserts that all nontrivial zeros lie on the critical line $\sigma = \frac{1}{2}$. Zeros of $L(s,\chi)$ on the critical line correspond to exact minima of $|L(\frac{1}{2}+it,\chi)|$ reaching zero.
The Code
1 | # ============================================================ |
Code Walkthrough
Step 1 — Character Definition
The function chi4(n) implements $\chi_4$ by reducing $n \bmod 4$. Only odd $n$ contribute: $n \equiv 1 \pmod{4}$ gives $+1$, while $n \equiv 3 \pmod{4}$ gives $-1$.
Step 2 — Vectorized Partial Sum
The function L_chi4(s_array, N) is the core engine. Since $\chi_4(n) = 0$ for even $n$, we sum only over odd integers $n = 1, 3, 5, \ldots$ up to $2N-1$. The trick is using np.outer to compute the matrix of $n^{-s}$ for all $n$ and all $s$ simultaneously:
$$L(s, \chi_4) \approx \sum_{\substack{n=1 \ n \text{ odd}}}^{2N} \chi_4(n) \cdot e^{-s \log n}$$
With $N = 3000$, we sum 3000 odd terms, which gives excellent accuracy for $\text{Re}(s) \geq 0.2$ and moderate $t$. The matrix exponents has shape (K, M) where $K$ is the number of $s$-values and $M = N$, so all K evaluations happen in one NumPy call — no Python loops.
Step 3 — Local Minima Detection
scipy.signal.argrelmin identifies local minima in the discrete array abs_L using a neighborhood of order 15 samples. Then minimize_scalar with the bounded method refines each minimum to high precision within a $\pm 0.5$ window around the coarse candidate.
Step 4 — 3D Surface
We create a $80 \times 200$ grid over $(\sigma, t) \in [0.2, 1.2] \times [0.1, 30]$, flatten it into a vector, call L_chi4 once, then reshape. The surface is clipped at $|L| = 3$ to prevent the divergence near $\sigma = 1$ from dominating the color scale. The cyan curve on the 3D plot marks the critical line $\sigma = \frac{1}{2}$.
Results
======================================================= # t (location) |L(1/2+it)| ======================================================= 1 6.016928 0.00391272 <-- ZERO? 2 10.240892 0.00367946 <-- ZERO? 3 12.987726 0.00640438 <-- ZERO? 4 16.343953 0.00582567 <-- ZERO? 5 18.290210 0.00507564 <-- ZERO? 6 21.452597 0.00429338 <-- ZERO? 7 23.275682 0.00093554 <-- ZERO? 8 25.730319 0.00426197 <-- ZERO? 9 28.357026 0.00284663 <-- ZERO? 10 29.653989 0.00303421 <-- ZERO? 11 32.591633 0.00623710 <-- ZERO? 12 34.198148 0.00456596 <-- ZERO? 13 36.141904 0.00554603 <-- ZERO? 14 38.509976 0.00069965 <-- ZERO? 15 40.324942 0.00255655 <-- ZERO? =======================================================

Figure 1 saved. Computing 3D surface (this takes ~20-30 seconds)...

Figure 2 saved. Global minimum on critical line (t ∈ [0,50]): t* = 38.50997559 |L(1/2 + i*t*, chi4)| = 0.0006996492
Graph Interpretation
Figure 1 — Critical Line Plot:
The top panel shows $|L(\frac{1}{2}+it, \chi_4)|$ over $t \in [0, 50]$. The function oscillates, touching near-zero values at specific $t$-values — these are the zeros of $L(s, \chi_4)$ on the critical line. According to GRH, all non-trivial zeros lie exactly here. The first known zero is near $t \approx 6.02$.
The red downward triangles mark the local minima. Notice:
- Minima near zero correspond to actual zeros of the L-function
- The spacing between zeros grows roughly logarithmically with $t$, consistent with the explicit formula
Figure 2 — 3D Surface and Heatmap:
The 3D surface reveals the modulus landscape of $L(s, \chi_4)$:
- For $\sigma > 1$: The function is large and smooth (absolute convergence region). The partial sums are extremely accurate here.
- On $\sigma = \frac{1}{2}$ (cyan line): The function dips to zero periodically — these are the non-trivial zeros. The zeros appear as valleys in the 3D surface.
- For $\sigma < \frac{1}{2}$: The functional equation
$$L(s, \chi_4) = \left(\frac{\pi}{4}\right)^{s-\frac{1}{2}} \frac{\Gamma!\left(\frac{1-s+1}{2}\right)}{\Gamma!\left(\frac{s+1}{2}\right)} L(1-s, \chi_4)$$
means zeros are symmetric about $\sigma = \frac{1}{2}$. The heatmap (right) makes this landscape legible as a top-down view.
The key takeaway: the minima problem on the critical line is equivalent to finding the zeros of $L(s,\chi_4)$, which is one of the deepest open problems in mathematics — the Generalized Riemann Hypothesis.
















