Figurate Numbers is the most comprehensive and specialized library for figurate numbers, developed in Ruby to date. It implements 241 infinite number sequences inspired by the groundbreaking work Figurate Numbers by Elena Deza and Michel Deza, published in 2012.
Install it from the gem repository:
gem install figurate_numbersFigurate Numbers implements 241 infinite sequences using the Enumerator class in Ruby, each categorized by its geometric dimension. It is ideal for use in mathematical modeling, algorithmic composition, and integration with tools like Sonic Pi.
The sequences are organized following the structure of the Figurate Numbers book:
- PlaneFigurateNumbers: 79 sequences (2D)
- SpaceFigurateNumbers: 86 sequences (3D)
- MultiDimensionalFigurateNumbers: 70 sequences (4D and beyond)
- Zoo of figurate-related numbers: 6 additional sequences (included in the MultiDimensional module)
- ArithTransform: p-adic transformations and other arithmetic operations
See detailed list of sequences below
require 'figurate_numbers'
## Using take(integer)
FigurateNumbers.pentatope.take(10)
## Storing and iterating
f = FigurateNumbers.centered_octagonal_pyramid
f.next
f.next
f.nextStarting from version 1.5.0, figurate_numbers not only supports global access via FigurateNumbers and the use of specific classes for separate access, but also introduces new p-adic transformations and other mathematical operations that can be applied directly to sequences.
PlaneFigurateNumbers.polygonal(19)
SpaceFigurateNumbers.rhombic_dodecahedral
MultiDimensionalFigurateNumbers.six_dimensional_hyperoctahedron
seq = MultiDimensionalFigurateNumbers.five_dimensional_hypercube.take(15)
ArithTransform.ring_padic_val(seq, 3)Simply copy the entry point path from the lib/figurate_numbers.rb file where the gem is installed.
require "<PATH>"
pol_num = FigurateNumbers.polygonal(8)
350.times do
play pol_num.next % 12 * 7 # Some mathematical function or transformation
sleep 0.125
end
amp_seq = SpaceFigurateNumbers.centered_hendecagonal_pyramidal
100.times do
sample :bd_sone, amp: ArithTransform.padic_norm(amp_seq.next, 3) # p-adic amplitude control
sleep 0.25
endThe main change introduced after version 1.3.0 is that you must now import the file using require instead of run_file; otherwise, it will not function.
See discussion in the Sonic Pi community thread right here!
polygonal(m)triangularsquarepentagonalhexagonalheptagonaloctagonalnonagonaldecagonalhendecagonaldodecagonaltridecagonaltetradecagonalpentadecagonalhexadecagonalheptadecagonaloctadecagonalnonadecagonalicosagonalicosihenagonalicosidigonalicositrigonalicositetragonalicosipentagonalicosihexagonalicosiheptagonalicosioctagonalicosinonagonaltriacontagonalcentered_triangularcentered_square=diamond(equality only by quantity)centered_pentagonalcentered_hexagonalcentered_heptagonalcentered_octagonalcentered_nonagonalcentered_decagonalcentered_hendecagonalcentered_dodecagonal=star(equality only by quantity)centered_tridecagonalcentered_tetradecagonalcentered_pentadecagonalcentered_hexadecagonalcentered_heptadecagonalcentered_octadecagonalcentered_nonadecagonalcentered_icosagonalcentered_icosihenagonalcentered_icosidigonalcentered_icositrigonalcentered_icositetragonalcentered_icosipentagonalcentered_icosihexagonalcentered_icosiheptagonalcentered_icosioctagonalcentered_icosinonagonalcentered_triacontagonalcentered_mgonal(m)pronic=heteromecic=oblongpoliteimpolitecrossaztec_diamondpolygram(m)=centered_star_polygonal(m)pentagramgnomictruncated_triangulartruncated_squaretruncated_pronictruncated_centered_pol(m)=truncated_centered_mgonal(m)truncated_centered_triangulartruncated_centered_squaretruncated_centered_pentagonaltruncated_centered_hexagonal=truncated_hexgeneralized_mgonal(m, left_index = 0)generalized_pentagonal(left_index = 0)generalized_hexagonal(left_index = 0)generalized_centered_pol(m, left_index = 0)generalized_pronic(left_index = 0)
r_pyramidal(r)triangular_pyramidal = tetrahedralsquare_pyramidal = pyramidalpentagonal_pyramidalhexagonal_pyramidalheptagonal_pyramidaloctagonal_pyramidalnonagonal_pyramidaldecagonal_pyramidalhendecagonal_pyramidaldodecagonal_pyramidaltridecagonal_pyramidaltetradecagonal_pyramidalpentadecagonal_pyramidalhexadecagonal_pyramidalheptadecagonal_pyramidaloctadecagonal_pyramidalnonadecagonal_pyramidalicosagonal_pyramidalicosihenagonal_pyramidalicosidigonal_pyramidalicositrigonal_pyramidalicositetragonal_pyramidalicosipentagonal_pyramidalicosihexagonal_pyramidalicosiheptagonal_pyramidalicosioctagonal_pyramidalicosinonagonal_pyramidaltriacontagonal_pyramidaltriangular_tetrahedral [finite]triangular_square_pyramidal [finite]square_tetrahedral [finite]square_square_pyramidal [finite]tetrahedral_square_pyramidal_number [finite]cubic = perfect_cube != hex_pyramidal (equality only by quantity)tetrahedraloctahedraldodecahedralicosahedraltruncated_tetrahedraltruncated_cubictruncated_octahedralstella_octangulacentered_cuberhombic_dodecahedralhauy_rhombic_dodecahedralcentered_tetrahedron = centered_tetrahedralcentered_square_pyramid = centered_pyramidcentered_mgonal_pyramid(m)centered_pentagonal_pyramid != centered_octahedron (equality only in quantity)centered_hexagonal_pyramidcentered_heptagonal_pyramidcentered_octagonal_pyramidcentered_octahedroncentered_icosahedron = centered_cuboctahedroncentered_dodecahedroncentered_truncated_tetrahedroncentered_truncated_cubecentered_truncated_octahedroncentered_mgonal_pyramidal(m)centered_triangular_pyramidalcentered_square_pyramidalcentered_pentagonal_pyramidalcentered_hexagonal_pyramidal = hex_pyramidalcentered_heptagonal_pyramidalcentered_octagonal_pyramidalcentered_nonagonal_pyramidalcentered_decagonal_pyramidalcentered_hendecagonal_pyramidalcentered_dodecagonal_pyramidalhexagonal_prismmgonal_prism(m)generalized_mgonal_pyramidal(m, left_index = 0)generalized_pentagonal_pyramidal(left_index = 0)generalized_hexagonal_pyramidal(left_index = 0)generalized_cubic(left_index = 0)generalized_octahedral(left_index = 0)generalized_icosahedral(left_index = 0)generalized_dodecahedral(left_index = 0)generalized_centered_cube(left_index = 0)generalized_centered_tetrahedron(left_index = 0)generalized_centered_square_pyramid(left_index = 0)generalized_rhombic_dodecahedral(left_index = 0)generalized_centered_mgonal_pyramidal(m, left_index = 0)generalized_mgonal_prism(m, left_index = 0)generalized_hexagonal_prism(left_index = 0)
pentatope = hypertetrahedral = triangulotriangulark_dimensional_hypertetrahedron(k) = k_hypertetrahedron(k) = regular_k_polytopic(k) = figurate_numbers_of_order_k(k)five_dimensional_hypertetrahedronsix_dimensional_hypertetrahedronbiquadratick_dimensional_hypercube(k) = k_hypercube(k)five_dimensional_hypercubesix_dimensional_hypercubehyperoctahedral = hexadecachoron = four_cross_polytope = four_orthoplexhypericosahedral = tetraplex = polytetrahedron = hexacosichoronhyperdodecahedral = hecatonicosachoron = dodecaplex = polydodecahedronpolyoctahedral = icositetrachoron = octaplex = hyperdiamondfour_dimensional_hyperoctahedronfive_dimensional_hyperoctahedronsix_dimensional_hyperoctahedronseven_dimensional_hyperoctahedroneight_dimensional_hyperoctahedronnine_dimensional_hyperoctahedronten_dimensional_hyperoctahedronk_dimensional_hyperoctahedron(k) = k_cross_polytope(k)four_dimensional_mgonal_pyramidal(m) = mgonal_pyramidal_numbers_of_the_second_order(m)four_dimensional_square_pyramidalfour_dimensional_pentagonal_pyramidalfour_dimensional_hexagonal_pyramidalfour_dimensional_heptagonal_pyramidalfour_dimensional_octagonal_pyramidalfour_dimensional_nonagonal_pyramidalfour_dimensional_decagonal_pyramidalfour_dimensional_hendecagonal_pyramidalfour_dimensional_dodecagonal_pyramidalk_dimensional_mgonal_pyramidal(k, m) = mgonal_pyramidal_of_the_k_2_th_order(k, m)five_dimensional_mgonal_pyramidal(m)five_dimensional_square_pyramidalfive_dimensional_pentagonal_pyramidalfive_dimensional_hexagonal_pyramidalfive_dimensional_heptagonal_pyramidalfive_dimensional_octagonal_pyramidalsix_dimensional_mgonal_pyramidal(m)six_dimensional_square_pyramidalsix_dimensional_pentagonal_pyramidalsix_dimensional_hexagonal_pyramidalsix_dimensional_heptagonal_pyramidalsix_dimensional_octagonal_pyramidalcentered_biquadratick_dimensional_centered_hypercube(k)five_dimensional_centered_hypercubesix_dimensional_centered_hypercubecentered_polytopek_dimensional_centered_hypertetrahedron(k)five_dimensional_centered_hypertetrahedron(k)six_dimensional_centered_hypertetrahedron(k)centered_hyperoctahedral = orthoplexnexus(k)k_dimensional_centered_hyperoctahedron(k)five_dimensional_centered_hyperoctahedronsix_dimensional_centered_hyperoctahedrongeneralized_pentatope(left_index = 0)generalized_k_dimensional_hypertetrahedron(k = 5, left_index = 0)generalized_biquadratic(left_index = 0)generalized_k_dimensional_hypercube(k = 5, left_index = 0)generalized_hyperoctahedral(left_index = 0)generalized_k_dimensional_hyperoctahedron(k = 5, left_index = 0) [even or odd dimension only changes sign]generalized_hyperdodecahedral(left_index = 0)generalized_hypericosahedral(left_index = 0)generalized_polyoctahedral(left_index = 0)generalized_k_dimensional_mgonal_pyramidal(k, m, left_index = 0)generalized_k_dimensional_centered_hypercube(k, left_index = 0)generalized_k_dimensional_centered_hypertetrahedron(k, left_index = 0)[provisional symmetry]generalized_k_dimensional_centered_hyperoctahedron(k, left_index = 0)[provisional symmetry]generalized_nexus(k, left_index = 0) [even or odd dimension only changes sign]
cuban_numbers = cuban_prime_numbersquartan_numbers [Needs to improve the algorithmic complexity for n > 70]pell_numberscarmichael_numbers [Needs to improve the algorithmic complexity for n > 20]stern_prime_numbers(infty = false) [Quick calculations up to 8 terms]apocalyptic_numbers
ArithTransform.n_residue(n, pow, mod)ArithTransform.pc_inversion(n, mod)ArithTransform.padic_val(n, p)ArithTransform.ring_padic_val(seq, p)ArithTransform.padic_norm(n, p)ArithTransform.ring_padic_norm(seq, p)ArithTransform.padic_expansion(n, p, precision = 11, reverse: false)ArithTransform.ring_padic_expansion(seq, p, precision = 11, reverse: false)
-
Chapter 1, page 6: The formula for Square in the table is given as:
1/2 (n^2 - 0 * n)It should be corrected to:1/2 (2n^2 - 0 * n) -
Chapter 1, page 51: The formula for Centered icosihexagonal numbers is listed as:
1/3n^2 - 13n + 1with values546, 728, 936, 1170. The correct formula and values are:13n^2 - 13n + 1with values547, 729, 937, 1171. -
Chapter 1, page 51: The value for Centered icosiheptagonal number is given as
972. The correct value is973. -
Chapter 1, page 51: The value for Centered icosioctagonal number is given as
84. The correct value is85. -
Chapter 1, page 65: The term polite numbers is misspelled as:
inpolite numbersIt should read:impolite numbers -
Chapter 1, page 72: The formula for truncated centered pentagonal numbers (TCSS_5) is:
TCSS_5(n) = (35n^2 - 55n) / 2 + 3It should be:TCSS_5(n) = (35n^2 - 55n) / 2 + 11 -
Chapter 2, page 92: The formula for octagonal pyramidal numbers is stated as:
n(n+1)(6n-1) / 6The correct formula is:n(n+1)(6n-3) / 6 -
Chapter 2, page 140: The sequence for centered square pyramidal numbers is listed as:
1, 6, 19, 44, 85, 111, 146, 231, ...The number111should be excluded, resulting in:1, 6, 19, 44, 85, 146, 231, ... -
Chapter 2, page 155: The formula for generalized centered tetrahedron numbers (S_3^3) is:
S_3^3(n) = ((2n - 1)(n^2 + n + 3)) / 3It should include a negative sign:S_3^3(n) = ((2n - 1)(n^2 - n + 3)) / 3 -
Chapter 2, page 156: The formula for generalized centered square pyramid numbers (S_4^3) is:
S_4^3(n) = ((2n - 1)(n^2 - n + 2)^2) / 3The correct formula is:S_4^3(n) = ((2n - 1)(n^2 - n + 2)) / 2 -
Chapter 3, page 188: The term hyperoctahedral numbers is incorrectly called:
hexadecahoron numbersIt should be:hexadecachoron numbers -
Chapter 3, page 190: The term hypericosahedral numbers is incorrectly written as:
hexacisihoron numbersIt should be:hexacosichoron numbers
