.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/abstract_algebra/structure/plot_01_cauchy_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_structure_plot_01_cauchy_theorem.py: Cauchy's theorem: elements of prime order =============================================== For each prime p dividing a group's order, finds the elements of order p, and checks McKay's refinement that their number is congruent to -1 modulo p. .. GENERATED FROM PYTHON SOURCE LINES 11-15 .. code-block:: Python import matplotlib.pyplot as plt from mathematicskit.abstract_algebra import DihedralGroup, PermutationGroup, QuaternionGroup, elements_of_order .. GENERATED FROM PYTHON SOURCE LINES 16-18 Elements of each prime order ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 18-28 .. code-block:: Python groups = {"S_4": PermutationGroup(4), "D_5": DihedralGroup(5), "Q_8": QuaternionGroup(), "S_5": PermutationGroup(5)} counts = {} for name, group in groups.items(): for p in (2, 3, 5): if group.order % p == 0: count = len(elements_of_order(group, p)) counts[(name, p)] = count print(f"{name} (order {group.order}): {count} elements of order {p}, count mod {p} = {count % p}") .. rst-class:: sphx-glr-script-out .. code-block:: none S_4 (order 24): 9 elements of order 2, count mod 2 = 1 S_4 (order 24): 8 elements of order 3, count mod 3 = 2 D_5 (order 10): 5 elements of order 2, count mod 2 = 1 D_5 (order 10): 4 elements of order 5, count mod 5 = 4 Q_8 (order 8): 1 elements of order 2, count mod 2 = 1 S_5 (order 120): 25 elements of order 2, count mod 2 = 1 S_5 (order 120): 20 elements of order 3, count mod 3 = 2 S_5 (order 120): 24 elements of order 5, count mod 5 = 4 .. GENERATED FROM PYTHON SOURCE LINES 29-31 Every count is -1 mod p ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 31-39 .. code-block:: Python labels = [f"{name}, p={p}" for name, p in counts] fig, ax = plt.subplots(figsize=(8, 3.5)) ax.bar(labels, list(counts.values()), color="tab:blue") ax.set_ylabel("elements of order p") ax.set_title("Cauchy's theorem: every prime divisor p of |G| has elements of order p") ax.tick_params(axis="x", rotation=30) fig.tight_layout() .. image-sg:: /api/gallery/abstract_algebra/structure/images/sphx_glr_plot_01_cauchy_theorem_001.png :alt: Cauchy's theorem: every prime divisor p of |G| has elements of order p :srcset: /api/gallery/abstract_algebra/structure/images/sphx_glr_plot_01_cauchy_theorem_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.035 seconds) .. _sphx_glr_download_api_gallery_abstract_algebra_structure_plot_01_cauchy_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_cauchy_theorem.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_cauchy_theorem.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_cauchy_theorem.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_