# ssum2549.py -- exact defect of the twin-pair singular-series sum for a grid of H (job #2549, leads): # Delta(H) = H^2 (2C2)^2 - sum_{even h, 0<|h|8} rel={rel:.7f} (1-rel)*H={defect:.4f} lnH={math.log(H):.3f}", file=sys.stderr, flush=True) X = np.array([[math.log(H) ** 2, math.log(H), 1.0] for H, _, _ in rows]); y = np.array([d for _, _, d in rows]) coef, res, rk, sv = np.linalg.lstsq(X, y, rcond=None); fit = X @ coef X1 = np.array([[math.log(H), 1.0] for H, _, _ in rows]); coef1 = np.linalg.lstsq(X1, y, rcond=None)[0]; fit1 = X1 @ coef1 out = dict(C4=C4, rows=[dict(H=H, rel=rel, defect_over_2C2sq_H=d) for H, rel, d in rows], fit_ln2=dict(a=coef[0], b=coef[1], c=coef[2], max_abs_resid=float(np.abs(fit - y).max())), fit_ln=dict(a=coef1[0], b=coef1[1], max_abs_resid=float(np.abs(fit1 - y).max()))) json.dump(out, open('ssum2549.json', 'w'), indent=1); print(json.dumps(out, indent=1))