"""Recompute the Spark two-mass weak-field model. Requires Python 3 only.""" from cmath import exp from decimal import Decimal, getcontext from itertools import product from json import dumps from math import tau getcontext().prec = 64 D = Decimal G = D("6.67430e-11") MASS = D("1e-8") GAPS = (D("49.5e-6"), D("50.5e-6")) PROBE_DISTANCE = D("1e-3") STEP = D("1e-16") def acceleration(gap, lateral): radius = (gap * gap + lateral * lateral).sqrt() return G * MASS * gap / radius ** 3 def gradient(gap, lateral): # A probe displaced upward decreases the gap to the source. numeric = (acceleration(gap - STEP, lateral) - acceleration(gap + STEP, lateral)) / (2 * STEP) radius = (gap * gap + lateral * lateral).sqrt() analytic = G * MASS * (2 * gap * gap - lateral * lateral) / radius ** 5 assert abs(numeric / analytic - 1) < D("1e-21") return numeric local = [gradient(gap, D(0)) for gap in GAPS] remote = [gradient(gap, PROBE_DISTANCE) for gap in GAPS] readings = [(local[a] + remote[b], remote[a] + local[b]) for a, b in product(range(2), repeat=2)] average = (sum(local) + sum(remote)) / 2 local_change = (local[0] - local[1]) / 2 remote_change = (remote[0] - remote[1]) / 2 results = [] for correlation in (D("-1"), D("-0.7"), D("0"), D("0.31"), D("1")): probabilities = [(1 + correlation * a * b) / 4 for a, b in product((1, -1), repeat=2)] assert sum(probabilities) == 1 means = [sum(p * row[i] for p, row in zip(probabilities, readings)) for i in (0, 1)] assert all(abs(mean - average) < D("1e-62") for mean in means) covariance = sum(p * (a - means[0]) * (b - means[1]) for p, (a, b) in zip(probabilities, readings)) closed = 2 * local_change * remote_change + correlation * (local_change ** 2 + remote_change ** 2) assert abs(covariance - closed) < D("1e-61") results.append({ "correlation": float(correlation), "jointBranchProbability": list(map(float, probabilities)), "meanGradient_per_s2": float(means[0]), "crossCovariance_per_s4": float(covariance), }) # A complex pure-state density matrix and an incoherent mixture have the same # trace against every diagonal position projector. A separate X⊗X readout can # respond to the relative phase because it has off-diagonal matrix elements. phase_checks = 0 mixed = [0.5, 0, 0, 0.5] for step in range(64): phase = tau * step / 64 ket = (1 / 2 ** 0.5, 0, 0, exp(1j * phase) / 2 ** 0.5) rho = [[x * y.conjugate() for y in ket] for x in ket] for mask in range(16): measured = sum(rho[i][i].real for i in range(4) if mask & (1 << i)) control = sum(mixed[i] for i in range(4) if mask & (1 << i)) assert abs(measured - control) < 1e-14 phase_checks += 1 phase_readout = sum(rho[i][3-i] for i in range(4)) assert abs(phase_readout - exp(1j * phase).real) < 1e-14 print(dumps({ "purpose": "Synthetic static point-mass prediction. No gravimetry was performed.", "massEach_kg": float(MASS), "gaps_m": list(map(float, GAPS)), "probeSeparation_m": float(PROBE_DISTANCE), "independentCheck": "decimal finite differences, full outcome enumeration, and complex density matrices", "phaseEventChecks": phase_checks, "conditions": results, }, indent=2))