# One ordinary logarithmic Mahler measure, using mpmath.
# This is heuristic quadrature; compare working=140 and working=180.
# Recompute an algebraic argument inside the callable at each precision.
from mpmath import mp
def p_boyd(argument, working=140):
with mp.workdps(working):
k=abs(mp.mpf(argument() if callable(argument) else argument))
if not mp.isfinite(k):
raise ValueError('A finite real argument is required.')
if k==0:
return mp.mpf(0)
a=(mp.sqrt(k*k+16)-k)/8
b=min(mp.mpf(1),(mp.sqrt(k*k+16)+k)/8)
bounds=sorted(set([mp.mpf(0),mp.acos(b),mp.acos(a),mp.pi/2]))
def f(theta):
t=mp.cos(theta)
D=k*k*t*t-(4*t*t-1)**2
return (mp.log(k*t+mp.sqrt(D)) if D>=0
else mp.log(abs(4*t*t-1)))
result=mp.mpf(0)
for left,right in zip(bounds,bounds[1:]):
def g(u):
if u==0 or u==mp.pi/2:
return mp.mpf(0)
return (f(left+(right-left)*mp.sin(u)**2)
*(right-left)*mp.sin(2*u))
result+=mp.quad(g,[0,mp.pi/4,mp.pi/2])
return 2*result/mp.pi
# Example: positive sqrt(2), never a copied rounded decimal input.
print(mp.nstr(p_boyd(lambda: mp.sqrt(2)),105))
# The attached generator enumerates k=sqrt(n), n=0,...,36,
# reduces square cases to integers, and checks input endpoint propagation.
The generator applies the real Jensen integral (3). Algebraic discriminant contacts split the integration range, and a sine-squared endpoint change removes square-root cusps. Quadratures use 140 and 180 decimal digits for a 100-digit request. Exact radical inputs are enclosed with Sage real intervals; monotonicity of the positive-root Jensen representation propagates their endpoint values, and the results at both precisions are united. Quadrature errors remain heuristic: these intervals are not certified enclosures of the integrals. The exact value at zero follows from (2).
All 37 stored-format values are checked at 135 working decimal digits by integrating the complete-elliptic derivative from p(0)=0, using Carlson RF and a split at k=3. This uses a different integral representation from the primary Jensen numerator, while sharing mpmath and the source normalization. Its nonzero control p(3) agrees with a Hurwitz-zeta computation of the quadratic Dirichlet L-value to more than 120 digits; a deliberately perturbed value is rejected. The parity and zero-factorization identities are checked by polynomial expansion. Executable code, numerical results and argument-selection evidence are attached. These numerical checks do not certify the quadrature error.