# Merge dim-1 main grid (j=-6..12) with the supplementary low grid; recompute least/upward-closed certified h. import json, math res = {} for x in (11, 13, 17, 19): A = json.load(open('sm2851_x%d_dim1.json' % x)); B = json.load(open('sm2851lo_x%d_dim1.json' % x)) rows = {r['h']: r for r in B['rows'] + A['rows']}; hs = sorted(rows) s = {} for k in ('true', 'A', 'B', 'abs'): cert = [h for h in hs if rows[h][k]['k'] is not None]; up = None for h in reversed(hs): if rows[h][k]['k'] is None: break up = h e = lambda v: None if v is None else round(math.log(v) / math.log(x), 3) s[k] = {'h_cert': cert[0] if cert else None, 'exp': e(cert[0]) if cert else None, 'h_up': up, 'exp_up': e(up), 'uncert_above_first': [h for h in hs if cert and h > cert[0] and rows[h][k]['k'] is None]} s['grid_min_h'] = hs[0] s['null_not_sup'] = {k: [h for h in hs if (rows[h][k]['k'] is None) != (rows[h][k]['max'] >= 1)] for k in ('true', 'A', 'B', 'abs')} res[x] = s print(json.dumps(res, sort_keys=True))