Figurate Numbers
figurate_numbers
is a Ruby module that implements 239 infinite number sequences
based on the formulas from the wonderful book
Figurate Numbers (2012) by Elena Deza and Michel Deza.
This implementation uses the Enumerator class to deal with INFINITE SEQUENCES.
Following the order of the book, the methods are divided into 3 types according to the spatial dimension (see complete list below):
- Plane figurate numbers implemented =
79
- Space figurate numbers implemented =
86
- Multidimensional figurate numbers implemented =
70
- Zoo of figurate-related numbers implemented =
6
- [x] TOTAL =
241
infinite sequences of figurate numbers implemented
Installation and use
gem install figurate_numbers
How to use in Ruby
If the sequence is defined with lazy
, to make the numbers explicit we must include the converter method to_a
at the end.
require 'figurate_numbers'
## Using take(integer)
FigurateNumbers.pronic_numbers.take(10).to_a
## Storing and iterating
f = FigurateNumbers.centered_octagonal_pyramid_numbers
f.next
f.next
f.next
How to use in Sonic Pi
- Locate or download the file in the path
lib/figurate_numbers.rb
- Drag the file to a buffer in Sonic Pi (this generates the
<PATH>
)
run_file "<PATH>"
pol_num = FigurateNumbers.polygonal_numbers(8)
80.times do
play pol_num.next % 12 * 7 # Some mathematical function or transformation
sleep 0.25
end
List of implemented sequences
- Note that
=
means that you can call the same sequence with different names.
1. Plane Figurate Numbers
polygonal_numbers(m)
triangular_numbers
square_numbers
pentagonal_numbers
hexagonal_numbers
heptagonal_numbers
octagonal_numbers
nonagonal_numbers
decagonal_numbers
hendecagonal_numbers
dodecagonal_numbers
tridecagonal_numbers
tetradecagonal_numbers
pentadecagonal_numbers
hexadecagonal_numbers
heptadecagonal_numbers
octadecagonal_numbers
nonadecagonal_numbers
icosagonal_numbers
icosihenagonal_numbers
icosidigonal_numbers
icositrigonal_numbers
icositetragonal_numbers
icosipentagonal_numbers
icosihexagonal_numbers
icosiheptagonal_numbers
icosioctagonal_numbers
icosinonagonal_numbers
triacontagonal_numbers
centered_triangular_numbers
centered_square_numbers = diamond_numbers (equality only by quantity)
centered_pentagonal_numbers
centered_hexagonal_numbers
centered_heptagonal_numbers
centered_octagonal_numbers
centered_nonagonal_numbers
centered_decagonal_numbers
centered_hendecagonal_numbers
centered_dodecagonal_numbers = star_numbers (equality only by quantity)
centered_tridecagonal_numbers
centered_tetradecagonal_numbers
centered_pentadecagonal_numbers
centered_hexadecagonal_numbers
centered_heptadecagonal_numbers
centered_octadecagonal_numbers
centered_nonadecagonal_numbers
centered_icosagonal_numbers
centered_icosihenagonal_numbers
centered_icosidigonal_numbers
centered_icositrigonal_numbers
centered_icositetragonal_numbers
centered_icosipentagonal_numbers
centered_icosihexagonal_numbers
centered_icosiheptagonal_numbers
centered_icosioctagonal_numbers
centered_icosinonagonal_numbers
centered_triacontagonal_numbers
centered_mgonal_numbers(m)
pronic_numbers = heteromecic_numbers = oblong_numbers
polite_numbers
impolite_numbers
cross_numbers
aztec_diamond_numbers
polygram_numbers(m) = centered_star_polygonal_numbers(m)
pentagram_numbers
gnomic_numbers
truncated_triangular_numbers
truncated_square_numbers
truncated_pronic_numbers
truncated_centered_pol_numbers(m) = truncated_centered_mgonal_numbers(m)
truncated_centered_triangular_numbers
truncated_centered_square_numbers
truncated_centered_pentagonal_numbers
truncated_centered_hexagonal_numbers = truncated_hex_numbers
generalized_mgonal_numbers(m, left_index = 0)
generalized_pentagonal_numbers(left_index = 0)
generalized_hexagonal_numbers(left_index = 0)
generalized_centered_pol_numbers(m, left_index = 0)
generalized_pronic_numbers(left_index = 0)
2. Space Figurate Numbers
r_pyramidal_numbers(r)
triangular_pyramidal_numbers = tetrahedral_numbers
square_pyramidal_numbers = pyramidal_numbers
pentagonal_pyramidal_numbers
hexagonal_pyramidal_numbers
heptagonal_pyramidal_numbers
octagonal_pyramidal_numbers
nonagonal_pyramidal_numbers
decagonal_pyramidal_numbers
hendecagonal_pyramidal_numbers
dodecagonal_pyramidal_numbers
tridecagonal_pyramidal_numbers
tetradecagonal_pyramidal_numbers
pentadecagonal_pyramidal_numbers
hexadecagonal_pyramidal_numbers
heptadecagonal_pyramidal_numbers
octadecagonal_pyramidal_numbers
nonadecagonal_pyramidal_numbers
icosagonal_pyramidal_numbers
icosihenagonal_pyramidal_numbers
icosidigonal_pyramidal_numbers
icositrigonal_pyramidal_numbers
icositetragonal_pyramidal_numbers
icosipentagonal_pyramidal_numbers
icosihexagonal_pyramidal_numbers
icosiheptagonal_pyramidal_numbers
icosioctagonal_pyramidal_numbers
icosinonagonal_pyramidal_numbers
triacontagonal_pyramidal_numbers
triangular_tetrahedral_numbers [finite]
triangular_square_pyramidal_numbers [finite]
square_tetrahedral_numbers [finite]
square_square_pyramidal_numbers [finite]
tetrahedral_square_pyramidal_number [finite]
cubic_numbers = perfect_cube_numbers != hex_pyramidal_numbers (equality only by quantity)
tetrahedral_numbers
octahedral_numbers
dodecahedral_numbers
icosahedral_numbers
truncated_tetrahedral_numbers
truncated_cubic_numbers
truncated_octahedral_numbers
stella_octangula_numbers
centered_cube_numbers
rhombic_dodecahedral_numbers
hauy_rhombic_dodecahedral_numbers
centered_tetrahedron_numbers = centered_tetrahedral_numbers
centered_square_pyramid_numbers = centered_pyramid_numbers
centered_mgonal_pyramid_numbers(m)
centered_pentagonal_pyramid_numbers != centered_octahedron_numbers (equality only in quantity)
centered_hexagonal_pyramid_numbers
centered_heptagonal_pyramid_numbers
centered_octagonal_pyramid_numbers
centered_octahedron_numbers
centered_icosahedron_numbers = centered_cuboctahedron_numbers
centered_dodecahedron_numbers
centered_truncated_tetrahedron_numbers
centered_truncated_cube_numbers
centered_truncated_octahedron_numbers
centered_mgonal_pyramidal_numbers(m)
centered_triangular_pyramidal_numbers
centered_square_pyramidal_numbers
centered_pentagonal_pyramidal_numbers
centered_hexagonal_pyramidal_numbers = hex_pyramidal_numbers
centered_heptagonal_pyramidal_numbers
centered_octagonal_pyramidal_numbers
centered_nonagonal_pyramidal_numbers
centered_decagonal_pyramidal_numbers
centered_hendecagonal_pyramidal_numbers
centered_dodecagonal_pyramidal_numbers
hexagonal_prism_numbers
mgonal_prism_numbers(m)
generalized_mgonal_pyramidal_numbers(m, left_index = 0)
generalized_pentagonal_pyramidal_numbers(left_index = 0)
generalized_hexagonal_pyramidal_numbers(left_index = 0)
generalized_cubic_numbers(left_index = 0)
generalized_octahedral_numbers(left_index = 0)
generalized_icosahedral_numbers(left_index = 0)
generalized_dodecahedral_numbers(left_index = 0)
generalized_centered_cube_numbers(left_index = 0)
generalized_centered_tetrahedron_numbers(left_index = 0)
generalized_centered_square_pyramid_numbers(left_index = 0)
generalized_rhombic_dodecahedral_numbers(left_index = 0)
generalized_centered_mgonal_pyramidal_numbers(m, left_index = 0)
generalized_mgonal_prism_numbers(m, left_index = 0)
generalized_hexagonal_prism_numbers(left_index = 0)
3. Multidimensional figurate numbers
pentatope_numbers = hypertetrahedral_numbers = triangulotriangular_numbers
k_dimensional_hypertetrahedron_numbers(k) = k_hypertetrahedron_numbers(k) = regular_k_polytopic_numbers(k) = figurate_numbers_of_order_k(k)
five_dimensional_hypertetrahedron_numbers
six_dimensional_hypertetrahedron_numbers
biquadratic_numbers
k_dimensional_hypercube_numbers(k) = k_hypercube_numbers(k)
five_dimensional_hypercube_numbers
six_dimensional_hypercube_numbers
hyperoctahedral_numbers = hexadecachoron_numbers = four_cross_polytope_numbers = four_orthoplex_numbers
hypericosahedral_numbers = tetraplex_numbers = polytetrahedron_numbers = hexacosichoron_numbers
hyperdodecahedral_numbers = hecatonicosachoron_numbers = dodecaplex_numbers = polydodecahedron_numbers
polyoctahedral_numbers = icositetrachoron_numbers = octaplex_numbers = hyperdiamond_numbers
four_dimensional_hyperoctahedron_numbers
five_dimensional_hyperoctahedron_numbers
six_dimensional_hyperoctahedron_numbers
seven_dimensional_hyperoctahedron_numbers
eight_dimensional_hyperoctahedron_numbers
nine_dimensional_hyperoctahedron_numbers
ten_dimensional_hyperoctahedron_numbers
k_dimensional_hyperoctahedron_numbers(k) = k_cross_polytope_numbers(k)
four_dimensional_mgonal_pyramidal_numbers(m) = mgonal_pyramidal_numbers_of_the_second_order(m)
four_dimensional_square_pyramidal_numbers
four_dimensional_pentagonal_pyramidal_numbers
four_dimensional_hexagonal_pyramidal_numbers
four_dimensional_heptagonal_pyramidal_numbers
four_dimensional_octagonal_pyramidal_numbers
four_dimensional_nonagonal_pyramidal_numbers
four_dimensional_decagonal_pyramidal_numbers
four_dimensional_hendecagonal_pyramidal_numbers
four_dimensional_dodecagonal_pyramidal_numbers
k_dimensional_mgonal_pyramidal_numbers(k, m) = mgonal_pyramidal_numbers_of_the_k_2_th_order(k, m)
five_dimensional_mgonal_pyramidal_numbers(m)
five_dimensional_square_pyramidal_numbers
five_dimensional_pentagonal_pyramidal_numbers
five_dimensional_hexagonal_pyramidal_numbers
five_dimensional_heptagonal_pyramidal_numbers
five_dimensional_octagonal_pyramidal_numbers
six_dimensional_mgonal_pyramidal_numbers(m)
six_dimensional_square_pyramidal_numbers
six_dimensional_pentagonal_pyramidal_numbers
six_dimensional_hexagonal_pyramidal_numbers
six_dimensional_heptagonal_pyramidal_numbers
six_dimensional_octagonal_pyramidal_numbers
centered_biquadratic_numbers
k_dimensional_centered_hypercube_numbers(k)
five_dimensional_centered_hypercube_numbers
six_dimensional_centered_hypercube_numbers
centered_polytope_numbers
k_dimensional_centered_hypertetrahedron_numbers(k)
five_dimensional_centered_hypertetrahedron_numbers(k)
six_dimensional_centered_hypertetrahedron_numbers(k)
centered_hyperoctahedral_numbers = orthoplex_numbers
nexus_numbers(k)
k_dimensional_centered_hyperoctahedron_numbers(k)
five_dimensional_centered_hyperoctahedron_numbers
six_dimensional_centered_hyperoctahedron_numbers
generalized_pentatope_numbers(left_index = 0)
generalized_k_dimensional_hypertetrahedron_numbers(k = 5, left_index = 0)
generalized_biquadratic_numbers(left_index = 0)
generalized_k_dimensional_hypercube_numbers(k = 5, left_index = 0)
generalized_hyperoctahedral_numbers(left_index = 0)
generalized_k_dimensional_hyperoctahedron_numbers(k = 5, left_index = 0) [even or odd dimension only changes sign]
generalized_hyperdodecahedral_numbers(left_index = 0)
generalized_hypericosahedral_numbers(left_index = 0)
generalized_polyoctahedral_numbers(left_index = 0)
generalized_k_dimensional_mgonal_pyramidal_numbers(k, m, left_index = 0)
generalized_k_dimensional_centered_hypercube_numbers(k, left_index = 0)
generalized_k_dimensional_centered_hypertetrahedron_numbers(k, left_index = 0)[provisional symmetry]
generalized_k_dimensional_centered_hyperoctahedron_numbers(k, left_index = 0)[provisional symmetry]
generalized_nexus_numbers(k, left_index = 0) [even or odd dimension only changes sign]
6. Zoo of figurate-related numbers
cuban_numbers = cuban_prime_numbers
quartan_numbers [Needs to improve the algorithmic complexity for n > 70]
pell_numbers
carmichael_numbers [Needs to improve the algorithmic complexity for n > 20]
stern_prime_numbers(infty = false) [Quick calculations up to 8 terms]
apocalyptic_numbers
Errata
- Chapter 1, formula in the table on page 6 says:
| Name | Formula | |
| ------ | ------------------- | --- |
| Square | 1/2 (n^2 - 0 * n)
| |
It should be:
| Name | Formula | |
| ------ | -------------------- | --- |
| Square | 1/2 (2n^2 - 0 * n)
| |
- Chapter 1, formula in the table on page 51 says:
| Name | Formula | |
| -------------------- | --------------------- | --------------------- |
| Cent. icosihexagonal | 1/3n^2 - 13 * n + 1
| 546, 728, 936, 1170
|
It should be:
| Name | Formula | |
| -------------------- | --------------------- | --------------------- |
| Cent. icosihexagonal | 1/3n^2 - 13 * n + 1
| 547, 729, 937, 1171
|
- Chapter 1, formula in the table on page 51 says:
| Name | Formula | |
| --------------------- | ------- | ----- |
| Cent. icosiheptagonal | | 972
|
It should be:
| Name | Formula | |
| --------------------- | ------- | ----- |
| Cent. icosiheptagonal | | 973
|
- Chapter 1, formula in the table on page 51 says:
| Name | Formula | |
| -------------------- | ------- | ---- |
| Cent. icosioctagonal | | 84
|
It should be:
| Name | Formula | |
| -------------------- | ------- | ---- |
| Cent. icosioctagonal | | 85
|
- Chapter 1, page 65 (polite numbers) says:
>
inpolite numbers
It should read:
impolite numbers
- Chapter 1, formula (truncated centered pentagonal numbers) on page 72 says:
>
TCSS_5(n) = (35n^2 - 55n) / 2 + 3
It should be:
TCSS_5(n) = (35n^2 - 55n) / 2 + 11
- Chapter 2, formula of octagonal pyramidal number on page 92 says:
>
n(n+1)(6n-1) / 6
It should be:
n(n+1)(6n-3) / 6
- Chapter 2, page 140 says: > centered square pyramidal numbers are 1, 6, 19, 44, 85, 111, 146, 231, ...
This sequence must exclude the number 111:
centered square pyramidal numbers are 1, 6, 19, 44, 85, ~~111~~, 146, 231, ...
- Chapter 2, page 155 (generalized centered tetrahedron numbers) says:
>
S_3^3(n) = ((2n - 1)(n^2 + n + 3)) / 3
Formula must have a negative sign:
S_3^3(n) = ((2n - 1)(n^2 - n + 3)) / 3
- Chapter 2, page 156 (generalized centered square pyramid numbers) says:
>
S_4^3(n) = ((2n - 1) * (n^2 - n + 2)^2) / 3
Formula must write:
S_4^3(n) = ((2n - 1) * (n^2 - n + 2)) / 2
- Chapter 3, page 188 (hyperoctahedral numbers) says:
>
hexadecahoron numbers
It should read:
hexadecachoron numbers
- Chapter 3, page 190 (hypericosahedral numbers) says:
>
hexacisihoron numbers
It should read:
hexacosichoron numbers