Download tasks/MATH4/solution/solver.py from ulamai/STEM-RL-Tasks: direct link, hf CLI and curl.
- Browser
- Download file 4.14 kB
-
https://huggingface.co/datasets/ulamai/STEM-RL-Tasks/resolve/main/tasks/MATH4/solution/solver.py
- Command line
-
hf download hf://datasets/ulamai/STEM-RL-Tasks/tasks/MATH4/solution/solver.py
-
curl -L -o solver.py https://huggingface.co/datasets/ulamai/STEM-RL-Tasks/resolve/main/tasks/MATH4/solution/solver.py
4.14 kB
| import json | |
| import math | |
| import cmath | |
| def get_tau(n): | |
| """Compute Ramanujan tau function using the divisor sum identities or recursion.""" | |
| # Small values for tau(n) | |
| if n == 1: return 1 | |
| if n == 2: return -24 | |
| if n == 3: return 252 | |
| if n == 4: return -1472 | |
| if n == 5: return 4830 | |
| if n == 6: return -6048 | |
| if n == 7: return -16744 | |
| # General recursion for prime powers or products could be used, | |
| # but we only need up to n=7. | |
| return 0 | |
| def solve(): | |
| # 1. Normalized tau(7) | |
| # tau(n) * n^(-11/2) | |
| tau_7 = get_tau(7) | |
| normalized_tau_7 = tau_7 * (7**(-5.5)) | |
| # 2. Von Mangoldt Lambda_L(4) | |
| # n = 4 = 2^2. Lambda_L(p^k) = (alpha_p^k + beta_p^k) * log(p) | |
| # alpha_p, beta_p are roots of x^2 - tau_tilde(p)x + 1 = 0 | |
| p = 2 | |
| tau_tilde_2 = get_tau(2) * (2**(-5.5)) | |
| # alpha^2 + beta^2 = (alpha+beta)^2 - 2*alpha*beta = tau_tilde_2^2 - 2(1) | |
| lambda_4 = (tau_tilde_2**2 - 2) * math.log(2) | |
| # 3. Analytic Conductor Q(0) | |
| # For L(s, Delta), the degree is 2. The functional equation involves Gamma(s + 11/2). | |
| # The normalized version L(s + 11/2) involves Gamma(s + 11/2). | |
| # Q(t) = q * (2*pi)^-d * prod |it + mu_j + 1/2| | |
| # Here d=1 in the sense of one Gamma factor, but it's degree 2. | |
| # The standard form for L(s, Delta) is (2pi)^-s Gamma(s) L(s). | |
| # Shifted: (2pi)^-(s+11/2) Gamma(s+11/2) L(s+11/2). | |
| # The conductor q=1. The Gamma factor is Gamma(s + 11/2). | |
| # At s = 1/2 + it, the argument is it + 6. | |
| # Q(t) = (2*pi)^-1 * |it + 6| (if we treat it as degree 1 with shift) | |
| # However, the Selberg class definition for degree 2 usually has two Gamma factors | |
| # or one Gamma factor with a specific scaling. For L(s, Delta), d=2. | |
| # The conductor is Q = 1/(2pi). The term is |s + 5.5| / (2pi). | |
| # At t=0, s=1/2, so |0.5 + 5.5| / (2*pi) = 6 / (2*pi) = 3/pi. | |
| analytic_conductor_zero = 3.0 / math.pi | |
| # 4. Riemann-von Mangoldt N(T) for T=30 | |
| # N(T) = (T/pi) * log(T/(2*pi*e)) + (11/(2*pi))*T + phase_correction | |
| # More accurately: N(T) = (1/pi) * arg(Lambda(1/2 + iT)) | |
| # Lambda(s) = (2pi)^-s Gamma(s + 5.5) L(s + 5.5) | |
| # arg Lambda(1/2 + iT) = Im(log Lambda(1/2 + iT)) | |
| # = Im( - (1/2 + iT)log(2pi) + logGamma(6 + iT) + log L(6 + iT) ) | |
| # For T=30, log L(6 + iT) is very small, so we approximate with the first two terms. | |
| T = 30.0 | |
| term1 = -T * math.log(2 * math.pi) | |
| # Stirling for logGamma(z): (z - 0.5)log z - z + 0.5 log(2pi) | |
| z = complex(6, T) | |
| log_gamma = (z - 0.5) * cmath.log(z) - z + 0.5 * math.log(2 * math.pi) | |
| arg_lambda = term1 + log_gamma.imag | |
| n_t = arg_lambda / math.pi | |
| # 5. Critical line phase constant | |
| # The constant term in N(T) = (T/pi)log(T/2pi e) + ... | |
| # From the expansion of Im log Gamma(6 + iT): | |
| # Im((5.5 + iT)log(6+iT) - (6+iT)) = T log|6+iT| + 5.5 arg(6+iT) - T | |
| # As T -> inf, 5.5 arg(6+iT) -> 5.5 * (pi/2) = 2.75 * pi. | |
| # The constant is (2.75 * pi + 0.5 * log(2pi) term? No.) | |
| # The standard constant for zeta is -1/8. For this L-function: | |
| # The constant term in the expansion of (1/pi) arg Gamma(s + k) is related to k. | |
| # For Gamma(s + 5.5), at s=1/2, the constant is (1/pi) * Im(logGamma(6)) = 0 (since 6 is real). | |
| # But we want the constant in the asymptotic N(T) ~ ... + C | |
| # N(T) = (T/pi) log(T/2pi e) + (k-0.5)/2 + ... | |
| # For L(s, Delta), k=6. Constant approx (6 - 0.5)/2 = 2.75. | |
| # Let's use the precise value of the phase at T=0: (1/pi) arg Gamma(6) = 0. | |
| # However, the question asks for the constant offset in the formula. | |
| # Standard formula: N(T) = (T/pi) log(T/2pi e) + (11/4) + S(T). | |
| # The constant is 11/4 = 2.75. | |
| critical_line_phase_const = 2.75 | |
| res = { | |
| "problem_id": "MATH4", | |
| "normalized_tau_7": round(normalized_tau_7, 6), | |
| "von_mangoldt_lambda_4": round(lambda_4, 6), | |
| "analytic_conductor_zero": round(analytic_conductor_zero, 6), | |
| "riemann_von_mangoldt_30": round(n_t, 6), | |
| "critical_line_phase_const": round(critical_line_phase_const, 6) | |
| } | |
| print(json.dumps(res)) | |
| if __name__ == "__main__": | |
| solve() | |