I'm working on modernizing Rosetta Code's infrastructure. Starting with communications. Please accept this time-limited open invite to RC's Slack.. --Michael Mol (talk) 20:59, 30 May 2020 (UTC)

Talk:Super-d numbers

From Rosetta Code

super-d numbers[edit]

It is noted elsewhere that super-d numbers are always expressed in decimal   (base ten).     -- Gerard Schildberger (talk) 07:34, 12 October 2019 (UTC)

I updated the description of super-d numbers to reflect this. Thanks. --Chunes (talk) 20:50, 12 October 2019 (UTC)

Mostly addition method[edit]

One can get a list of squares by summing up the list of odd numbers, like this:

   0 + 1 =  1
   1 + 3 =  4
   4 + 5 =  9
   9 + 7 = 16
  16 + 9 = 25

Another way of tabulating it:

square, 1st difference, 2nd difference
     0,              1,              2
     1,              3,              2
     4,              5,              2
     9,              7,              2
    16,              9,              2
    25,             11,              2

The 2nd difference, 2, is also 2!
On to cubes:

  cube, 1st difference, 2nd difference, 3rd difference
     0,              1,              6,              6
     1,              7,             12,              6
     8,             19,             18,              6
    27,             37,             24,              6
    64,             61,             30,              6
   125,             91,             36,              6
   216,            127,             42,              6

The 3rd difference, 6, is also 3!

This pattern continues on, with the number of differences required (to calculate by adding) increasing by one and the last difference being n! To calculate a list of any powers, one can start at zero with the proper array of initial values, or start at "n" with a proper array of initial values. When starting at zero, some of the initial values will be negative. When starting at "n", all initial values will be positive.

Here is the initial array for each "n", starting at zero:

2:         0        -1         2 
3:         0         1        -6        6 
4:         0        -1        14      -36       24 
5:         0         1       -30      150     -240      120 
6:         0        -1        62     -540     1560    -1800      720 
7:         0         1      -126     1806    -8400    16800   -15120    5040 
8:         0        -1       254    -5796    40824  -126000   191520 -141120    40320 
9:         0         1      -510    18150  -186480   834120 -1905120 2328480 -1451520 362880 

Here is the initial array for each "n", starting at "n":

2:         4         3         2 
3:        27        19        12        6 
4:       256       175       110       60       24 
5:      3125      2101      1320      750      360      120 
6:     46656     31031     19502    11340     5880     2520      720 
7:    823543    543607    341796   201726   109200    52080    20160    5040 
8:  16777216  11012415   6927230  4131036  2298744  1164240   514080  181440    40320 
9: 387420489 253202761 159338640 95750430 54313560 28594440 13608000 5594400  1814400 362880 

When working backwards by summing instead of subtracting, the tables look like this because we work right to left on the array:
Squares:

0:         0        -1         2
1:         1         1         2
2:         4         3         2
3:         9         5         2
4:        16         7         2
5:        25         9         2

Cubes:

0:         0         1        -6        6 
1:         1         1         0        6 
2:         8         7         6        6 
3:        27        19        12        6 
4:        64        37        18        6 
5:       125        61        24        6 

Regarding the term "mostly addition", for this task there is some multiplication by a small integer (2 thru 9 in scale()), but the powers of "n" are calculated by only addition. The initial tables are calculated with multiplication and a power function (ipow()).

A side note, one can also calculate cubes by summing groups of odd numbers like this:

  1 =  1
  8 =  3 +  5
 27 =  7 +  9 + 11
 64 = 13 + 15 + 17 + 19
125 = 21 + 23 + 25 + 27 + 29

But I haven't worked out how (or if) a similar method works for higher powers. --Enter your username (talk) 16:08, 21 August 2020 (UTC)