Independent scholarship · Open accessThe monthly digest

Indexed text attachment

verify-topology.py

Source for Algebraic and Differential Topology in Higher Categories

View paper · Download original file

Lines 1321–1420 of 1961. Source text is displayed literally.

1321okadd = True1322for ab, vm in AUT:1323    if ab[1] == 0:1324        A = Cx([[0]])1325        okadd = okadd and lefschetz_chain(T7, vm) == lefschetz_chain(A, {0: 0}) + rel_trace(T7, A, vm)1326rot = {0: 0, 11: 11}1327rot.update({1 + i: 1 + (i + 1) % 5 for i in range(5)})1328rot.update({6 + i: 6 + (i + 1) % 5 for i in range(5)})1329poles = Cx([[0], [11]])1330okadd = okadd and lefschetz_chain(ICO, rot) == 2 == lefschetz_chain(poles, {0: 0, 11: 11}) + rel_trace(ICO, poles, rot)1331check('L7 traces are additive: L(f) = L(f on A) + L(f on K relative to A) for an invariant subcomplex A', okadd,1332      'torus automorphisms fixing a vertex; the rotation of the icosahedron about an axis has L = 2 = two fixed poles')1333 1334 1335def aut_group(K):1336    verts = [x[0] for x in K.S[0]]1337    top = set(K.S[K.dim])1338    out = []1339    for perm in itertools.permutations(verts):1340        vm = dict(zip(verts, perm))1341        if all(tuple(sorted(vm[v] for v in t)) in top for t in top):1342            out.append(vm)1343    return out1344 1345 1346AR = aut_group(RP2)1347check('L8 every self-map of the projective plane has L = 1: all 60 automorphisms of the 6-vertex triangulation fix a point',1348      len(AR) == 60 and all(lefschetz_chain(RP2, vm) == 1 and has_fixed_simplex(RP2, vm) for vm in AR), 'automorphism group of order %d' % len(AR))1349 1350okmul = True1351for _ in range(30):1352    a, b = random.randint(-4, 4), random.randint(-4, 4)1353    A = [[a, 0], [0, b]]1354    okmul = okmul and (1 - a) * (1 - b) == 1 - (a + b) + a * b1355check('L9 the Lefschetz number is multiplicative on products: for z^a x z^b on the torus, (1-a)(1-b) = det(I - diag(a,b))', okmul, '30 pairs of degrees')1356 1357 1358 1359 1360# ######################## CHECKS: PART TWO ########################1361def vsub(a, b):1362    return [x - y for x, y in zip(a, b)]1363 1364 1365def cross(a, b):1366    return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]1367 1368 1369def vnorm(a):1370    return math.sqrt(sum(x * x for x in a))1371 1372 1373def gauss_link(c1, c2, n=200):1374    """Gauss linking integral of two closed curves given as functions on [0, 2 pi)"""1375    h = 2 * PI / n1376    P = [c1((i + 0.5) * h) for i in range(n)]1377    Q = [c2((i + 0.5) * h) for i in range(n)]1378    dP = [vsub(c1((i + 1) * h), c1(i * h)) for i in range(n)]1379    dQ = [vsub(c2((i + 1) * h), c2(i * h)) for i in range(n)]1380    tot = 0.01381    for i in range(n):1382        for j in range(n):1383            r = vsub(P[i], Q[j])1384            d = vnorm(r)1385            tot += dot(r, cross(dP[i], dQ[j])) / d ** 31386    return tot / (4 * PI)1387 1388 1389sec('7. General position')1390 1391 1392def seg_cross(p, q, r, s):1393    def o(a, b, c):1394        return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])1395    return o(p, q, r) * o(p, q, s) < 0 and o(r, s, p) * o(r, s, q) < 01396 1397 1398def trefoil(t):1399    return [math.sin(t) + 2 * math.sin(2 * t), math.cos(t) - 2 * math.cos(2 * t), -math.sin(3 * t)]1400 1401 1402def crossings(direction, n=240):1403    d = [x / vnorm(direction) for x in direction]1404    a = cross(d, [0.3, 0.5, 0.81])1405    a = [x / vnorm(a) for x in a]1406    b = cross(d, a)1407    pts = [(dot(trefoil(2 * PI * i / n), a), dot(trefoil(2 * PI * i / n), b)) for i in range(n)]1408    c = 01409    for i in range(n):1410        for j in range(i + 2, n):1411            if i == 0 and j == n - 1:1412                continue1413            if seg_cross(pts[i], pts[(i + 1) % n], pts[j], pts[(j + 1) % n]):1414                c += 11415    return c1416 1417 1418cz = crossings([0, 0, 1])1419cr = [crossings([random.gauss(0, 1) for _ in range(3)]) for _ in range(12)]1420check('M1 a generic projection of a closed curve from space to the plane has finitely many transverse double points: the trefoil shows 3 from above and never fewer',