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

1901for g in (1, 2, 3):1902    vecs, forms = quad_forms(g)1903    for c, q in forms:1904        arf = sum(c[i] * c[g + i] for i in range(g)) % 21905        okred = okred and surgery_reduce(q, g) == 2 * arf1906check('A5 surgery on classes with q = 0 reduces a form of Arf invariant 0 to nothing and one of Arf invariant 1 to a torus on which q is 1 on every non-zero class',1907      okred, 'all forms of genus 1, 2, 3')1908 1909sec('12. Stable stems as the homotopy of the unit')1910 1911 1912def commutator_index(n):1913    els = list(itertools.permutations(range(n)))1914    mul = lambda a, b: tuple(a[b[i]] for i in range(n))1915    inv_ = lambda a: tuple(sorted(range(n), key=lambda i: a[i]))1916    gens = set()1917    for a in els:1918        for b in els:1919            gens.add(mul(mul(a, b), mul(inv_(a), inv_(b))))1920    G = set(gens)1921    frontier = list(gens)1922    while frontier:1923        x = frontier.pop()1924        for y in gens:1925            z = mul(x, y)1926            if z not in G:1927                G.add(z)1928                frontier.append(z)1929    return len(els) // len(G)1930 1931 1932ci = [commutator_index(n) for n in (2, 3, 4, 5)]1933check('T1 the abelianization of the symmetric group has order 2 for n >= 2: the sign is the first stable stem', ci == [2, 2, 2, 2], 'index of the commutator subgroup for n = 2..5: %s' % ci)1934 1935 1936def angle_defect_sum(verts, tris):1937    ang = {i: 0.0 for i in range(len(verts))}1938    for t in tris:1939        for k in range(3):1940            a, b, c = verts[t[k]], verts[t[(k + 1) % 3]], verts[t[(k + 2) % 3]]1941            u_, v_ = vsub(b, a), vsub(c, a)1942            ang[t[k]] += math.acos(max(-1.0, min(1.0, dot(u_, v_) / (vnorm(u_) * vnorm(v_)))))1943    return sum(2 * PI - a for a in ang.values())1944 1945 1946tet = [[random.gauss(0, 1) for _ in range(3)] for _ in range(4)]1947d_tet = angle_defect_sum(tet, [(0, 1, 2), (0, 1, 3), (0, 2, 3), (1, 2, 3)])1948m_, n_ = 6, 91949tv = [[(2 + math.cos(2 * PI * i / m_)) * math.cos(2 * PI * j / n_), (2 + math.cos(2 * PI * i / m_)) * math.sin(2 * PI * j / n_), math.sin(2 * PI * i / m_)] for i in range(m_) for j in range(n_)]1950tt = []1951for i in range(m_):1952    for j in range(n_):1953        a, b, c, d = i * n_ + j, ((i + 1) % m_) * n_ + j, ((i + 1) % m_) * n_ + (j + 1) % n_, i * n_ + (j + 1) % n_1954        tt += [(a, b, c), (a, c, d)]1955d_tor = angle_defect_sum(tv, tt)1956check('T2 the Euler characteristic as a total curvature: the angle defects of a polyhedral surface add up to 2 pi chi', close(d_tet, 4 * PI, 1e-9) and abs(d_tor) < 1e-9,1957      'random tetrahedron %.6f = 4 pi; polyhedral torus %.1e' % (d_tet, d_tor))1958 1959 1960footer()1961