.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/topology/complexes/plot_03_mayer_vietoris_sequence.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_topology_complexes_plot_03_mayer_vietoris_sequence.py: The Mayer-Vietoris sequence (1929-1930) ======================================= Walther Mayer and Leopold Vietoris computed the homology of a union from its pieces through the long exact sequence .. math:: \cdots \to H_k(A\cap B) \to H_k(A)\oplus H_k(B) \to H_k(A\cup B) \to H_{k-1}(A\cap B) \to \cdots Cut a torus into two annuli :math:`A` and :math:`B`. They meet in two circles. Exactness, plus the rank of the map induced by the inclusions, predicts :math:`\beta(T^2) = (1, 2, 1)`. The second loop of the torus comes from the connecting map :math:`\delta`. .. GENERATED FROM PYTHON SOURCE LINES 17-35 .. code-block:: Python import matplotlib.pyplot as plt from mathematicskit.topology import circle, mayer_vietoris, sphere, torus from mathematicskit.topology.visualizers import plot_complex T = torus(16, 6) A = T.induced_subcomplex([v for v in T.vertices if v // 6 in range(9)]) B = T.induced_subcomplex([v for v in T.vertices if v // 6 in (*range(8, 16), 0)]) cases = {"torus = annulus ∪ annulus": (A, B)} C = circle(8) cases["circle = arc ∪ arc"] = (C.induced_subcomplex(range(5)), C.induced_subcomplex([4, 5, 6, 7, 0])) S = sphere(2, "cross_polytope") cases["sphere = disc ∪ disc"] = (S.induced_subcomplex([0, 1, 2, 3, 4]), S.induced_subcomplex([0, 1, 2, 3, 5])) for name, (X, Y) in cases.items(): r = mayer_vietoris(X, Y) print(f"{name}: beta(A) = {r.betti_a}, beta(B) = {r.betti_b}, beta(A∩B) = {r.betti_intersection}, rank i_* = {r.rank_inclusion}") print(f"{'':>26} predicted beta(A∪B) = {r.predicted_union}, computed = {r.betti_union}") .. rst-class:: sphx-glr-script-out .. code-block:: none torus = annulus ∪ annulus: beta(A) = (1, 1, 0), beta(B) = (1, 1, 0), beta(A∩B) = (2, 2), rank i_* = (1, 1, 0) predicted beta(A∪B) = (1, 2, 1), computed = (1, 2, 1) circle = arc ∪ arc: beta(A) = (1, 0), beta(B) = (1, 0), beta(A∩B) = (2,), rank i_* = (1, 0) predicted beta(A∪B) = (1, 1), computed = (1, 1) sphere = disc ∪ disc: beta(A) = (1, 0, 0), beta(B) = (1, 0, 0), beta(A∩B) = (1, 1), rank i_* = (1, 0, 0) predicted beta(A∪B) = (1, 0, 1), computed = (1, 0, 1) .. GENERATED FROM PYTHON SOURCE LINES 36-38 The two annuli and their intersection ------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 38-48 .. code-block:: Python fig = plt.figure(figsize=(7, 6)) ax = fig.add_subplot(projection="3d", computed_zorder=False) plot_complex(A, ax=ax, face_color="tab:blue", alpha=0.35, vertex_size=0) plot_complex(B, ax=ax, face_color="tab:orange", alpha=0.35, vertex_size=0) for edge in (A & B).simplices(1): ax.plot(*T.coordinates[list(edge)].T, color="k", lw=3) ax.view_init(elev=50, azim=-60) ax.set_axis_off() ax.set_title("A (blue) ∪ B (orange) = torus; A ∩ B = two circles") .. image-sg:: /api/gallery/topology/complexes/images/sphx_glr_plot_03_mayer_vietoris_sequence_001.png :alt: A (blue) ∪ B (orange) = torus; A ∩ B = two circles :srcset: /api/gallery/topology/complexes/images/sphx_glr_plot_03_mayer_vietoris_sequence_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Text(0.5, 1.0, 'A (blue) ∪ B (orange) = torus; A ∩ B = two circles') .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.032 seconds) .. _sphx_glr_download_api_gallery_topology_complexes_plot_03_mayer_vietoris_sequence.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/topology/complexes/plot_03_mayer_vietoris_sequence.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_mayer_vietoris_sequence.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_mayer_vietoris_sequence.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_mayer_vietoris_sequence.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_