Advanced Theory
Based on Deza & Deza (2012), many figurate numbers admit extensions beyond their standard index range or dimensional setting. In particular, some classical families can be generalized to negative or shifted indices while preserving their polynomial form.
A key example is the generalized pentagonal numbers, defined by evaluating the same polynomial over the integers:
For negative indices,
This yields the interleaved sequence
Reordering by gives
corresponding to OEIS A001318 and appearing in the pentagonal number theorem proved by Euler:
In general, FigurateNum generators evaluate the polynomial sequentially over integer values of .
Alternative enumerations (e.g. symmetric indexing ) are not part of the computational model, but can be obtained by reordering evaluations.
Computational Representation
In Deza & Deza (2012), figurate numbers are given both recursively and through closed-form polynomial formulas. The hypertetrahedral numbers illustrate this well: they can be expressed through recursive definitions, factorial expressions, binomial coefficients, or Gamma-function identities, all describing the same mathematical object.
For example, since
the recursive construction for a -dimensional family is given by
with initial condition
Implementation
By default, FigurateNum uses optimized, mathematically equivalent implementations that are significantly faster, especially for multidimensional figurate numbers. Incremental computation and precomputed values allow terms to be generated efficiently without repeatedly evaluating factorials or traversing recursive definitions.
The default implementation uses an incremental binomial update:
def k_dimensional_hypertetrahedron(k: int) -> Generator[int]:
delta = 1
bin_coeff = 1
while True:
yield bin_coeff
bin_coeff = bin_coeff * (delta + k) // delta
delta += 1
The original formulations from the literature remain available through the corresponding *_from_book() methods for reference, validation, and testing.