logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

math::figurate - Evaluate figurate 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    TcllibTrackers
       [http://core.tcl.tk/tcllib/reportlist].  Please also report any ideas for enhancements you may  have  for
       either package and/or documentation.

       When proposing code changes, please provide unifieddiffs, 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.

Category

       Mathematics

tcllib                                                 1.1                                  math::figurate(3tcl)

Description

       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.

Keywords

       figurate numbers, mathematics

Name

       math::figurate - Evaluate figurate numbers

Procedures

       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.

       ::math::figurate::sum_sequencen
              Return the sum of integers 1, 2, ..., n.

              int n  Highest integer in the sum

       ::math::figurate::sum_squaresn
              Return the sum of squares 1**2, 2**2, ..., n**2.

              int n  Highest base integer in the sum

       ::math::figurate::sum_cubesn
              Return the sum of cubes 1**3, 2**3, ..., n**3.

              int n  Highest base integer in the sum

       ::math::figurate::sum_4th_powern
              Return the sum of 4th powers 1**4, 2**4, ..., n**4.

              int n  Highest base integer in the sum

       ::math::figurate::sum_5th_powern
              Return the sum of 5th powers 1**5, 2**5, ..., n**5.

              int n  Highest base integer in the sum

       ::math::figurate::sum_6th_powern
              Return the sum of 6th powers 1**6, 2**6, ..., n**6.

              int n  Highest base integer in the sum

       ::math::figurate::sum_7th_powern
              Return the sum of 7th powers 1**7, 2**7, ..., n**7.

              int n  Highest base integer in the sum

       ::math::figurate::sum_8th_powern
              Return the sum of 8th powers 1**8, 2**8, ..., n**8.

              int n  Highest base integer in the sum

       ::math::figurate::sum_9th_powern
              Return the sum of 9th powers 1**9, 2**9, ..., n**9.

              int n  Highest base integer in the sum

       ::math::figurate::sum_10th_powern
              Return the sum of 10th powers 1**10, 2**10, ..., n**10.

              int n  Highest base integer in the sum

       ::math::figurate::sum_sequence_oddn
              Return the sum of odd integers 1, 3, ..., 2n-1

              int n  Highest integer in the sum

       ::math::figurate::sum_squares_oddn
              Return the sum of odd squares 1**2, 3**2, ..., (2n-1)**2.

              int n  Highest base integer in the sum

       ::math::figurate::sum_cubes_oddn
              Return the sum of odd cubes 1**3, 3**3, ..., (2n-1)**3.

              int n  Highest base integer in the sum

       ::math::figurate::sum_4th_power_oddn
              Return the sum of odd 4th powers 1**4, 2**4, ..., (2n-1)**4.

              int n  Highest base integer in the sum

       ::math::figurate::sum_5th_power_oddn
              Return the sum of odd 5th powers 1**5, 2**5, ..., (2n-1)**5.

              int n  Highest base integer in the sum

       ::math::figurate::sum_6th_power_oddn
              Return the sum of odd 6th powers 1**6, 2**6, ..., (2n-1)**6.

              int n  Highest base integer in the sum

       ::math::figurate::sum_7th_power_oddn
              Return the sum of odd 7th powers 1**7, 2**7, ..., (2n-1)**7.

              int n  Highest base integer in the sum

       ::math::figurate::sum_8th_power_oddn
              Return the sum of odd 8th powers 1**8, 2**8, ..., (2n-1)**8.

              int n  Highest base integer in the sum

       ::math::figurate::sum_9th_power_oddn
              Return the sum of odd 9th powers 1**9, 2**9, ..., (2n-1)**9.

              int n  Highest base integer in the sum

       ::math::figurate::sum_10th_power_oddn
              Return the sum of odd 10th powers 1**10, 2**10, ..., (2n-1)**10.

              int n  Highest base integer in the sum

       ::math::figurate::oblongn
              Return the nth oblong number (twice the nth triangular number)

              int n  Required index

       ::math::figurate::pronicn
              Return the nth pronic number (synonym for oblong)

              int n  Required index

       ::math::figurate::triangularn
              Return the nth triangular number

              int n  Required index

       ::math::figurate::squaren
              Return the nth square number

              int n  Required index

       ::math::figurate::cubicn
              Return the nth cubic number

              int n  Required index

       ::math::figurate::biquadraticn
              Return the nth biquaratic number (i.e. n**4)

              int n  Required index

       ::math::figurate::centeredTriangularn
              Return the nth centered triangular number (items arranged in concentric squares)

              int n  Required index

       ::math::figurate::centeredSquaren
              Return the nth centered square number (items arranged in concentric squares)

              int n  Required index

       ::math::figurate::centeredPentagonaln
              Return the nth centered pentagonal number (items arranged in concentric pentagons)

              int n  Required index

       ::math::figurate::centeredHexagonaln
              Return the nth centered hexagonal number (items arranged in concentric hexagons)

              int n  Required index

       ::math::figurate::centeredCuben
              Return the nth centered cube number (items arranged in concentric cubes)

              int n  Required index

       ::math::figurate::decagonaln
              Return the nth decagonal number (items arranged in decagons with one common vertex)

              int n  Required index

       ::math::figurate::heptagonaln
              Return the nth heptagonal number (items arranged in heptagons with one common vertex)

              int n  Required index

       ::math::figurate::hexagonaln
              Return the nth hexagonal number (items arranged in hexagons with one common vertex)

              int n  Required index

       ::math::figurate::octagonaln
              Return the nth octagonal number (items arranged in octagons with one common vertex)

              int n  Required index

       ::math::figurate::octahedraln
              Return the nth octahedral number (items arranged in octahedrons with a common centre)

              int n  Required index

       ::math::figurate::pentagonaln
              Return the nth pentagonal number (items arranged in pentagons with one common vertex)

              int n  Required index

       ::math::figurate::squarePyramidraln
              Return the nth square pyramidral number (items arranged in a square pyramid)

              int n  Required index

       ::math::figurate::tetrahedraln
              Return the nth tetrahedral number (items arranged in a triangular pyramid)

              int n  Required index

       ::math::figurate::pentatopen
              Return  the  nth pentatope number (items arranged in the four-dimensional analogue of a triangular
              pyramid)

              int n  Required index

Synopsis

       package require Tcl8.69

       package require math::figurate1.0::math::figurate::sum_sequencen::math::figurate::sum_squaresn::math::figurate::sum_cubesn::math::figurate::sum_4th_powern::math::figurate::sum_5th_powern::math::figurate::sum_6th_powern::math::figurate::sum_7th_powern::math::figurate::sum_8th_powern::math::figurate::sum_9th_powern::math::figurate::sum_10th_powern::math::figurate::sum_sequence_oddn::math::figurate::sum_squares_oddn::math::figurate::sum_cubes_oddn::math::figurate::sum_4th_power_oddn::math::figurate::sum_5th_power_oddn::math::figurate::sum_6th_power_oddn::math::figurate::sum_7th_power_oddn::math::figurate::sum_8th_power_oddn::math::figurate::sum_9th_power_oddn::math::figurate::sum_10th_power_oddn::math::figurate::oblongn::math::figurate::pronicn::math::figurate::triangularn::math::figurate::squaren::math::figurate::cubicn::math::figurate::biquadraticn::math::figurate::centeredTriangularn::math::figurate::centeredSquaren::math::figurate::centeredPentagonaln::math::figurate::centeredHexagonaln::math::figurate::centeredCuben::math::figurate::decagonaln::math::figurate::heptagonaln::math::figurate::hexagonaln::math::figurate::octagonaln::math::figurate::octahedraln::math::figurate::pentagonaln::math::figurate::squarePyramidraln::math::figurate::tetrahedraln::math::figurate::pentatopen

________________________________________________________________________________________________________________

See Also