# [seqfan] Trivium.

wouter meeussen wouter.meeussen at pandora.be
Sun Sep 6 17:08:14 CEST 2009

```for all prime bases b,  the matrix A(n,m)= m*n mod b for n,m in (1,b-1), is
a latin square.
Each row (and column) is thus a permutation of size b-1.

Unexpected:
form the inner product of B(n,m) with A(n,m)
where B consists of rows that are the inverse permutations of rows in A,
with the multiplications taken in mod b,
and one gets two types of results (illustrated below).

The inner product has all elements c(n,m) = Sum{k^2 mod b:
k=1,2,...,b}=A048153(b)
or
The inner product has (again) elements c1(n,m)=Sum{k^2 mod b:
k=1,2,...,b}=A048153(b)
and, secondly, elements c2(n,m)== Sum{k*(b-k) mod b: k=1,2,...,b} (*not
in OEIS, submission pending*)

All primes in A002145 (of form 4n+3) seem to fall in the first type,
while those in A002313 (congruent to 1 or 2 mod 4) fall in the second type.

Examples:
-------------------------------------------------------------------------
base 5:
a(n,m)= m*n mod 5 for n,m in (1 ... 4)
{1, 2, 3, 4},  inverse:  {1, 2, 3, 4},
{2, 4, 1, 3},               {3, 1, 4, 2},
{3, 1, 4, 2},               {2, 4, 1, 3},
{4, 3, 2, 1}                {4, 3, 2, 1}

b=5: "*" should be read as multiplication mod 5; B x A mod 5=

{1*1+2*2+3*3+4*4, 1*2+2*4+3*1+4*3, 1*3+2*1+3*4+4*2, 1*4+2*3+3*2+4*1},
{1*2+2*4+3*1+4*3, 1*4+2*3+3*2+4*1, 1*1+2*2+3*3+4*4, 1*3+2*1+3*4+4*2},
{1*3+2*1+3*4+4*2, 1*1+2*2+3*3+4*4, 1*4+2*3+3*2+4*1, 1*2+2*4+3*1+4*3},
{1*4+2*3+3*2+4*1, 1*3+2*1+3*4+4*2, 1*2+2*4+3*1+4*3, 1*1+2*2+3*3+4*4}

{1+4+4+1,2+3+3+2,3+2+2+3,4+1+1+4},
{3+2+2+3,1+4+4+1,4+1+1+4,2+3+3+2},
{2+3+3+2,4+1+1+4,1+4+4+1,3+2+2+3},
{4+1+1+4,3+2+2+3,2+3+3+2,1+4+4+1}

1*1+2*2+3*3+4*4 (mod 5)=1+4+4+1=10:
{10, 10, 10, 10},
{10, 10, 10, 10},
{10, 10, 10, 10},
{10, 10, 10, 10},
-------------------------------------------------------------------------
base 7:
a(n,m)= m*n mod 7 for n,m in (1 ... 6)
A:{1, 2, 3, 4, 5, 6}, B:{1, 2, 3, 4, 5, 6},
{2, 4, 6, 1, 3, 5},     {4, 1, 5, 2, 6, 3},
{3, 6, 2, 5, 1, 4},     {5, 3, 1, 6, 4, 2},
{4, 1, 5, 2, 6, 3},     {2, 4, 6, 1, 3, 5},
{5, 3, 1, 6, 4, 2},     {3, 6, 2, 5, 1, 4},
{6, 5, 4, 3, 2, 1}      {6, 5, 4, 3, 2, 1}

b=7: "*" should be read as multiplication mod 7; B x A mod 7=

{1*1+2*2+3*3+4*4+5*5+6*6, 1*2+2*4+3*6+4*1+5*3+6*5, 1*3+2*6+3*2+4*5+5*1+6*4,
1*4+2*1+3*5+4*2+5*6+6*3, 1*5+2*3+3*1+4*6+5*4+6*2, 1*6+2*5+3*4+4*3+5*2+6*1},
{1*2+2*4+3*6+4*1+5*3+6*5, 1*4+2*1+3*5+4*2+5*6+6*3, 1*6+2*5+3*4+4*3+5*2+6*1,
1*1+2*2+3*3+4*4+5*5+6*6, 1*3+2*6+3*2+4*5+5*1+6*4, 1*5+2*3+3*1+4*6+5*4+6*2},
{1*3+2*6+3*2+4*5+5*1+6*4, 1*6+2*5+3*4+4*3+5*2+6*1, 1*2+2*4+3*6+4*1+5*3+6*5,
1*5+2*3+3*1+4*6+5*4+6*2, 1*1+2*2+3*3+4*4+5*5+6*6, 1*4+2*1+3*5+4*2+5*6+6*3},
{1*4+2*1+3*5+4*2+5*6+6*3, 1*1+2*2+3*3+4*4+5*5+6*6, 1*5+2*3+3*1+4*6+5*4+6*2,
1*2+2*4+3*6+4*1+5*3+6*5, 1*6+2*5+3*4+4*3+5*2+6*1, 1*3+2*6+3*2+4*5+5*1+6*4},
{1*5+2*3+3*1+4*6+5*4+6*2, 1*3+2*6+3*2+4*5+5*1+6*4, 1*1+2*2+3*3+4*4+5*5+6*6,
1*6+2*5+3*4+4*3+5*2+6*1, 1*4+2*1+3*5+4*2+5*6+6*3, 1*2+2*4+3*6+4*1+5*3+6*5},
{1*6+2*5+3*4+4*3+5*2+6*1, 1*5+2*3+3*1+4*6+5*4+6*2, 1*4+2*1+3*5+4*2+5*6+6*3,
1*3+2*6+3*2+4*5+5*1+6*4, 1*2+2*4+3*6+4*1+5*3+6*5, 1*1+2*2+3*3+4*4+5*5+6*6}

{{1+4+2+2+4+1, 2+1+4+4+1+2, 3+5+6+6+5+3, 4+2+1+1+2+4, 5+6+3+3+6+5,
6+3+5+5+3+6},
{4+2+1+1+2+4, 1+4+2+2+4+1, 5+6+3+3+6+5, 2+1+4+4+1+2, 6+3+5+5+3+6,
3+5+6+6+5+3},
{5+6+3+3+6+5, 3+5+6+6+5+3, 1+4+2+2+4+1, 6+3+5+5+3+6, 4+2+1+1+2+4,
2+1+4+4+1+2},
{2+1+4+4+1+2, 4+2+1+1+2+4, 6+3+5+5+3+6, 1+4+2+2+4+1, 3+5+6+6+5+3,
5+6+3+3+6+5},
{3+5+6+6+5+3, 6+3+5+5+3+6, 2+1+4+4+1+2, 5+6+3+3+6+5, 1+4+2+2+4+1,
4+2+1+1+2+4},
{6+3+5+5+3+6, 5+6+3+3+6+5, 4+2+1+1+2+4, 3+5+6+6+5+3, 2+1+4+4+1+2,
1+4+2+2+4+1}}

1*1+2*2+3*3+4*4+5*5+6*6 mod 7= 1+4+2+2+4+1=14
1*6+2*5+3*4+4*3+5*2+6*1 mod 7= 6+3+5+5+3+6=28
{14, 14, 28, 14, 28, 28},
{14, 14, 28, 14, 28, 28},
{28, 28, 14, 28, 14, 14},
{14, 14, 28, 14, 28, 28},
{28, 28, 14, 28, 14, 14},
{28, 28, 14, 28, 14, 14}
-------------------------------------------------------------------------
ugly code: only on request.

Wouter.

```