Tcl Library Source Code

Bounty program for improvements to Tcl and certain Tcl packages.

[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]


math::figurate - Evaluate figurate numbers

Table Of Contents


package require Tcl 8.6
package require math::figurate 1.0

::math::figurate::sum_sequence n
::math::figurate::sum_squares n
::math::figurate::sum_cubes n
::math::figurate::sum_4th_power n
::math::figurate::sum_5th_power n
::math::figurate::sum_6th_power n
::math::figurate::sum_7th_power n
::math::figurate::sum_8th_power n
::math::figurate::sum_9th_power n
::math::figurate::sum_10th_power n
::math::figurate::sum_sequence_odd n
::math::figurate::sum_squares_odd n
::math::figurate::sum_cubes_odd n
::math::figurate::sum_4th_power_odd n
::math::figurate::sum_5th_power_odd n
::math::figurate::sum_6th_power_odd n
::math::figurate::sum_7th_power_odd n
::math::figurate::sum_8th_power_odd n
::math::figurate::sum_9th_power_odd n
::math::figurate::sum_10th_power_odd n
::math::figurate::oblong n
::math::figurate::pronic n
::math::figurate::triangular n
::math::figurate::square n
::math::figurate::cubic n
::math::figurate::biquadratic n
::math::figurate::centeredTriangular n
::math::figurate::centeredSquare n
::math::figurate::centeredPentagonal n
::math::figurate::centeredHexagonal n
::math::figurate::centeredCube n
::math::figurate::decagonal n
::math::figurate::heptagonal n
::math::figurate::hexagonal n
::math::figurate::octagonal n
::math::figurate::octahedral n
::math::figurate::pentagonal n
::math::figurate::squarePyramidral n
::math::figurate::tetrahedral n
::math::figurate::pentatope n


Sums of numbers that follow a particular pattern are called figurate numbers. A simple example is the sum of integers 1, 2, ... up to n. You can arrange 1, 1+2=3, 1+2+3=6, ... objects in a triangle, hence the name triangular numbers:

*  *
*  *  *
*  *  *  *

The math::figurate package consists of a collection of procedures to evaluate a wide variety of figurate numbers. While all formulae are straightforward, the details are sometimes puzzling. Note: The procedures consider arguments lower than zero as to mean "no objects to be counted" and therefore return 0.


The procedures can be arranged in a few categories: sums of integers raised to a particular power, sums of odd integers and general figurate numbers, for instance the pentagonal numbers.

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math :: figurate of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.


figurate numbers, mathematics