.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/combinatorics/partitions/plot_01_partitions_and_young_diagrams.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_combinatorics_partitions_plot_01_partitions_and_young_diagrams.py: Integer partitions, the partition function, and Young diagrams ====================================================================== Enumerates every partition of 6, checks the count against the partition function ``p(6)``, and visualizes one partition's Young diagram and its conjugate. .. GENERATED FROM PYTHON SOURCE LINES 11-14 .. code-block:: Python from mathematicskit.combinatorics import YoungDiagram, integer_partitions, partition_function from mathematicskit.combinatorics.visualizers.plots import plot_partition_counts, plot_young_diagram .. GENERATED FROM PYTHON SOURCE LINES 15-17 Enumerate the partitions of 6 ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 17-23 .. code-block:: Python partitions = integer_partitions(6) print(f"p(6) = {partition_function(6)}, enumerated {len(partitions)} partitions:") for p in partitions: print(" ", p) .. rst-class:: sphx-glr-script-out .. code-block:: none p(6) = 11, enumerated 11 partitions: [6] [5, 1] [4, 2] [4, 1, 1] [3, 3] [3, 2, 1] [3, 1, 1, 1] [2, 2, 2] [2, 2, 1, 1] [2, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1] .. GENERATED FROM PYTHON SOURCE LINES 24-26 A Young diagram and its conjugate ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 26-34 .. code-block:: Python diagram = YoungDiagram([4, 2, 1]) print("\nFerrers diagram of (4, 2, 1):") print(diagram.ferrers_diagram()) print("conjugate partition:", diagram.conjugate().parts) plot_young_diagram(diagram) .. image-sg:: /api/gallery/combinatorics/partitions/images/sphx_glr_plot_01_partitions_and_young_diagrams_001.png :alt: Young diagram of [4, 2, 1] :srcset: /api/gallery/combinatorics/partitions/images/sphx_glr_plot_01_partitions_and_young_diagrams_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Ferrers diagram of (4, 2, 1): **** ** * conjugate partition: [3, 2, 1, 1] .. GENERATED FROM PYTHON SOURCE LINES 35-37 Growth of the partition function ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 37-39 .. code-block:: Python plot_partition_counts(30) .. image-sg:: /api/gallery/combinatorics/partitions/images/sphx_glr_plot_01_partitions_and_young_diagrams_002.png :alt: Integer partition function :srcset: /api/gallery/combinatorics/partitions/images/sphx_glr_plot_01_partitions_and_young_diagrams_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.042 seconds) .. _sphx_glr_download_api_gallery_combinatorics_partitions_plot_01_partitions_and_young_diagrams.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_partitions_and_young_diagrams.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_partitions_and_young_diagrams.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_partitions_and_young_diagrams.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_