module public import Mathlib.NumberTheory.LSeries.PrimesInAP import Mathlib.MeasureTheory.Function.Floor import Mathlib.NumberTheory.LSeries.Linearity import Mathlib.NumberTheory.LSeries.SumCoeff public import TauCeti.NumberTheory.ArithmeticDirichletSeries.Riesz.Basic public import Lib.Analytic.EntireLFunction import TauCeti.NumberTheory.ArithmeticDirichletSeries.Riesz.Laplace /-! # A weighted prime-counting error term and its poles at zeros of L-functions Let `d` be a prime and `χ_K = (·/d)` the Legendre symbol. We study the remainder `R_q` of a weighted sum over the prime powers `n ≡ 1` modulo `q` with `χ_K(n) ≠ 1`. Its Laplace transform sees the zeros of the Dirichlet `L`-functions modulo `q` and of their twists by `χ_K`. * `New.lambdaKResidueClass`: the weight `λ(n) = Λ(n) (1 - χ_K(n))` on `n ≡ 1` modulo `q`; it is nonnegative. * `New.logDerivMean`: the mean `G_q` over the characters `ψ` modulo `q` of the differences of the logarithmic derivatives of `New.entireL (New.quadTwist ψ d)` and `New.entireL ψ`, less `1 / φ(q)`. * `New.primeRemainder`: `R_q(x) = ∑_{n ≤ x} λ(n) (1/n - 1/x) - log x / φ(q) - re G_q(1)`. * `New.LSeriesHasSum_lambdaKResidueClass`: for odd `d` prime to `q`, the Dirichlet series of `λ` converges absolutely to `s / (φ(q) (s - 1)) + G_q(s)` in `re s > 1`. * `New.isPolar_primeRemainder`: for `d ≡ 7` modulo `8` prime to `q`, the transform of `v ↦ R_q(e ^ v)` has at most simple poles in `re s > 0`, none at `1`, and at `s ≠ 1` with the residue `(n(s) - n'(s)) / (φ(q) s (1 - s))`, where `n(s)` and `n'(s)` are the sums of the orders at `s` of these `L`-functions and of their twists. Here `New.entireL ψ` is `L(s, ψ)`, times `s - 1` if `ψ` is principal, `New.quadTwist ψ d` is the character `ψ χ_K`, and `New.chowlaSelbergConst d` is, for odd `d`, `γ - re L'/L(1, χ_K)`, with `γ` Euler's constant. ## Relation to the literature The transform of a weighted prime sum in a residue class is computed by orthogonality of characters and partial summation. Source: Davenport, Multiplicative Number Theory. -/ @[expose] public section noncomputable section open ArithmeticFunction DirichletCharacter Complex Finset Filter MeasureTheory Nat Real Topology vonMangoldt namespace New variable (d : ℕ) [Fact d.Prime] (q : ℕ) /-! ### The weights, their partial sums and the error term -/ /-- The weight `λ(n) = Λ(n) (1 - χ_K(n))` for `n ≡ 1` mod `q`, and `0` for other `n`. Here `Λ` is the von Mangoldt function and `χ_K = chiK d` is the Legendre symbol `(·/d)`. -/ def lambdaKResidueClass (n : ℕ) : ℝ := residueClass (1 : ZMod q) n * (1 - chiK d n) /-- The sum `y ^ (-r) ∑_{1 ≤ n ≤ y} λ(n) n ^ (r - 1)` with `λ = lambdaKResidueClass d q`, used for `r = 0` and `r = 1`. -/ def lambdaKSum (r : ℕ) (y : ℝ) : ℝ := (∑ n ∈ Icc 1 ⌊y⌋₊, lambdaKResidueClass d q n / n * n ^ r) / y ^ r /-- The function `G_q` with `φ(q) G_q = (L_q^K)' / L_q^K - L_q' / L_q - 1` away from the zeros of `L_q` and `L_q^K`, which are the products of the `entireL ψ` and of the `entireL (quadTwist ψ d)` over all characters `ψ` mod `q`. For odd `d` prime to `q` and `re s > 1` it is `∑ λ(n) n ^ (-s) - s / (φ(q) (s - 1))`. -/ def logDerivMean [NeZero q] (s : ℂ) : ℂ := (∑ ψ : DirichletCharacter ℂ q, (logDeriv (entireL (quadTwist ψ d)) s - logDeriv (entireL ψ) s) - 1) / φ q /-- The remainder `R_q(x) = ∑_{n ≤ x} λ(n) (1/n - 1/x) - log x / φ(q) - c_q`, with `λ = lambdaKResidueClass d q` and `c_q = re G_q(1)`, `G_q = logDerivMean d q`; see `primeRemainder_eq_sum_posPart`. For odd `d` prime to `q` this is the constant for which `R_q(x) → 0` as `x → ∞`, by `eventually_abs_primeRemainder_exp_le_inv_pow` in `New.Reduction.Zeros.PrimeNumberTheorem` with `B = 1`. -/ def primeRemainder [NeZero q] (x : ℝ) : ℝ := lambdaKSum d q 0 x - lambdaKSum d q 1 x - x.log / φ q - re (logDerivMean d q 1) /-- For a prime `d`, the Legendre symbol `chiK d n = (n/d)` takes the values `0`, `1` and `-1`, so `0 ≤ 1 - (n/d) ≤ 2`. -/ lemma one_sub_chiK_mem_Icc (n : ℕ) : 1 - (chiK d n : ℝ) ∈ Set.Icc (0 : ℝ) 2 := by obtain h_val | h_val | h_val : legendreSym d n = 0 ∨ legendreSym d n = 1 ∨ legendreSym d n = -1 := quadraticChar_isQuadratic (ZMod d) ((n : ℤ) : ZMod d) <;> norm_num [chiK_eq_legendreSym, h_val] lemma lambdaKResidueClass_nonneg (n : ℕ) : 0 ≤ lambdaKResidueClass d q n := mul_nonneg (residueClass_nonneg 1 n) (one_sub_chiK_mem_Icc d n).1 variable {d q} in /-- For a prime `d` and any `q : ℕ`, the weight `lambdaKResidueClass d q n`, which is `Λ(n) (1 - (n/d))` for `n ≡ 1` mod `q` and `0` otherwise, is at most `2 Λ(n)`, where `Λ = vonMangoldt`. -/ lemma lambdaKResidueClass_le_two_mul_vonMangoldt (n : ℕ) : lambdaKResidueClass d q n ≤ 2 * vonMangoldt n := by obtain ⟨h_chi_nonneg, h_chi_le⟩ := one_sub_chiK_mem_Icc d n rw [lambdaKResidueClass, mul_comm 2] exact mul_le_mul (residueClass_le 1 n) h_chi_le h_chi_nonneg vonMangoldt_nonneg lemma lambdaKResidueClass_le_two_mul (n : ℕ) : lambdaKResidueClass d q n ≤ 2 * n := calc lambdaKResidueClass d q n ≤ 2 * vonMangoldt n := lambdaKResidueClass_le_two_mul_vonMangoldt n _ ≤ 2 * Real.log n := mul_le_mul_of_nonneg_left vonMangoldt_le_log zero_le_two _ ≤ 2 * n := mul_le_mul_of_nonneg_left (Real.log_le_self n.cast_nonneg) zero_le_two /-- A bound of Mertens's type: `∑_{n ≤ N} Λ(n) / n ≤ 2 log N`. -/ lemma sum_vonMangoldt_div_le (N : ℕ) : ∑ n ∈ Ioc 0 N, vonMangoldt n / n ≤ 2 * Real.log N := by -- Use `N / n ≤ 2 ⌊N / n⌋` for `n ≤ N` and `∑ Λ(n) ⌊N / n⌋ = log N! ≤ N log N`. obtain rfl | hN := N.eq_zero_or_pos · simp have h_floor (n : ℕ) (hn : n ∈ Ioc 0 N) : (N : ℝ) / n ≤ 2 * (N / n : ℕ) := by obtain ⟨hn_pos, hn_le⟩ := mem_Ioc.1 hn have h_one : (1 : ℝ) ≤ (N / n : ℕ) := mod_cast Nat.div_pos hn_le hn_pos have h_lt : (N : ℝ) / n < (N / n : ℕ) + 1 := by simpa [Nat.floor_div_eq_div] using Nat.lt_floor_add_one ((N : ℝ) / n) linarith refine le_of_mul_le_mul_left ?_ (Nat.cast_pos.2 hN) calc (N : ℝ) * ∑ n ∈ Ioc 0 N, vonMangoldt n / n ≤ ∑ n ∈ Ioc 0 N, vonMangoldt n * (2 * (N / n : ℕ)) := by simp only [mul_sum, mul_div_left_comm (N : ℝ)] exact sum_le_sum fun n hn ↦ mul_le_mul_of_nonneg_left (h_floor n hn) vonMangoldt_nonneg _ = 2 * ∑ n ∈ Ioc 0 N, Real.log n := by simp only [mul_left_comm _ (2 : ℝ), ← mul_sum, ← sum_Ioc_mul_zeta_eq_sum, vonMangoldt_mul_zeta, log_apply] _ ≤ 2 * ∑ _n ∈ Ioc 0 N, Real.log N := by gcongr with n hn <;> simp_all [mem_Ioc] _ = N * (2 * Real.log N) := by simp [mul_left_comm] /-- Growth of the partial sums. Let `d` be a prime, `q` any natural number, and `λ = lambdaKResidueClass d q` the weight `Λ(n) (1 - (n/d))` on `n ≡ 1` mod `q` and `0` elsewhere, with `(·/d)` the Legendre symbol. For every `r : ℕ` and real `v`, the sum `lambdaKSum d q r y = y ^ (-r) ∑_{1 ≤ n ≤ y} λ(n) n ^ (r - 1)` at `y = e ^ v` has absolute value at most `2 e ^ v`. -/ lemma abs_lambdaKSum_exp_le (r : ℕ) (v : ℝ) : |lambdaKSum d q r (rexp v)| ≤ 2 * rexp v := by -- There are at most `exp v` terms, each at most `2 * exp v ^ r` since `0 ≤ λ(n) ≤ 2 n`. have h_term (n : ℕ) (hn : n ∈ Icc 1 ⌊rexp v⌋₊) : |lambdaKResidueClass d q n / n * n ^ r| ≤ 2 * rexp v ^ r := by have hn_le : (n : ℝ) ≤ rexp v := (le_floor_iff (exp_nonneg v)).1 (mem_Icc.1 hn).2 have h_div : lambdaKResidueClass d q n / n ≤ 2 := div_le_of_le_mul₀ n.cast_nonneg zero_le_two (lambdaKResidueClass_le_two_mul d q n) rw [abs_mul, abs_div, abs_pow, Nat.abs_cast, abs_of_nonneg (lambdaKResidueClass_nonneg d q n)] gcongr rw [lambdaKSum, abs_div, abs_pow, Real.abs_exp, div_le_iff₀ (by positivity), mul_assoc, mul_left_comm] calc |∑ n ∈ Icc 1 ⌊rexp v⌋₊, lambdaKResidueClass d q n / n * n ^ r| ≤ ∑ _n ∈ Icc 1 ⌊rexp v⌋₊, 2 * rexp v ^ r := (abs_sum_le_sum_abs _ _).trans (sum_le_sum h_term) _ = ⌊rexp v⌋₊ * (2 * rexp v ^ r) := by simp _ ≤ rexp v * (2 * rexp v ^ r) := mul_le_mul_of_nonneg_right (floor_le (exp_nonneg v)) (by positivity) variable [NeZero q] /-- Let `d` be a prime and `χ_K = quadTwist 1 d` the Legendre symbol `(·/d)` as a complex character mod `1 * d`. Let `E = entireL χ_K`, which is `L(s, χ_K)` if `d` is odd and `(s - 1) L(s, χ_K)` if `d = 2`. For the modulus `q = 1`, `G₁ = logDerivMean d 1` is `E'/E - Z'/Z - 1` with `Z(s) = (s - 1) ζ(s)`, and `re G₁(1) = -1 - γ + re E'/E(1)`. -/ lemma re_logDerivMean_one_eq_add_re_logDeriv : (logDerivMean d 1 1).re = -1 - eulerMascheroniConstant + (logDeriv (entireL (quadTwist (N := 1) 1 d)) 1).re := by -- For the trivial character mod `1`, `entireL` is `(s - 1) ζ(s)`, whose logarithmic derivative at -- `1` is `γ`. have h_zeta : entireL (1 : DirichletCharacter ℂ 1) = riemannZeta₁ := by have h_eq (s : ℂ) (hs : s ≠ 1) : (s - 1) * riemannZeta s = riemannZeta₁ s := by rw [riemannZeta_eq_inv_sub_mul hs, mul_inv_cancel_left₀ (sub_ne_zero.2 hs)] simpa [entireL, Function.update_eq_iff] using h_eq have h_mean : (logDerivMean d 1 1).re = (logDeriv (entireL (quadTwist (N := 1) 1 d)) 1).re - eulerMascheroniConstant - 1 := by simp [logDerivMean, logDeriv, level_one, h_zeta] linarith /-- For a prime `d` and the modulus `q = 1`, the value at `s = 1` of `G₁ = logDerivMean d 1` has real part `-1 - chowlaSelbergConst d`. -/ lemma re_logDerivMean_one : (logDerivMean d 1 1).re = -1 - chowlaSelbergConst d := by rw [re_logDerivMean_one_eq_add_re_logDeriv, chowlaSelbergConst] ring variable {d q} in /-- For a character `ψ` mod `q` let `L_ψ = entireL ψ` be `L(s, ψ)`, times `s - 1` if `ψ` is principal, and let `ψ' = quadTwist ψ d` be `ψ (·/d)`. The function `logDerivMean d q`, that is `(∑_ψ (logDeriv L_ψ' - logDeriv L_ψ) - 1) / φ(q)`, is analytic at every point where no `L_ψ` and no `L_ψ'` vanishes. -/ lemma analyticAt_logDerivMean {s : ℂ} (h_char : ∀ ψ : DirichletCharacter ℂ q, entireL ψ s ≠ 0) (h_twist : ∀ ψ : DirichletCharacter ℂ q, entireL (quadTwist ψ d) s ≠ 0) : AnalyticAt ℂ (logDerivMean d q) s := by unfold logDerivMean fun_prop (disch := simp only [h_char, h_twist, ne_eq, not_false_eq_true]) [logDeriv] /-- The function `G_q = logDerivMean d q` is analytic in `re s ≥ 1`, where no `entireL χ` vanishes. -/ lemma analyticAt_logDerivMean_of_one_le_re {s : ℂ} (hs : 1 ≤ s.re) : AnalyticAt ℂ (logDerivMean d q) s := analyticAt_logDerivMean (fun ψ ↦ entireL_ne_zero ψ hs) (fun ψ ↦ entireL_ne_zero (quadTwist ψ d) hs) variable {d q} in /-- The normalized mean `G_q(s) / s` used in the prime remainder transform is analytic at a nonzero point where all the entire L-functions and their quadratic twists are nonzero. -/ lemma analyticAt_logDerivMean_div {s : ℂ} (hs : s ≠ 0) (h_char : ∀ ψ : DirichletCharacter ℂ q, entireL ψ s ≠ 0) (h_twist : ∀ ψ : DirichletCharacter ℂ q, entireL (quadTwist ψ d) s ≠ 0) : AnalyticAt ℂ (fun z ↦ logDerivMean d q z / z) s := (analyticAt_logDerivMean h_char h_twist).div analyticAt_id hs /-- The normalized mean `G_q(s) / s` is analytic throughout `1 ≤ re s`. -/ lemma analyticAt_logDerivMean_div_of_one_le_re {s : ℂ} (hs : 1 ≤ s.re) : AnalyticAt ℂ (fun z ↦ logDerivMean d q z / z) s := (analyticAt_logDerivMean_of_one_le_re d q hs).div analyticAt_id (ne_zero_of_re_pos (zero_lt_one.trans_le hs)) /-- Growth of the remainder: for a prime `d`, `q ≥ 1` and `v ≥ 0`, `|R_q(e ^ v)| ≤ (|re G_q(1)| + 5) e ^ v`. -/ lemma abs_primeRemainder_exp_le {v : ℝ} (hv : 0 ≤ v) : |primeRemainder d q (rexp v)| ≤ (|re (logDerivMean d q 1)| + 5) * rexp v := by have h_log : |v / φ q| ≤ rexp v := by rw [abs_of_nonneg (by positivity)] linarith only [div_le_self hv (mod_cast NeZero.one_le : (1 : ℝ) ≤ φ q), add_one_le_exp v] set c : ℝ := re (logDerivMean d q 1) with hc calc |primeRemainder d q (rexp v)| ≤ |lambdaKSum d q 0 (rexp v)| + |lambdaKSum d q 1 (rexp v)| + |v / φ q| + |c| := by grw [primeRemainder, Real.log_exp, ← hc, abs_sub, abs_sub, abs_sub] _ ≤ 2 * rexp v + 2 * rexp v + rexp v + |c| * rexp v := by gcongr exacts [abs_lambdaKSum_exp_le d q 0 v, abs_lambdaKSum_exp_le d q 1 v, le_mul_of_one_le_right (abs_nonneg c) (one_le_exp hv)] _ = (|c| + 5) * rexp v := by ring variable {d q} /-- The prime remainder is the normalized first Riesz sum of its quadratic weights after subtracting the logarithmic main term and the constant at infinity. -/ lemma primeRemainder_eq_normalized_rieszSum {y : ℝ} (hy : 0 < y) : (primeRemainder d q y : ℂ) = TauCeti.rieszSum (fun n ↦ (lambdaKResidueClass d q n : ℂ)) y / y - (φ q : ℂ)⁻¹ * Real.log y - (logDerivMean d q 1).re := by have weight (n : ℕ) (hn : n ∈ Icc 1 ⌊y⌋₊) (w : ℂ) : w / n - w / n * n / y = w * ((y : ℂ) / n - 1) / y := by have hn_pos : 0 < n := (mem_Icc.1 hn).1 field [hn_pos.ne', hy.ne'] simpa [primeRemainder, lambdaKSum, TauCeti.rieszSum_def, ← div_eq_inv_mul, sum_div, ← sum_sub_distrib] using (sum_congr (rfl : Icc 1 ⌊y⌋₊ = _) fun n hn ↦ weight n hn (lambdaKResidueClass d q n)) /-- Multiplying the positive part of a difference of reciprocals by a nonnegative scale is the positive part of the corresponding scaled difference. -/ private lemma mul_posPart_one_div_sub_one_div {a : ℝ} (ha : 0 ≤ a) (x z : ℝ) : a * (1 / x - 1 / z)⁺ = (a / x - a / z)⁺ := by simp [posPart_def, mul_max_of_nonneg, ha, mul_sub, div_eq_mul_inv] /-- In the remainder `primeRemainder d q z = ∑_{1 ≤ n ≤ z} λ(n) (1/n - 1/z) - log z / φ(q) - re G_q(1)` with `z > 0`, the sum equals `∑_{1 ≤ n ≤ A} λ(n) (1/n - 1/z)⁺` for any integer `A ≥ ⌊z⌋`. -/ lemma primeRemainder_eq_sum_posPart {A : ℕ} {z : ℝ} (hz_pos : 0 < z) (hz_le : ⌊z⌋₊ ≤ A) : primeRemainder d q z = ∑ n ∈ Icc 1 A, lambdaKResidueClass d q n * (1 / n - 1 / z)⁺ - z.log / φ q - re (logDerivMean d q 1) := by apply Complex.ofReal_injective rw [primeRemainder_eq_normalized_rieszSum hz_pos, TauCeti.rieszSum_eq_sum_max_of_floor_le _ hz_le] simp only [ofReal_sub, ofReal_div, ofReal_sum, ofReal_mul, ofReal_natCast] rw [div_eq_inv_mul (Real.log z : ℂ), sub_left_inj, sub_left_inj, sum_div] apply sum_congr rfl intro n _ have ramp : max (z / (n : ℝ) - 1) 0 = z * (1 / n - 1 / z)⁺ := by rw [mul_posPart_one_div_sub_one_div hz_pos.le n z, div_self hz_pos.ne', posPart_def] rw [ramp, Complex.ofReal_mul] field_simp [Complex.ofReal_ne_zero.2 hz_pos.ne'] /-- In the remainder `primeRemainder d q z = ∑_{1 ≤ n ≤ z} λ(n) (1/n - 1/z) - log z / φ(q) - re G_q(1)` with `z > 0`, the sum equals `A⁻¹ ∑_{1 ≤ n ≤ A} λ(n) (A/n - A/z)⁺` for any integer `A ≥ z`. -/ lemma primeRemainder_eq_sum (A : ℕ) {z : ℝ} (hz_pos : 0 < z) (hz_le : z ≤ A) : primeRemainder d q z = ∑ n ∈ Icc 1 A, lambdaKResidueClass d q n * (A / n - A / z)⁺ / A - z.log / φ q - re (logDerivMean d q 1) := by have hA : (0 : ℝ) < A := hz_pos.trans_le hz_le simp [primeRemainder_eq_sum_posPart hz_pos (Nat.floor_le_of_le hz_le), ← mul_posPart_one_div_sub_one_div hA.le, mul_div_assoc, hA.ne'] /-! ### The Dirichlet series and the Laplace transform -/ /-- Let `d` be an odd prime coprime to `q ≥ 1`, `χ_K = (·/d)` the Legendre symbol, and `λ = lambdaKResidueClass d q` the weight `Λ(n) (1 - χ_K(n))` on `n ≡ 1` mod `q` and `0` elsewhere. For `re s > 1`, the series `∑ λ(n) n ^ (-s)` converges absolutely to `s / (φ(q) (s - 1)) + G_q(s)`. -/ lemma LSeriesHasSum_lambdaKResidueClass (hd : d ≠ 2) (h_cop : q.Coprime d) {s : ℂ} (hs : 1 < s.re) : LSeriesHasSum (fun n : ℕ ↦ lambdaKResidueClass d q n) s (s / (φ q * (s - 1)) + logDerivMean d q s) := by -- Orthogonality of the characters mod `q` expresses `λ` through `ψ Λ - ψ χ_K Λ`. let a (ψ : DirichletCharacter ℂ q) : ℕ → ℂ := (fun n : ℕ ↦ ψ n * vonMangoldt n) - fun n : ℕ ↦ quadTwist ψ d n * vonMangoldt n have h_orth (n : ℕ) : (lambdaKResidueClass d q n : ℂ) = ((φ q : ℂ)⁻¹ • ∑ ψ : DirichletCharacter ℂ q, a ψ) n := by have h_twist (ψ : DirichletCharacter ℂ q) : quadTwist ψ d n = ψ n * legendreSym d n := mod_cast quadTwist_apply ψ d n simp [a, lambdaKResidueClass, chiK_eq_legendreSym, residueClass_apply, h_twist, ← sum_mul, field] -- No twist is principal, so only `ψ = 1` contributes the term `1 / (s - 1)`. let D (ψ : DirichletCharacter ℂ q) : ℂ := logDeriv (entireL (quadTwist ψ d)) s - logDeriv (entireL ψ) s have h_series (ψ : DirichletCharacter ℂ q) : LSeriesHasSum (a ψ) s ((if ψ = 1 then 1 else 0) / (s - 1) + D ψ) := by convert (LSeriesHasSum_mul_vonMangoldt ψ hs).sub (LSeriesHasSum_mul_vonMangoldt (quadTwist ψ d) hs) rw [ite_eq_right (quadTwist_ne_one ψ d hd h_cop)] ring have h_total : LSeriesHasSum (∑ ψ : DirichletCharacter ℂ q, a ψ) s (1 / (s - 1) + ∑ ψ, D ψ) := by simpa [sum_add_distrib, ite_div] using LSeriesHasSum.sum (S := univ) fun ψ _ ↦ h_series ψ have hs_sub_ne : s - 1 ≠ 0 := sub_ne_zero.2 (ne_of_apply_ne re hs.ne') rw [LSeriesHasSum_congr _ _ (fun _ ↦ h_orth _)] convert h_total.smul (φ q : ℂ)⁻¹ using 1 unfold logDerivMean field /-- For an odd prime `d` coprime to `q ≥ 1` and `re s > 1`, the Laplace transform of `v ↦ R_q(e ^ v)` at `s - 1` is `(G_q(s) / s - re G_q(1)) / (s - 1)`. -/ lemma integral_primeRemainder (hd : d ≠ 2) (h_cop : q.Coprime d) {s : ℂ} (hs : 1 < s.re) : ∫ v : ℝ in Set.Ioi 0, primeRemainder d q (Real.exp v) * Complex.exp ((1 - s) * v) = (logDerivMean d q s / s - re (logDerivMean d q 1)) / (s - 1) := by let a (n : ℕ) : ℂ := lambdaKResidueClass d q n have h_series : LSeriesHasSum a s _ := LSeriesHasSum_lambdaKResidueClass hd h_cop hs have h_remainder (u : ℝ) : (primeRemainder d q (rexp u) : ℂ) = TauCeti.rieszSum a (rexp u) / (rexp u : ℂ) - (φ q : ℂ)⁻¹ * u - re (logDerivMean d q 1) := by simpa only [Real.log_exp] using primeRemainder_eq_normalized_rieszSum (d := d) (q := q) (Real.exp_pos u) have h := (TauCeti.hasLaplace_normalized_riesz_remainder hs h_series.LSeriesSummable (φ q : ℂ)⁻¹ (re (logDerivMean d q 1))).integral_eq simp only [← h_remainder, neg_sub, smul_eq_mul, mul_comm (cexp _)] at h rw [h, h_series.LSeries_eq] have hs_ne : s ≠ 0 := ne_zero_of_re_pos (by linarith) field /-- For an odd prime `d` coprime to `q ≥ 1`, the number `G_q(1)` is real, so it equals the constant `re G_q(1)` subtracted in `primeRemainder d q`. Here `G_q = logDerivMean d q` is `(∑_ψ (E_{ψ χ_K}' / E_{ψ χ_K} - E_ψ' / E_ψ) - 1) / φ(q)`, summed over the characters `ψ` mod `q`, where `χ_K = (·/d)` is the Legendre symbol and `E_χ = entireL χ` is `L(s, χ)`, times `s - 1` if `χ` is principal. -/ lemma ofReal_re_logDerivMean_one (hd : d ≠ 2) (h_cop : q.Coprime d) : ((logDerivMean d q 1).re : ℂ) = logDerivMean d q 1 := by -- The transform is real on `(1, ∞)`, so its numerator is real at `1` by continuity. let F (s : ℂ) : ℂ := logDerivMean d q s / s - re (logDerivMean d q 1) have h_real (x : ℝ) (hx : 1 < x) : (F x).im = 0 := by have h_eq : F x = (∫ v : ℝ in .Ioi 0, primeRemainder d q (rexp v) * cexp ((1 - x : ℂ) * v)) * (x - 1) := by rw [integral_primeRemainder hd h_cop (by simpa), div_mul_cancel₀ _ (mod_cast (by linarith : 0 < x - 1).ne')] rw [h_eq] norm_cast have hc : ContinuousAt (fun x : ℝ ↦ (F x).im) 1 := by have hG := (analyticAt_logDerivMean_of_one_le_re d q (s := 1) (by simp)).continuousAt dsimp only [F] fun_prop (disch := norm_num) have h_im : (F (1 : ℝ)).im = 0 := by refine tendsto_nhds_unique_of_eventuallyEq (l := 𝓝[>] (1 : ℝ)) hc.continuousWithinAt (g := fun _ : ℝ ↦ (0 : ℝ)) tendsto_const_nhds ?_ filter_upwards [self_mem_nhdsWithin] with x hx using h_real x hx exact Complex.ext (ofReal_re _) (by simpa [F, eq_comm] using h_im) /-! ### The poles of the Laplace transform -/ /-- Let `d` be a prime, `q ≥ 1`, `χ_K = (·/d)` the Legendre symbol, `quadTwist ψ d = ψ χ_K`, and let `E_χ = entireL χ` be `L(s, χ)`, times `s - 1` if `χ` is principal. The function `G_q = logDerivMean d q`, that is `(∑_ψ (E_{ψ χ_K}' / E_{ψ χ_K} - E_ψ' / E_ψ) - 1) / φ(q)` summed over the characters `ψ` mod `q`, has at most a simple pole at `ρ`. Its residue is the mean over `ψ` of `ord_ρ E_{ψ χ_K} - ord_ρ E_ψ`. -/ lemma tendsto_sub_mul_logDerivMean (ρ : ℂ) : Tendsto (fun z : ℂ ↦ (z - ρ) * logDerivMean d q z) (𝓝[≠] ρ) (𝓝 ((∑ ψ : DirichletCharacter ℂ q, (analyticOrderNatAt (entireL (quadTwist ψ d)) ρ - analyticOrderNatAt (entireL ψ) ρ : ℂ)) / φ q)) := by have h_term (ψ : DirichletCharacter ℂ q) : Tendsto (fun z : ℂ ↦ (z - ρ) * (logDeriv (entireL (quadTwist ψ d)) z - logDeriv (entireL ψ) z)) (𝓝[≠] ρ) (𝓝 (analyticOrderNatAt (entireL (quadTwist ψ d)) ρ - analyticOrderNatAt (entireL ψ) ρ)) := by simpa only [mul_sub] using (tendsto_sub_mul_logDeriv_entireL_analyticOrderNatAt (quadTwist ψ d) ρ).sub (tendsto_sub_mul_logDeriv_entireL_analyticOrderNatAt ψ ρ) have h_sub : Tendsto (fun z : ℂ ↦ z - ρ) (𝓝[≠] ρ) (𝓝 0) := tendsto_sub_nhds_zero_iff.2 nhdsWithin_le_nhds have h_eq (z : ℂ) : (z - ρ) * logDerivMean d q z = (∑ ψ : DirichletCharacter ℂ q, (z - ρ) * (logDeriv (entireL (quadTwist ψ d)) z - logDeriv (entireL ψ) z) - (z - ρ)) / φ q := by simp [logDerivMean, ← mul_sum, field] simpa only [h_eq, sub_zero] using ((tendsto_finsetSum univ fun ψ _ ↦ h_term ψ).sub h_sub).div_const (φ q : ℂ) /-- Let `d` be a prime, `q ≥ 1`, `χ_K = (·/d)` the Legendre symbol, `quadTwist ψ d = ψ χ_K`, and let `E_χ = entireL χ` be `L(s, χ)`, times `s - 1` if `χ` is principal. At `ρ ≠ 0, 1` and for any constant `κ`, the function `(G_q(z) / z - κ) / (z - 1)` has at most a simple pole, of residue `∑_ψ (ord_ρ E_ψ - ord_ρ E_{ψ χ_K}) / (φ(q) ρ (1 - ρ))`. -/ lemma tendsto_logDerivMean_residue (κ : ℂ) {ρ : ℂ} (hρ₀ : ρ ≠ 0) (hρ₁ : ρ ≠ 1) : Tendsto (fun z : ℂ ↦ (z - ρ) * ((logDerivMean d q z / z - κ) / (z - 1))) (𝓝[≠] ρ) (𝓝 ((∑ ψ : DirichletCharacter ℂ q, (analyticOrderNatAt (entireL ψ) ρ - analyticOrderNatAt (entireL (quadTwist ψ d)) ρ : ℂ)) / φ q / (ρ * (1 - ρ)))) := by -- The pole is that of `G_q`, with residue `m`; it is divided by `z (z - 1)`. let m : ℂ := (∑ ψ : DirichletCharacter ℂ q, (analyticOrderNatAt (entireL (quadTwist ψ d)) ρ - analyticOrderNatAt (entireL ψ) ρ : ℂ)) / φ q have h_id : Tendsto (fun z : ℂ ↦ z) (𝓝[≠] ρ) (𝓝 ρ) := tendsto_id.mono_left nhdsWithin_le_nhds have h_lim : Tendsto (fun z : ℂ ↦ ((z - ρ) * logDerivMean d q z / z - (z - ρ) * κ) / (z - 1)) (𝓝[≠] ρ) (𝓝 ((m / ρ - (ρ - ρ) * κ) / (ρ - 1))) := (((tendsto_sub_mul_logDerivMean ρ).div h_id hρ₀).sub ((h_id.sub_const ρ).mul_const κ)).div (h_id.sub_const 1) (sub_ne_zero.2 hρ₁) convert h_lim using 2 with z · ring · simp only [m, sum_sub_distrib] field [sub_ne_zero.2 hρ₁, sub_ne_zero.2 hρ₁.symm] /-- **Poles.** Let `d ≡ 7 mod 8` be a prime coprime to `q ≥ 1`, `χ_K = (·/d)` the character of `K = ℚ(√-d)`, and `R_q = primeRemainder d q`. The conclusion `IsPolar` says that the transform `∫₀^∞ R_q(e ^ v) e ^ ((1 - s) v) dv` converges absolutely for `re s > 2` and continues from there to a function meromorphic on `re s > 0` with at most simple poles there and the following residues. It has no pole at `1`, where the formula below is a division by zero, of value `0`. The residue at `s ≠ 1` is `∑_ψ (ord_s E_ψ - ord_s E_{ψ χ_K}) / (φ(q) s (1 - s))`, summed over the characters `ψ` mod `q`, where `quadTwist ψ d = ψ χ_K` and `E_χ = entireL χ` is `L(s, χ)`, times `s - 1` if `χ` is principal. -/ lemma isPolar_primeRemainder (hd : d % 8 = 7) (h_cop : q.Coprime d) : IsPolar (fun v : ℝ ↦ primeRemainder d q (Real.exp v)) fun s : ℂ ↦ (∑ ψ : DirichletCharacter ℂ q, (analyticOrderNatAt (entireL ψ) s - analyticOrderNatAt (entireL (quadTwist ψ d)) s : ℂ)) / φ q / (s * (1 - s)) := by -- The continuation is `F s / (s - 1)` with `F s = G_q(s) / s - c_q`, which vanishes at `1`. have hd_ne : d ≠ 2 := by lia let c : ℝ := re (logDerivMean d q 1) let F (s : ℂ) : ℂ := logDerivMean d q s / s - c have h_meas : Measurable fun v : ℝ ↦ primeRemainder d q (rexp v) := by fun_prop [primeRemainder, lambdaKSum] have h_mero : Meromorphic fun s : ℂ ↦ F s / (s - 1) := fun _ ↦ by fun_prop [logDerivMean] have h_transform (s : ℂ) (hs : 2 < s.re) : F s / (s - 1) = ∫ v : ℝ in Set.Ioi 0, primeRemainder d q (rexp v) * cexp ((1 - s) * v) := (integral_primeRemainder hd_ne h_cop (one_lt_two.trans hs)).symm have h_growth (v : ℝ) (hv : 0 ≤ v) : |primeRemainder d q (rexp v)| ≤ (|c| + 5) * rexp v := abs_primeRemainder_exp_le d q hv refine isPolar_of_tendsto h_meas h_growth (fun z _ ↦ h_mero z) h_transform fun ρ hρ ↦ ?_ obtain rfl | hρ₁ := eq_or_ne ρ 1 · have hF : AnalyticAt ℂ F 1 := (analyticAt_logDerivMean_div_of_one_le_re d q one_re.ge).sub analyticAt_const have hF_one : F 1 = 0 := by simp [F, c, ofReal_re_logDerivMean_one hd_ne h_cop] have h_lim : Tendsto F (𝓝[≠] 1) (𝓝 0) := by simpa [hF_one] using hF.continuousAt.continuousWithinAt.tendsto simp only [sub_self, mul_zero, div_zero] exact h_lim.congr' (eventually_nhdsWithin_of_forall fun z hz ↦ (mul_div_cancel₀ (F z) (sub_ne_zero.2 hz)).symm) · exact tendsto_logDerivMean_residue c (ne_zero_of_re_pos hρ) hρ₁ end New end