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 1521–1620 of 1961. Source text is displayed literally.

1521    s, w = circle_degree(F, None, 0.7)1522    okdeg = okdeg and s == a == w1523check('F1 framed points: the signed number of preimages of a regular value of a circle map is its degree, also when the map folds back', okdeg, 'degrees -2..3 with a non-monotone lift')1524 1525 1526def sphere_degree(F, n=160):1527    """degree of a map of the 2-sphere by integrating the pulled-back area form"""1528    tot = 0.01529    hu, hv = PI / n, 2 * PI / n1530    def X(u, v):1531        return F([math.sin(u) * math.cos(v), math.sin(u) * math.sin(v), math.cos(u)])1532    for i in range(n):1533        for j in range(n):1534            u, v = (i + 0.5) * hu, (j + 0.5) * hv1535            a = X(u, v)1536            du = [(p - q) / (2e-5) for p, q in zip(X(u + 1e-5, v), X(u - 1e-5, v))]1537            dv = [(p - q) / (2e-5) for p, q in zip(X(u, v + 1e-5), X(u, v - 1e-5))]1538            tot += dot(a, cross(du, dv)) * hu * hv1539    return tot / (4 * PI)1540 1541 1542def susp(d):1543    def F(x):1544        r = math.hypot(x[0], x[1])1545        if r < 1e-12:1546            return [0.0, 0.0, 1.0 if x[2] > 0 else -1.0]1547        z = complex(x[0], x[1]) / r1548        w = z ** d if d >= 0 else (z.conjugate()) ** (-d)1549        return [r * w.real, r * w.imag, x[2]]1550    return F1551 1552 1553sd_ = [sphere_degree(susp(d)) for d in (1, 2, 3, -2)]1554check('F2 suspension preserves the degree: the suspension of z -> z^d on the 2-sphere has degree d',1555      all(close(v, d, 2e-3) for v, d in zip(sd_, (1, 2, 3, -2))), 'integral of the pulled-back area form: %s' % ', '.join('%.4f' % v for v in sd_))1556 1557 1558def collapse_degree(points, n=120):1559    """degree of the Pontryagin-Thom collapse of framed points in the plane: sum over discs of the area integral"""1560    tot = 0.01561    for (px, py, frame) in points:1562        def G(y):1563            # disc |y| < 1 -> sphere: y/(1-|y|^2) followed by inverse stereographic projection1564            r2 = y[0] * y[0] + y[1] * y[1]1565            Y = [y[0] / (1 - r2), y[1] / (1 - r2)]1566            s = Y[0] * Y[0] + Y[1] * Y[1]1567            return [2 * Y[0] / (s + 1), 2 * Y[1] / (s + 1), (1 - s) / (s + 1)]1568        hr, ht = 1.0 / n, 2 * PI / n1569        for i in range(n):1570            for j in range(n):1571                r, t = (i + 0.5) * hr, (j + 0.5) * ht1572                def X(r_, t_):1573                    x = [r_ * math.cos(t_), r_ * math.sin(t_)]1574                    y = [frame[0][0] * x[0] + frame[0][1] * x[1], frame[1][0] * x[0] + frame[1][1] * x[1]]1575                    return G(y)1576                a = X(r, t)1577                dr = [(p - q) / 2e-6 for p, q in zip(X(r + 1e-6, t), X(r - 1e-6, t))]1578                dt = [(p - q) / 2e-6 for p, q in zip(X(r, t + 1e-6), X(r, t - 1e-6))]1579                tot += dot(a, cross(dr, dt)) * hr * ht1580    return tot / (4 * PI)1581 1582 1583pos = [[1.0, 0.0], [0.0, 1.0]]1584neg = [[0.0, 1.0], [1.0, 0.0]]1585cd = [collapse_degree([(0, 0, pos)]), collapse_degree([(0, 0, neg)]), collapse_degree([(0, 0, pos), (3, 0, pos), (0, 3, neg)])]1586check('F3 the Pontryagin-Thom collapse of framed points in the plane has degree the signed number of points',1587      close(cd[0], 1, 5e-3) and close(cd[1], -1, 5e-3) and close(cd[2], 1, 5e-3), 'degrees %.4f, %.4f, %.4f for frames (+), (-), (+,+,-)' % tuple(cd))1588 1589sec('9. Degree, linking and the Hopf invariant')1590cA = lambda s: [math.cos(s), math.sin(s), 0.0]1591cB = lambda s: [1 + math.cos(s), 0.0, math.sin(s)]1592cC = lambda s: [4 + math.cos(s), 0.0, math.sin(s)]1593def tl(j, k=2):1594    return lambda s: [(2 + 0.6 * math.cos(k * s + j * PI)) * math.cos(s), (2 + 0.6 * math.cos(k * s + j * PI)) * math.sin(s), 0.6 * math.sin(k * s + j * PI)]1595l1, l0, l2 = gauss_link(cA, cB), gauss_link(cA, cC), gauss_link(tl(0), tl(1))1596check('K1 the Gauss integral computes linking numbers: Hopf link 1, unlinked circles 0, the (2,4) torus link 2',1597      close(abs(l1), 1, 1e-3) and abs(l0) < 1e-9 and close(abs(l2), 2, 1e-3), 'values %.8f, %.1e, %.8f' % (l1, l0, l2))1598 1599 1600def stereo(x):1601    return [x[0] / (1 - x[3]), x[1] / (1 - x[3]), x[2] / (1 - x[3])]1602 1603 1604def fibre(zeta):1605    """the Hopf fibre z1 = zeta z2, as a curve in R^3"""1606    n = math.sqrt(1 + abs(zeta) ** 2)1607    def c(t):1608        e = cmath.exp(1j * t)1609        z1, z2 = zeta * e / n, e / n1610        return stereo([z1.real, z1.imag, z2.real, z2.imag])1611    return c1612 1613 1614def total_link(zs, ws):1615    return sum(gauss_link(fibre(a), fibre(b)) for a in zs for b in ws)1616 1617 1618h1 = total_link([0.3 + 0.2j], [-1.0 + 0.5j])1619h4 = total_link([cmath.sqrt(0.3 + 0.2j), -cmath.sqrt(0.3 + 0.2j)], [cmath.sqrt(-1 + 0.5j), -cmath.sqrt(-1 + 0.5j)])1620c3 = lambda w: [abs(w) ** (1 / 3) * cmath.exp(1j * (cmath.phase(w) + 2 * PI * k) / 3) for k in range(3)]