import os, sys, json, math, random import numpy as np import torch sys.path.insert(0, '/home/maxwelhelp/all/math2nn') from bench import get_dataset, make_model, train_model, sweep_baseline, evaluate, make_report SEEDS = tuple(range(8)) # Small fixed finite-difference Dirichlet Laplacian. WW inertia gives certified # intervals for eigenvalues of the indefinite operator L-lambda I. def ww_bracket(mode, n=18, tol=2e-3): N = n*n; h=1.0/(n+1) L = np.diag(np.full(N, 4.0/h**2)) for i in range(n): for j in range(n): k=i*n+j if i: L[k,(i-1)*n+j] = -1.0/h**2 if i=mode+1: lo,hi=float(a),float(b); break while hi-lo>tol: mid=(lo+hi)/2 if count(mid)<=mode: lo=mid else: hi=mid return lo,hi,vals def math_check(): lo,hi,vals=ww_bracket(2) grid=np.linspace(0,float(vals[20]),120) # independent inertia check on the same operator, with eigensolver only Lvals=vals counts=np.array([np.sum(Lvals < x-1e-9) for x in grid]) return {'monotone': bool(np.all(np.diff(counts)>=0)), 'bracket_width': float(hi-lo), 'eigenvalues_in_bracket': int(np.sum((Lvals>lo)&(Lvals