"tabf", new keyword

Antti Karttunen karttu at walrus.megabaud.fi
Sun Jul 25 15:03:17 CEST 1999


N. J. A. Sloane wrote:
> 
> thanks to Antti Karttunen's program, the database now can
> display sequences coming from arrays as 2-dimensional arrays
> (I mentioned this in a recent posting).
> 
> to distinguish sequences coming from "funny-shaped" arrays
> - for which Antti's program doesn't work, and produces
> a horrible mess - i have introduced a new keyword "tabf"
> 
> this applies for instance to sequences coming from arrays
> of shape
> 
> *
> ***
> *****
> *******
> *********
> 
> or
> 
> *
> *
> **
> **
> ***
> ***
> ****
> ****
> ...
> 
> - any time it doesn't make sense to break up
> the sequence into chunks of lengths 1,2,3,4,5,6,7,...

Please Neil, could we adopt three new keywords instead
of just one, i.e. tabs and tabh for the first two cases
and tabf for the others, yet funnier ones.

 From our previous mail:

>
> Here are a couple of examples:
>
> %I A027113
> %S A027113 1,1,1,2,1,1,2,4,3,1,1,2,4,7,9,7,1,1,2,4,7,13,20,23,16,1,1,2,
> %T A027113 4,7,13,24,40,56,59,39,1,1,2,4,7,13,24,44,77,120,155,154,98,1,
> %U A027113 1,2,4,7,13,24,44,81,145,241,352,429,407,252,1,1,2,4,7,13,24
> %N A027113 Array T given by rows: T(n,0)=1 for n>=0, T(n,1)=1,T(n,2)=2 for n>=1, and for n>=2,
T(n,k)=T(n-1,k-3)+T(n-1,k-2)
> +T(n-1,k-1) for 3<=k<=2n-1, T(n,2n)=T(n-1,2n-3)+T(n-1,2n-2).
> %O A027113 1,4
> %K A027113 nonn,tabf
> %A A027113 Clark Kimberling, ck6 at cedar.evansville.edu
> %e A027113 1; 1,1,2; 1,1,2,4,3; 1,1,2,4,7,9,7; 1,1,2,4,7,13,20,23,16; ...

Here the diagonals/rows are 1,3,5,7,9,etc. terms long,
thus it's like every other antidiagonal/row of
a square/triangular table. (I.e. like a chess board
where only the black or white squares are significant).
Could this format be "tabs"? (As table but sparse...?)

> %I A028297
> %S A028297 1,1,2,1,4,3,8,8,1,16,20,5,32,48,18,1,64,112,56,7,128,256,160,
> %T A028297 32,1,256,576,432,120,9,512,1280,1120,400,50,1,1024,2816,2816,
> %U A028297 1232,220,11,2048,6144,6912,3584,840,72,1,4096,13312,16640,998
4
> %V A028297 1,1,2,-1,4,-3,8,-8,1,16,-20,5,32,-48,18,-1,64,-112,56,-7,128,
-256,160,
> %W A028297 -32,1,256,-576,432,-120,9,512,-1280,1120,-400,50,-1,1024,-281
6,2816,
> %X A028297 -1232,220,-11,2048,-6144,6912,-3584,840,-72,1,4096,-13312,166
40,-9984
> %N A028297 Triangle of coefficients in expansion of cos nx in descending powers of cos x.
> %D A028297 I. S. Gradshteyn and I. M. Ryzhik, Tables of Integrals, Series and Products, 5th ed., Section 1.335, p.
35.
> %O A028297 0,3
> %K A028297 tabf,easy,sign,done
> %e A028297 Letting c = cos x, we have: cos 0x = 1, cos 1x = 1c; cos 2x = 2c^2-1; cos 3x = 4c^3-3c, cos 4x = 8c^4-8c^2+1,
et
> c.
> %C A028297 Rows are of length 1, 1, 2, 2, 3, 3, ...
> %A A028297 njas
> %E A028297 Extended by David W. Wilson (wilson at ctron.com)
> %Y A028297 Cf. A028298.
> %e A028297 1; 1; 2,-1; 4,-3; 8,-8,1; 16,-20,5; 32,-48,18,-1; ...

This seems to be like the "half-antidiagonal" reading
of a square array, producing a triangle standing on its 
vertex like this:
1   1   2   4   8  16  32
   -1  -3  -8 -20 -48
        1   5  18
           -1

etc...
already we see the powers of 2 on the top row...
"tabh"? As table, with half-antidiagonal reading?
Of course, when an array is symmetric this kind of
formatting makes some sense.

Then Neil's formatting script could transfer also
this tabl/tabs/tabh keyword to the showtabl script, which
would then use the correct format.

>
> %I A036038
> %S A036038 1,1,2,1,3,6,1,4,6,12,24,1,5,10,20,30,60,120,1,6,15,20,30,60,9
0,120,180,
> %T A036038 360,720,1,7,21,35,42,105,140,210,210,420,630,840,1260,2520,50
40,1,8,28,
> %U A036038 56,70,56,168,280,420,560,336,840,1120,1680,2520,1680,3360,504
0,6720
> %N A036038 Triangle of multinomial coefficients.
> %O A036038 1,3
> %K A036038 nonn,easy,nice,tabf
> %D A036038 Abramowitz and Stegun, H'book, p. 831, column labeled "M_1".
> %Y A036038 Cf. A036036-A036040.
> %A A036038 njas
> %e A036038 1; 1,2; 1,3,6; 1,4,6,12,24; 1,5,10,20,30,60,120; ...
> %E A036038 Extended by David Wilson, and by w.meeussen.vdmcc at vandemoortele.be.
> %t A036038 Table[Apply[Multinomial,Partitions[i],{1}],{i,9}]
>

This is harder... Why 1,>2<,3,5,7,etc terms? Is this common
for certain sequences involving partitions?
 
Now, is there anybody who could help us and give a way of 
indexing the first two cases, sparse table and 
half-antidiagonal table?
(Yes, it must be very easy, but currently I'm very occupied 
with other things...)
 
Note that going from the half-antidiagonal reading
1,2,3,5,7,10
  4,6,8,11
    9,12

to the upper triangle reading
1247
 358
  69
   10

and back gives yet two other permutations of natural
numbers (1,2,4,3,6,9,5,8,12,16,...) and its inverse 
(1,2,4,3,7,5,11,8,6,...) where in the former one
all terms indiced by triangular numbers 1,3,6,10,...
are squares, and in the latter one all the terms
indiced by squares are triangular numbers.

> 
> Neil

Yours,

Antti
E-mail: Antti.Karttunen at iki.fi -> karttu at megabaud.fi

PS. Here are the functions showtable and showtriangle
from showtable CGI-script. The first is used for
antidiagonal readings of square arrays (format=1)
and upper triangle arrays (format=2), and the latter
is used for triangle formatting (a la Pascal's triangle, 
format=3).


int showtable(FILE *out,
              int height,
              int width,
              int format,
              char *table_begin,
              char *table_end,
              char *row_begin,
              char *row_end,
              char *cell_begin,
              char *cell_end,
              char **terms,
              int n_terms)
{
    int nth_row;

    fputs(table_begin, out);

    nth_row=0;
    for(nth_row=0; nth_row < height; nth_row++)
     {
       showrow(out,
               ((2 == format) ? nth_row : 0),
                nth_row,width,
                row_begin,row_end,cell_begin,cell_end,
                terms,n_terms);
     }

    fputs(table_end, out);
}


int showrow (FILE *out,
             int prepend,
             int nth_row,
             int width,
             char *row_begin,
             char *row_end,
             char *cell_begin,
             char *cell_end,
             char **terms,
             int n_terms)
{
    int i,j,k, lim;

    fputs(row_begin,out);

    for(i=0; i<prepend; i++)
     { fputs(cell_begin,out); fputs(cell_end,out); }

    lim=width-prepend;

    for(i=0; i<lim; i++)
     {
       fputs(cell_begin,out);
       j = i+nth_row;
       j = (((j*j)+j)/2)+nth_row;
       if(j < n_terms)
        {
          fputs(terms[j],out);
        }
       fputs(cell_end,out);
     }

    fputs(row_end,out);
}



int showtriangle (FILE *out,
              int height,
              int width,
              int format,
              char *table_begin,
              char *table_end,
              char *row_begin,
              char *row_end,
              char *cell_begin,
              char *cell_end,
              char **terms,
              int n_terms)
{
    int prepend, lim, nth_row, i, j;

    fputs(table_begin,out);

    for(nth_row=0,prepend=((width/2)-1);
        ((nth_row < height) && (prepend >= 0));
        nth_row++,prepend--
       )
     {
       fputs(row_begin,out);
   
       for(i=0; i<prepend; i++)
        { fputs(cell_begin,out); fputs(cell_end,out); }

       lim=width-prepend;

       for(j=0; j < lim; j++)
        {
          fputs(cell_begin,out);
          if(!(j&1) && *terms && ((j/2) <= nth_row))
           {
             fputs(*terms++,out);
           }
          fputs(cell_end,out);
        }

       fputs(row_end,out);
     }

    fputs(table_end,out);
}





More information about the SeqFan mailing list