.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/abstract_algebra/subgroups/plot_01_lagranges_theorem.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_abstract_algebra_subgroups_plot_01_lagranges_theorem.py: Lagrange's theorem: subgroup order divides group order ============================================================== Enumerates every subgroup of Z_12 and confirms each subgroup's order divides 12, and that its left cosets partition the whole group. .. GENERATED FROM PYTHON SOURCE LINES 10-12 .. code-block:: Python from mathematicskit.abstract_algebra import CyclicGroup, all_subgroups, cyclic_subgroup, left_cosets .. GENERATED FROM PYTHON SOURCE LINES 13-15 Every subgroup of Z_12 ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 15-20 .. code-block:: Python g = CyclicGroup(12) for subgroup in sorted(all_subgroups(g), key=len): print(f"subgroup of order {len(subgroup)}: {sorted(subgroup)} (divides 12: {12 % len(subgroup) == 0})") .. rst-class:: sphx-glr-script-out .. code-block:: none subgroup of order 1: [0] (divides 12: True) subgroup of order 2: [0, 6] (divides 12: True) subgroup of order 3: [0, 4, 8] (divides 12: True) subgroup of order 4: [0, 3, 6, 9] (divides 12: True) subgroup of order 6: [0, 2, 4, 6, 8, 10] (divides 12: True) subgroup of order 12: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] (divides 12: True) .. GENERATED FROM PYTHON SOURCE LINES 21-23 Cosets of the order-3 subgroup {0, 4, 8} ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 23-29 .. code-block:: Python h = cyclic_subgroup(g, 4) cosets = left_cosets(g, h) print(f"\nsubgroup H = {h}") print(f"cosets of H: {cosets}") print(f"index [G:H] = {len(cosets)} = |G|/|H| = {g.order}/{len(h)} = {g.order // len(h)}") .. rst-class:: sphx-glr-script-out .. code-block:: none subgroup H = [0, 4, 8] cosets of H: [[0, 4, 8], [1, 5, 9], [2, 6, 10], [3, 7, 11]] index [G:H] = 4 = |G|/|H| = 12/3 = 4 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.001 seconds) .. _sphx_glr_download_api_gallery_abstract_algebra_subgroups_plot_01_lagranges_theorem.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_lagranges_theorem.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_lagranges_theorem.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_lagranges_theorem.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_