.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/topology/surfaces/plot_02_klein_bottle_torsion.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_surfaces_plot_02_klein_bottle_torsion.py: Klein's bottle and torsion in homology (1882) ============================================= Felix Klein's bottle glues a cylinder's ends with a reflection. It is a closed surface with one side and no edge. It cannot sit in :math:`\mathbb{R}^3` without crossing itself, as the figure-8 immersion below does. Its first homology group is :math:`\mathbb{Z} \oplus \mathbb{Z}/2`: a loop that is not a boundary but whose double is. The :math:`\mathbb{Z}/2` torsion hides from rational Betti numbers and shows up mod 2. .. GENERATED FROM PYTHON SOURCE LINES 15-26 .. code-block:: Python import matplotlib.pyplot as plt from mathematicskit.topology import betti_numbers, homology, is_orientable, klein_bottle, torus from mathematicskit.topology.visualizers import plot_complex K = klein_bottle(40, 24) T = torus(6, 4) for name, X in (("torus", T), ("Klein bottle", klein_bottle(6, 4))): print(f"{name:>12}: {homology(X)}; orientable = {is_orientable(X)}") print(f"{'':>12} Betti over Q: {betti_numbers(X)}, over Z/2: {betti_numbers(X, field=2)}, over Z/3: {betti_numbers(X, field=3)}") .. rst-class:: sphx-glr-script-out .. code-block:: none torus: H_0 = Z, H_1 = Z^2, H_2 = Z; orientable = True Betti over Q: (1, 2, 1), over Z/2: (1, 2, 1), over Z/3: (1, 2, 1) Klein bottle: H_0 = Z, H_1 = Z + Z/2, H_2 = 0; orientable = False Betti over Q: (1, 1, 0), over Z/2: (1, 2, 1), over Z/3: (1, 1, 0) .. GENERATED FROM PYTHON SOURCE LINES 27-29 The figure-8 immersion ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 29-37 .. code-block:: Python fig = plt.figure(figsize=(7, 6)) ax = fig.add_subplot(projection="3d") heights = K.coordinates[:, 2] plot_complex(K, ax=ax, face_values=[heights[list(t)].mean() for t in K.simplices(2)], alpha=0.85, vertex_size=0) ax.view_init(elev=30, azim=-50) ax.set_axis_off() ax.set_title(r"Klein bottle: $H_1 = \mathbb{Z} \oplus \mathbb{Z}/2$") .. image-sg:: /api/gallery/topology/surfaces/images/sphx_glr_plot_02_klein_bottle_torsion_001.png :alt: Klein bottle: $H_1 = \mathbb{Z} \oplus \mathbb{Z}/2$ :srcset: /api/gallery/topology/surfaces/images/sphx_glr_plot_02_klein_bottle_torsion_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Text(0.5, 1.0, 'Klein bottle: $H_1 = \\mathbb{Z} \\oplus \\mathbb{Z}/2$') .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.060 seconds) .. _sphx_glr_download_api_gallery_topology_surfaces_plot_02_klein_bottle_torsion.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/surfaces/plot_02_klein_bottle_torsion.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_klein_bottle_torsion.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_klein_bottle_torsion.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_klein_bottle_torsion.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_