text files


figurate numbers and sums of powers


programs also loaded on TCL WIKI pages.
Also OEIS has content on figurate numbers.
suggest figurate numbers and sums of powers (formulas) into TCLLIB math module.

(body) Suggest load figurate numbers and sums of powers (formulas) into TCLLIB  math module.. I loaded some one liner programs and formulas  on the TCL WIKI pages. Also OEIS has substantial  content on figurate numbers.


One Liners Programs Compendium and TCL demo examples calculations, numerical analysis

----
*** Advanced Topics: Figurate Polynomial Formulas for TCL Procs   ***
----
----
*** Table  :  Figurate Formulas and TCL Procs Table  ***
----
%|Table Figurate Formulas into TCL Procs  ||    |printed in | tcl format|%
%|        figurate name        |        formula in variable n        |        automatic trial  TCL  proc ************************       |        infinite series        |        comment, if any        |%
&|        oblong numbers        |        n*(n+1)        |        proc figurate1 {  n } {[ return [ expr {($n+1) }]}        |        0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, ...         | |&
&|        triangular numbers        |        n*(n+1)/2        |        proc figurate1 {  n } {[ return [ expr {($n+1)/2}]}        |        1 3 6 10 15 21 28...         | |&
&|        square numbers        |        n**2        |        proc figurate1 {  n } {[ return [ expr {$n**2}]}        |        1 4 9 16 25 36 49...         | |&
&|        pentagonal numbers        |        n*(3n-1)/2        |        proc figurate1 {  n } {[ return [ expr {(3*$n-1)/2}]}        |        1 5 12 22 35 51 70...         | |&
&|        hexagonal numbers        |        n*(4n-2)/2        |        proc figurate1 {  n } {[ return [ expr {(4*$n-2)/2}]}        |        1 6 15 28 45 66 91...         | |&
&|        heptagonal numbers        |        n*(5n-3)/2        |        proc figurate1 {  n } {[ return [ expr {(5*$n-3)/2}]}        |        1 7 18 34 55 81 112...         | |&
&|        octogonal numbers        |        n*(3n-2)        |        proc figurate1 {  n } {[ return [ expr {(3*$n-2)}]}        |        1 8 21 40 65 96 133...         | |&
&|        **********************        |         2D figurate numbers into 3D figurate numbers         |        ************************        |                 | |&
&|        triangular numbers        |        n*(n+1)/2        |        proc figurate1 {  n } {[ return [ expr {($n+1)/2}]}        |        1 3 6 10 15 21...         | |&
&|        tetrahedral numbers        |        n*(n+1)*(n+2)/6        |        proc figurate1 {  n } {[ return [ expr {($n+1)*($n+2)/6}]}        |        1 4 10 20 35 56...         | |&
&|        hypertetrahedral numbers        |        n*(n+1)*(n+2)*(n+3)/24        |        proc figurate1 {  n } {[ return [ expr {($n+1)*($n+2)*($n+3)/24}]}        |        1 5 15 35 70 126...         | |&
----
from Gnumeric spreadsheet
----
======
proc figurate1_oblong {  n } {[ return [ expr {($n+1) }]}
proc figurate2_triangular {  n } {[ return [ expr {($n+1)/2}]}
proc figurate3_square {  n } {[ return [ expr {$n**2}]}
proc figurate4_pentagonal {  n } {[ return [ expr {(3*$n-1)/2}]}
proc figurate5_hexagonal {  n } {[ return [ expr {(4*$n-2)/2}]}
proc figurate6_heptagonal  {  n } {[ return [ expr {(5*$n-3)/2}]}
proc figurate7_octogonal {  n } {[ return [ expr {(3*$n-2)}]}
;# *****  2D figurate into 3D figurate $numbers        ******
proc figurate8_triangular {  n } {[ return [ expr {($n+1)/2}]}   ;# duplicate proc for comparison
proc figurate9_tetrahedral {  n } {[ return [ expr {($n+1)*($n+2)/6}]}
proc figurate10_hypertetrahedral {  n } {[ return [ expr {($n+1)*($n+2)*($n+3)/24}]}
======
----
----
*** Advanced Topics: Polynomials, Sums of Powers,  Symbolic Differentiation & Integration   in  Tcllib Calculus***
----
======
;# adding extra and redundant spaces in proc expressions
;# below for wiki readability
;# recommend each proc be math checked by hand on small numbers (2,3,4)
;# recommend each proc be checked for small, medium,  and large numbers
;# in expected range of operation
;# one may leave off return commands and unnecessary spaces for brevity

;# formula for Sum of Squares is k(2) = n*(n+1)*(2*n+1)/6
proc sum_squares  { n } {set res [expr { $n*($n + 1)*(2*$n +1 ) / 6 }]}
;# Usage sum_squares 2 ->  5
;# check answer expr 2**2 -> 4, 4 + 1 = 5
;# Usage sum_squares 1000000 ->  333333833333500000

;# formula for Sum of Cubes is k(3) = (n**2)* ((n + 1)**2) / 4
proc sum_cubes  { n } {set res [expr { ($n**2)* (($n + 1)**2) / 4 }]}
;# Usage sum_cubes 2 ->  9
;# check answer expr 2**3 -> 8, 8 + 1 = 9
;# Usage sum_cubes 1000000 ->  250000500000250000000000

;# formula sum_4th_power k(4) = n* (n + 1)* (2*n + 1 )* ( 3*n**2 + 3*n -1)/30
;# using integer arithmetic for the long digit answers
proc  sum_4th_power {n} { expr { $n* ($n + 1)* (2*$n + 1 )* (3*$n**2 + 3*$n -1)/30}}
;# Usage sum_4th_power 2  -> 17
;# check answer expr 2**4 -> 16, 16 + 1 = 17
;# Usage sum_4th_power 0  -> 0  ;# Usage sum_4th_power 1  -> 1
;# Usage sum_4th_power 1000  -> 200500333333300
;# Usage  sum_4th_power 200 -> 64802666660
;# Usage sum_4th_power 1000000000
;#     ->

;# formula sum_5th_power k(5) = n*n* (n+1)* (n+1 )* (  2*n**2 + 2*n -1)/12
proc sum_5th {n} {return [expr {($n*$n* ($n + 1)*($n + 1 )*(2*($n**2)+2*$n - 1))/12}] }
;# internal ? in expr testing for 2 conditions
proc sum_5th_power  {n} {expr { $n < 1? 0: $n > 1 ? 1 : ($n*$n* ($n + 1)*($n + 1 )*(2*($n**2)+2*$n - 1))/12}}
;# Usage sum_5th_power 0  -> 0  ;# Usage sum_5th_power 1  -> 1
;# Usage sum_5th_power 2  -> 33

;# formula sum_6th_power k(6) =( n*(n + 1)*(2*n + 1 )*(3*(n**4)+(6*(n**3))-(3*n) + 1))/42
proc sum_6th {x} {return [expr {( $x*($x + 1)*(2*$x + 1 )*(3*($x**4)+(6*($x**3))-(3*$x) + 1))/42}] }
;# Usage sum_6th 2 -> 65
;# check answer expr 2**6 = 64, 1 + 64 = 65

;# formula sum_7th_power k(7) =( n*n*(n + 1)*(n + 1)*(3*(n**4)+(6*(n**3))-n*n-(4*n) + 2))/24
proc sum_7th {x} {return [expr {( $x*$x*($x + 1)*($x + 1)*(3*($x**4)+(6*($x**3))-$x*$x-(4*$x) + 2))/24}] }
;# Usage sum_7th 2 -> 129
;# check answer  expr 2**7 = 128, 1+128 = 129
======
----
======
;# adding extra and redundant spaces in expressions  below for wiki readability
;# recommend each proc be math checked by hand on small numbers (2,3,4)
;# recommend each proc be checked for small, medium, and large numbers
;# in expected range of operation
;# one may leave off return commands and unnecessary spaces