Counting the number of inversions for the function $f(x+yp)=qx+y$The generating function for permutations indexed by number of inversionsEfficient calculation of minimal expected number of inversionsFinding The Number Of Inversions In A PermutationCounting the number of permutations of $(1,ldots,i,ldots,j,ldots,m)$, where $i < j$ and number of inversions is $k$.Characterizing The Number of Inversions in A PermutationCorrespondence between the sum of inversions and the number of transpositionsAverage number of inversions in an involutionnumber of permutations with k inversions modulo 3Find number of permutations with 2 inversionsNumber of $n$-permutations with $r$ inversions modulo $k$

Could the E-bike drivetrain wear down till needing replacement after 400 km?

Do Legal Documents Require Signing In Standard Pen Colors?

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?

Find last 3 digits of this monster number

On a tidally locked planet, would time be quantized?

Can I sign legal documents with a smiley face?

What linear sensor for a keyboard?

Why is Arduino resetting while driving motors?

How do I extrude a face to a single vertex

Engineer refusing to file/disclose patents

Do the concepts of IP address and network interface not belong to the same layer?

Is possible to search in vim history?

Why has "pence" been used in this sentence, not "pences"?

Can I rely on this github repository files?

A social experiment. What is the worst that can happen?

Customize circled numbers

How can "mimic phobia" be cured or prevented?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

What is this type of notehead called?

Can somebody explain Brexit in a few child-proof sentences?

Java - What do constructor type arguments mean when placed *before* the type?

Query about absorption line spectra

Melting point of aspirin, contradicting sources

Is there a conventional notation or name for the slip angle?



Counting the number of inversions for the function $f(x+yp)=qx+y$


The generating function for permutations indexed by number of inversionsEfficient calculation of minimal expected number of inversionsFinding The Number Of Inversions In A PermutationCounting the number of permutations of $(1,ldots,i,ldots,j,ldots,m)$, where $i < j$ and number of inversions is $k$.Characterizing The Number of Inversions in A PermutationCorrespondence between the sum of inversions and the number of transpositionsAverage number of inversions in an involutionnumber of permutations with k inversions modulo 3Find number of permutations with 2 inversionsNumber of $n$-permutations with $r$ inversions modulo $k$













2












$begingroup$


Let $p,q$, $(pneq q)$ be odd primes. Define the function $f:0,1,ldots,pq-1to 0,1,ldots,pq-1$ by $f(x+yp)=qx+y$, where $xin 0,1,ldots,p-1$ and $yin0,1,ldots,q-1$. How does one calculate the number of inversions for $f$?



A complete solution would be quite helpful.










share|cite|improve this question











$endgroup$











  • $begingroup$
    "Inversions" are defined for a permutation of an ordered set; you need to define a total order on $mathbbZ_pq$. I assume you really want the function $f : left0,1,ldots,pq-1right to left0,1,ldots,pq-1right$ (not $f : mathbbZ_pq to mathbbZ_pq$) that sends each $x + yp$ to $qx + y$ for $x in left0,1,ldots,p-1right$ and $y in left0,1,ldots,q-1right$.
    $endgroup$
    – darij grinberg
    2 days ago






  • 1




    $begingroup$
    Note that it does not matter whether or not $p$ and $q$ are prime or distinct. A very similar (most likely equivalent, but I am too tired) problem has been posed as Exercise 3 in UMN Fall 2017 Math 4990 homework set #8 (the link goes to a PDF that sketches a solution and contains a link to another writeup with a solution).
    $endgroup$
    – darij grinberg
    2 days ago










  • $begingroup$
    @darijgrinberg Yes. Appreciate the comments. Thank you :)
    $endgroup$
    – crskhr
    2 days ago















2












$begingroup$


Let $p,q$, $(pneq q)$ be odd primes. Define the function $f:0,1,ldots,pq-1to 0,1,ldots,pq-1$ by $f(x+yp)=qx+y$, where $xin 0,1,ldots,p-1$ and $yin0,1,ldots,q-1$. How does one calculate the number of inversions for $f$?



A complete solution would be quite helpful.










share|cite|improve this question











$endgroup$











  • $begingroup$
    "Inversions" are defined for a permutation of an ordered set; you need to define a total order on $mathbbZ_pq$. I assume you really want the function $f : left0,1,ldots,pq-1right to left0,1,ldots,pq-1right$ (not $f : mathbbZ_pq to mathbbZ_pq$) that sends each $x + yp$ to $qx + y$ for $x in left0,1,ldots,p-1right$ and $y in left0,1,ldots,q-1right$.
    $endgroup$
    – darij grinberg
    2 days ago






  • 1




    $begingroup$
    Note that it does not matter whether or not $p$ and $q$ are prime or distinct. A very similar (most likely equivalent, but I am too tired) problem has been posed as Exercise 3 in UMN Fall 2017 Math 4990 homework set #8 (the link goes to a PDF that sketches a solution and contains a link to another writeup with a solution).
    $endgroup$
    – darij grinberg
    2 days ago










  • $begingroup$
    @darijgrinberg Yes. Appreciate the comments. Thank you :)
    $endgroup$
    – crskhr
    2 days ago













2












2








2


1



$begingroup$


Let $p,q$, $(pneq q)$ be odd primes. Define the function $f:0,1,ldots,pq-1to 0,1,ldots,pq-1$ by $f(x+yp)=qx+y$, where $xin 0,1,ldots,p-1$ and $yin0,1,ldots,q-1$. How does one calculate the number of inversions for $f$?



A complete solution would be quite helpful.










share|cite|improve this question











$endgroup$




Let $p,q$, $(pneq q)$ be odd primes. Define the function $f:0,1,ldots,pq-1to 0,1,ldots,pq-1$ by $f(x+yp)=qx+y$, where $xin 0,1,ldots,p-1$ and $yin0,1,ldots,q-1$. How does one calculate the number of inversions for $f$?



A complete solution would be quite helpful.







abstract-algebra combinatorics






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited 2 days ago







crskhr

















asked Mar 16 at 11:27









crskhrcrskhr

3,890926




3,890926











  • $begingroup$
    "Inversions" are defined for a permutation of an ordered set; you need to define a total order on $mathbbZ_pq$. I assume you really want the function $f : left0,1,ldots,pq-1right to left0,1,ldots,pq-1right$ (not $f : mathbbZ_pq to mathbbZ_pq$) that sends each $x + yp$ to $qx + y$ for $x in left0,1,ldots,p-1right$ and $y in left0,1,ldots,q-1right$.
    $endgroup$
    – darij grinberg
    2 days ago






  • 1




    $begingroup$
    Note that it does not matter whether or not $p$ and $q$ are prime or distinct. A very similar (most likely equivalent, but I am too tired) problem has been posed as Exercise 3 in UMN Fall 2017 Math 4990 homework set #8 (the link goes to a PDF that sketches a solution and contains a link to another writeup with a solution).
    $endgroup$
    – darij grinberg
    2 days ago










  • $begingroup$
    @darijgrinberg Yes. Appreciate the comments. Thank you :)
    $endgroup$
    – crskhr
    2 days ago
















  • $begingroup$
    "Inversions" are defined for a permutation of an ordered set; you need to define a total order on $mathbbZ_pq$. I assume you really want the function $f : left0,1,ldots,pq-1right to left0,1,ldots,pq-1right$ (not $f : mathbbZ_pq to mathbbZ_pq$) that sends each $x + yp$ to $qx + y$ for $x in left0,1,ldots,p-1right$ and $y in left0,1,ldots,q-1right$.
    $endgroup$
    – darij grinberg
    2 days ago






  • 1




    $begingroup$
    Note that it does not matter whether or not $p$ and $q$ are prime or distinct. A very similar (most likely equivalent, but I am too tired) problem has been posed as Exercise 3 in UMN Fall 2017 Math 4990 homework set #8 (the link goes to a PDF that sketches a solution and contains a link to another writeup with a solution).
    $endgroup$
    – darij grinberg
    2 days ago










  • $begingroup$
    @darijgrinberg Yes. Appreciate the comments. Thank you :)
    $endgroup$
    – crskhr
    2 days ago















$begingroup$
"Inversions" are defined for a permutation of an ordered set; you need to define a total order on $mathbbZ_pq$. I assume you really want the function $f : left0,1,ldots,pq-1right to left0,1,ldots,pq-1right$ (not $f : mathbbZ_pq to mathbbZ_pq$) that sends each $x + yp$ to $qx + y$ for $x in left0,1,ldots,p-1right$ and $y in left0,1,ldots,q-1right$.
$endgroup$
– darij grinberg
2 days ago




$begingroup$
"Inversions" are defined for a permutation of an ordered set; you need to define a total order on $mathbbZ_pq$. I assume you really want the function $f : left0,1,ldots,pq-1right to left0,1,ldots,pq-1right$ (not $f : mathbbZ_pq to mathbbZ_pq$) that sends each $x + yp$ to $qx + y$ for $x in left0,1,ldots,p-1right$ and $y in left0,1,ldots,q-1right$.
$endgroup$
– darij grinberg
2 days ago




1




1




$begingroup$
Note that it does not matter whether or not $p$ and $q$ are prime or distinct. A very similar (most likely equivalent, but I am too tired) problem has been posed as Exercise 3 in UMN Fall 2017 Math 4990 homework set #8 (the link goes to a PDF that sketches a solution and contains a link to another writeup with a solution).
$endgroup$
– darij grinberg
2 days ago




$begingroup$
Note that it does not matter whether or not $p$ and $q$ are prime or distinct. A very similar (most likely equivalent, but I am too tired) problem has been posed as Exercise 3 in UMN Fall 2017 Math 4990 homework set #8 (the link goes to a PDF that sketches a solution and contains a link to another writeup with a solution).
$endgroup$
– darij grinberg
2 days ago












$begingroup$
@darijgrinberg Yes. Appreciate the comments. Thank you :)
$endgroup$
– crskhr
2 days ago




$begingroup$
@darijgrinberg Yes. Appreciate the comments. Thank you :)
$endgroup$
– crskhr
2 days ago










1 Answer
1






active

oldest

votes


















1












$begingroup$

We will consider the case $p=3, q=5$ which is easy to draw. Hopefully you agree the ideas generalize. Consider these matrices:



$$
A = beginbmatrix
0 & 1 & 2 & 3 & 4 \
5 & 6 & 7 & 8 & 9 \
10 & 11 & 12 & 13 & 14
endbmatrix,

B = beginbmatrix
0 & 3 & 6 & 9 & 12 \
1 & 4 & 7 & 10 & 13 \
2 & 5 & 8 & 11 & 14
endbmatrix
$$



Let the rows be numbered $x = 0, 1, 2$ from top to bottom and the columns be numbered $y = 0, 1, 2, 3, 4$ from left to right. Then $A_xy = qx+y$ and $B_xy = x+py$.



So here's a recipe for evaluating $f(i)$ where $i in mathbbZ_pq$:



  • First, find location $(x,y)$ where $B_xy= i$


  • Then, look up the same location in matrix $A$ and we have $f(i) = A_xy$.


If I may abuse notation a bit, the chain of mapping that just happened was something like this:



$$i = x+py = B_xy rightarrow (x,y) rightarrow A_xy = qx+y = f(i) = f(x+py)$$



which has an overall effect of $x + py rightarrow qx+y$ as desired.



OK, so how does this help? Consider $(i,j) in mathbbZ_pq^2$. It is an inversion if $i < j$ and $f(i) > f(j)$. Let their locations be $(x_i, y_i), (x_j, y_j)$, i.e. $i = x_i + p y_i = B_x_i y_i$ and $f(i) = q x_i + y_i = A_x_i y_i$, and similarly for $j$.



  • From matrix $B$, it is obvious that $i = B_x_i y_i < j = B_x_j y_j$ iff $y_j > y_i$ ($j$'s column is to the right of $i$'s column), or, $y_j = y_i$ and $x_j > x_i$ ($j$ is in the same column and below $i$).


  • From matrix $A$, similarly, $f(i) = A_x_i y_i > f(j) = A_x_j y_j$ iff $x_j < x_i$ ($j$'s row is above $i$'s row), or, $x_j = x_i$ and $y_j < y_i$ ($j$ is in same row and to the left of $i$).


Since we need both conditions above to be true, this means $(i,j)$ is an inversion iff $y_j > y_i$ and $x_j < x_i$, i.e. $(x_j, y_j)$ must be strictly to the right and above $(x_i, y_i)$.



E.g. in the following colored matrices, the blue cell represents $i=4, f(i) = f(1 + 1 cdot 3) = 5 cdot 1 + 1 = 6$. The red area in the $B$ matrix represents $j> i$ and the red area in the $A$ matrix represents $f(j) < f(i)$. Clearly the only overlap (for this choice of $i$) are the $3$ cells corresponding to $x=0, y=2,3,4$. These are the values of $j$ which form inversions with this choice of $i$.



$$
A = beginbmatrix
colorred0 & colorred1 & colorred2 & colorred3 & colorred4 \
colorred5 & colorblue6 & 7 & 8 & 9 \
10 & 11 & 12 & 13 & 14
endbmatrix,

B = beginbmatrix
0 & 3 & colorred6 & colorred9 & colorred12 \
1 & colorblue4 & colorred7 & colorred10 & colorred13 \
2 & colorred5 & colorred8 & colorred11 & colorred14
endbmatrix
$$



E.g. $j=6 > i=4$ and $f(j) = f(0 + 2cdot 3) = 5cdot 0 + 2 = 2 < f(i) = 6$.



So each $(i,j)$ pair that is an inversion is a pair of cells which form the top-right and bottom-left corners of a rectangle, where the rectangle has $c>1$ columns and $r>1$ rows. To count such rectangles, simply pick any $2$ distinct columns, and any $2$ distinct rows. So the final answer, i.e. the total number of inversion pairs, is $p choose 2q choose 2$.






share|cite|improve this answer











$endgroup$












    Your Answer





    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "69"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3150298%2fcounting-the-number-of-inversions-for-the-function-fxyp-qxy%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1












    $begingroup$

    We will consider the case $p=3, q=5$ which is easy to draw. Hopefully you agree the ideas generalize. Consider these matrices:



    $$
    A = beginbmatrix
    0 & 1 & 2 & 3 & 4 \
    5 & 6 & 7 & 8 & 9 \
    10 & 11 & 12 & 13 & 14
    endbmatrix,

    B = beginbmatrix
    0 & 3 & 6 & 9 & 12 \
    1 & 4 & 7 & 10 & 13 \
    2 & 5 & 8 & 11 & 14
    endbmatrix
    $$



    Let the rows be numbered $x = 0, 1, 2$ from top to bottom and the columns be numbered $y = 0, 1, 2, 3, 4$ from left to right. Then $A_xy = qx+y$ and $B_xy = x+py$.



    So here's a recipe for evaluating $f(i)$ where $i in mathbbZ_pq$:



    • First, find location $(x,y)$ where $B_xy= i$


    • Then, look up the same location in matrix $A$ and we have $f(i) = A_xy$.


    If I may abuse notation a bit, the chain of mapping that just happened was something like this:



    $$i = x+py = B_xy rightarrow (x,y) rightarrow A_xy = qx+y = f(i) = f(x+py)$$



    which has an overall effect of $x + py rightarrow qx+y$ as desired.



    OK, so how does this help? Consider $(i,j) in mathbbZ_pq^2$. It is an inversion if $i < j$ and $f(i) > f(j)$. Let their locations be $(x_i, y_i), (x_j, y_j)$, i.e. $i = x_i + p y_i = B_x_i y_i$ and $f(i) = q x_i + y_i = A_x_i y_i$, and similarly for $j$.



    • From matrix $B$, it is obvious that $i = B_x_i y_i < j = B_x_j y_j$ iff $y_j > y_i$ ($j$'s column is to the right of $i$'s column), or, $y_j = y_i$ and $x_j > x_i$ ($j$ is in the same column and below $i$).


    • From matrix $A$, similarly, $f(i) = A_x_i y_i > f(j) = A_x_j y_j$ iff $x_j < x_i$ ($j$'s row is above $i$'s row), or, $x_j = x_i$ and $y_j < y_i$ ($j$ is in same row and to the left of $i$).


    Since we need both conditions above to be true, this means $(i,j)$ is an inversion iff $y_j > y_i$ and $x_j < x_i$, i.e. $(x_j, y_j)$ must be strictly to the right and above $(x_i, y_i)$.



    E.g. in the following colored matrices, the blue cell represents $i=4, f(i) = f(1 + 1 cdot 3) = 5 cdot 1 + 1 = 6$. The red area in the $B$ matrix represents $j> i$ and the red area in the $A$ matrix represents $f(j) < f(i)$. Clearly the only overlap (for this choice of $i$) are the $3$ cells corresponding to $x=0, y=2,3,4$. These are the values of $j$ which form inversions with this choice of $i$.



    $$
    A = beginbmatrix
    colorred0 & colorred1 & colorred2 & colorred3 & colorred4 \
    colorred5 & colorblue6 & 7 & 8 & 9 \
    10 & 11 & 12 & 13 & 14
    endbmatrix,

    B = beginbmatrix
    0 & 3 & colorred6 & colorred9 & colorred12 \
    1 & colorblue4 & colorred7 & colorred10 & colorred13 \
    2 & colorred5 & colorred8 & colorred11 & colorred14
    endbmatrix
    $$



    E.g. $j=6 > i=4$ and $f(j) = f(0 + 2cdot 3) = 5cdot 0 + 2 = 2 < f(i) = 6$.



    So each $(i,j)$ pair that is an inversion is a pair of cells which form the top-right and bottom-left corners of a rectangle, where the rectangle has $c>1$ columns and $r>1$ rows. To count such rectangles, simply pick any $2$ distinct columns, and any $2$ distinct rows. So the final answer, i.e. the total number of inversion pairs, is $p choose 2q choose 2$.






    share|cite|improve this answer











    $endgroup$

















      1












      $begingroup$

      We will consider the case $p=3, q=5$ which is easy to draw. Hopefully you agree the ideas generalize. Consider these matrices:



      $$
      A = beginbmatrix
      0 & 1 & 2 & 3 & 4 \
      5 & 6 & 7 & 8 & 9 \
      10 & 11 & 12 & 13 & 14
      endbmatrix,

      B = beginbmatrix
      0 & 3 & 6 & 9 & 12 \
      1 & 4 & 7 & 10 & 13 \
      2 & 5 & 8 & 11 & 14
      endbmatrix
      $$



      Let the rows be numbered $x = 0, 1, 2$ from top to bottom and the columns be numbered $y = 0, 1, 2, 3, 4$ from left to right. Then $A_xy = qx+y$ and $B_xy = x+py$.



      So here's a recipe for evaluating $f(i)$ where $i in mathbbZ_pq$:



      • First, find location $(x,y)$ where $B_xy= i$


      • Then, look up the same location in matrix $A$ and we have $f(i) = A_xy$.


      If I may abuse notation a bit, the chain of mapping that just happened was something like this:



      $$i = x+py = B_xy rightarrow (x,y) rightarrow A_xy = qx+y = f(i) = f(x+py)$$



      which has an overall effect of $x + py rightarrow qx+y$ as desired.



      OK, so how does this help? Consider $(i,j) in mathbbZ_pq^2$. It is an inversion if $i < j$ and $f(i) > f(j)$. Let their locations be $(x_i, y_i), (x_j, y_j)$, i.e. $i = x_i + p y_i = B_x_i y_i$ and $f(i) = q x_i + y_i = A_x_i y_i$, and similarly for $j$.



      • From matrix $B$, it is obvious that $i = B_x_i y_i < j = B_x_j y_j$ iff $y_j > y_i$ ($j$'s column is to the right of $i$'s column), or, $y_j = y_i$ and $x_j > x_i$ ($j$ is in the same column and below $i$).


      • From matrix $A$, similarly, $f(i) = A_x_i y_i > f(j) = A_x_j y_j$ iff $x_j < x_i$ ($j$'s row is above $i$'s row), or, $x_j = x_i$ and $y_j < y_i$ ($j$ is in same row and to the left of $i$).


      Since we need both conditions above to be true, this means $(i,j)$ is an inversion iff $y_j > y_i$ and $x_j < x_i$, i.e. $(x_j, y_j)$ must be strictly to the right and above $(x_i, y_i)$.



      E.g. in the following colored matrices, the blue cell represents $i=4, f(i) = f(1 + 1 cdot 3) = 5 cdot 1 + 1 = 6$. The red area in the $B$ matrix represents $j> i$ and the red area in the $A$ matrix represents $f(j) < f(i)$. Clearly the only overlap (for this choice of $i$) are the $3$ cells corresponding to $x=0, y=2,3,4$. These are the values of $j$ which form inversions with this choice of $i$.



      $$
      A = beginbmatrix
      colorred0 & colorred1 & colorred2 & colorred3 & colorred4 \
      colorred5 & colorblue6 & 7 & 8 & 9 \
      10 & 11 & 12 & 13 & 14
      endbmatrix,

      B = beginbmatrix
      0 & 3 & colorred6 & colorred9 & colorred12 \
      1 & colorblue4 & colorred7 & colorred10 & colorred13 \
      2 & colorred5 & colorred8 & colorred11 & colorred14
      endbmatrix
      $$



      E.g. $j=6 > i=4$ and $f(j) = f(0 + 2cdot 3) = 5cdot 0 + 2 = 2 < f(i) = 6$.



      So each $(i,j)$ pair that is an inversion is a pair of cells which form the top-right and bottom-left corners of a rectangle, where the rectangle has $c>1$ columns and $r>1$ rows. To count such rectangles, simply pick any $2$ distinct columns, and any $2$ distinct rows. So the final answer, i.e. the total number of inversion pairs, is $p choose 2q choose 2$.






      share|cite|improve this answer











      $endgroup$















        1












        1








        1





        $begingroup$

        We will consider the case $p=3, q=5$ which is easy to draw. Hopefully you agree the ideas generalize. Consider these matrices:



        $$
        A = beginbmatrix
        0 & 1 & 2 & 3 & 4 \
        5 & 6 & 7 & 8 & 9 \
        10 & 11 & 12 & 13 & 14
        endbmatrix,

        B = beginbmatrix
        0 & 3 & 6 & 9 & 12 \
        1 & 4 & 7 & 10 & 13 \
        2 & 5 & 8 & 11 & 14
        endbmatrix
        $$



        Let the rows be numbered $x = 0, 1, 2$ from top to bottom and the columns be numbered $y = 0, 1, 2, 3, 4$ from left to right. Then $A_xy = qx+y$ and $B_xy = x+py$.



        So here's a recipe for evaluating $f(i)$ where $i in mathbbZ_pq$:



        • First, find location $(x,y)$ where $B_xy= i$


        • Then, look up the same location in matrix $A$ and we have $f(i) = A_xy$.


        If I may abuse notation a bit, the chain of mapping that just happened was something like this:



        $$i = x+py = B_xy rightarrow (x,y) rightarrow A_xy = qx+y = f(i) = f(x+py)$$



        which has an overall effect of $x + py rightarrow qx+y$ as desired.



        OK, so how does this help? Consider $(i,j) in mathbbZ_pq^2$. It is an inversion if $i < j$ and $f(i) > f(j)$. Let their locations be $(x_i, y_i), (x_j, y_j)$, i.e. $i = x_i + p y_i = B_x_i y_i$ and $f(i) = q x_i + y_i = A_x_i y_i$, and similarly for $j$.



        • From matrix $B$, it is obvious that $i = B_x_i y_i < j = B_x_j y_j$ iff $y_j > y_i$ ($j$'s column is to the right of $i$'s column), or, $y_j = y_i$ and $x_j > x_i$ ($j$ is in the same column and below $i$).


        • From matrix $A$, similarly, $f(i) = A_x_i y_i > f(j) = A_x_j y_j$ iff $x_j < x_i$ ($j$'s row is above $i$'s row), or, $x_j = x_i$ and $y_j < y_i$ ($j$ is in same row and to the left of $i$).


        Since we need both conditions above to be true, this means $(i,j)$ is an inversion iff $y_j > y_i$ and $x_j < x_i$, i.e. $(x_j, y_j)$ must be strictly to the right and above $(x_i, y_i)$.



        E.g. in the following colored matrices, the blue cell represents $i=4, f(i) = f(1 + 1 cdot 3) = 5 cdot 1 + 1 = 6$. The red area in the $B$ matrix represents $j> i$ and the red area in the $A$ matrix represents $f(j) < f(i)$. Clearly the only overlap (for this choice of $i$) are the $3$ cells corresponding to $x=0, y=2,3,4$. These are the values of $j$ which form inversions with this choice of $i$.



        $$
        A = beginbmatrix
        colorred0 & colorred1 & colorred2 & colorred3 & colorred4 \
        colorred5 & colorblue6 & 7 & 8 & 9 \
        10 & 11 & 12 & 13 & 14
        endbmatrix,

        B = beginbmatrix
        0 & 3 & colorred6 & colorred9 & colorred12 \
        1 & colorblue4 & colorred7 & colorred10 & colorred13 \
        2 & colorred5 & colorred8 & colorred11 & colorred14
        endbmatrix
        $$



        E.g. $j=6 > i=4$ and $f(j) = f(0 + 2cdot 3) = 5cdot 0 + 2 = 2 < f(i) = 6$.



        So each $(i,j)$ pair that is an inversion is a pair of cells which form the top-right and bottom-left corners of a rectangle, where the rectangle has $c>1$ columns and $r>1$ rows. To count such rectangles, simply pick any $2$ distinct columns, and any $2$ distinct rows. So the final answer, i.e. the total number of inversion pairs, is $p choose 2q choose 2$.






        share|cite|improve this answer











        $endgroup$



        We will consider the case $p=3, q=5$ which is easy to draw. Hopefully you agree the ideas generalize. Consider these matrices:



        $$
        A = beginbmatrix
        0 & 1 & 2 & 3 & 4 \
        5 & 6 & 7 & 8 & 9 \
        10 & 11 & 12 & 13 & 14
        endbmatrix,

        B = beginbmatrix
        0 & 3 & 6 & 9 & 12 \
        1 & 4 & 7 & 10 & 13 \
        2 & 5 & 8 & 11 & 14
        endbmatrix
        $$



        Let the rows be numbered $x = 0, 1, 2$ from top to bottom and the columns be numbered $y = 0, 1, 2, 3, 4$ from left to right. Then $A_xy = qx+y$ and $B_xy = x+py$.



        So here's a recipe for evaluating $f(i)$ where $i in mathbbZ_pq$:



        • First, find location $(x,y)$ where $B_xy= i$


        • Then, look up the same location in matrix $A$ and we have $f(i) = A_xy$.


        If I may abuse notation a bit, the chain of mapping that just happened was something like this:



        $$i = x+py = B_xy rightarrow (x,y) rightarrow A_xy = qx+y = f(i) = f(x+py)$$



        which has an overall effect of $x + py rightarrow qx+y$ as desired.



        OK, so how does this help? Consider $(i,j) in mathbbZ_pq^2$. It is an inversion if $i < j$ and $f(i) > f(j)$. Let their locations be $(x_i, y_i), (x_j, y_j)$, i.e. $i = x_i + p y_i = B_x_i y_i$ and $f(i) = q x_i + y_i = A_x_i y_i$, and similarly for $j$.



        • From matrix $B$, it is obvious that $i = B_x_i y_i < j = B_x_j y_j$ iff $y_j > y_i$ ($j$'s column is to the right of $i$'s column), or, $y_j = y_i$ and $x_j > x_i$ ($j$ is in the same column and below $i$).


        • From matrix $A$, similarly, $f(i) = A_x_i y_i > f(j) = A_x_j y_j$ iff $x_j < x_i$ ($j$'s row is above $i$'s row), or, $x_j = x_i$ and $y_j < y_i$ ($j$ is in same row and to the left of $i$).


        Since we need both conditions above to be true, this means $(i,j)$ is an inversion iff $y_j > y_i$ and $x_j < x_i$, i.e. $(x_j, y_j)$ must be strictly to the right and above $(x_i, y_i)$.



        E.g. in the following colored matrices, the blue cell represents $i=4, f(i) = f(1 + 1 cdot 3) = 5 cdot 1 + 1 = 6$. The red area in the $B$ matrix represents $j> i$ and the red area in the $A$ matrix represents $f(j) < f(i)$. Clearly the only overlap (for this choice of $i$) are the $3$ cells corresponding to $x=0, y=2,3,4$. These are the values of $j$ which form inversions with this choice of $i$.



        $$
        A = beginbmatrix
        colorred0 & colorred1 & colorred2 & colorred3 & colorred4 \
        colorred5 & colorblue6 & 7 & 8 & 9 \
        10 & 11 & 12 & 13 & 14
        endbmatrix,

        B = beginbmatrix
        0 & 3 & colorred6 & colorred9 & colorred12 \
        1 & colorblue4 & colorred7 & colorred10 & colorred13 \
        2 & colorred5 & colorred8 & colorred11 & colorred14
        endbmatrix
        $$



        E.g. $j=6 > i=4$ and $f(j) = f(0 + 2cdot 3) = 5cdot 0 + 2 = 2 < f(i) = 6$.



        So each $(i,j)$ pair that is an inversion is a pair of cells which form the top-right and bottom-left corners of a rectangle, where the rectangle has $c>1$ columns and $r>1$ rows. To count such rectangles, simply pick any $2$ distinct columns, and any $2$ distinct rows. So the final answer, i.e. the total number of inversion pairs, is $p choose 2q choose 2$.







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited yesterday

























        answered 2 days ago









        antkamantkam

        2,322212




        2,322212



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3150298%2fcounting-the-number-of-inversions-for-the-function-fxyp-qxy%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Solar Wings Breeze Design and development Specifications (Breeze) References Navigation menu1368-485X"Hang glider: Breeze (Solar Wings)"e

            Kathakali Contents Etymology and nomenclature History Repertoire Songs and musical instruments Traditional plays Styles: Sampradayam Training centers and awards Relationship to other dance forms See also Notes References External links Navigation menueThe Illustrated Encyclopedia of Hinduism: A-MSouth Asian Folklore: An EncyclopediaRoutledge International Encyclopedia of Women: Global Women's Issues and KnowledgeKathakali Dance-drama: Where Gods and Demons Come to PlayKathakali Dance-drama: Where Gods and Demons Come to PlayKathakali Dance-drama: Where Gods and Demons Come to Play10.1353/atj.2005.0004The Illustrated Encyclopedia of Hinduism: A-MEncyclopedia of HinduismKathakali Dance-drama: Where Gods and Demons Come to PlaySonic Liturgy: Ritual and Music in Hindu Tradition"The Mirror of Gesture"Kathakali Dance-drama: Where Gods and Demons Come to Play"Kathakali"Indian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceMedieval Indian Literature: An AnthologyThe Oxford Companion to Indian TheatreSouth Asian Folklore: An Encyclopedia : Afghanistan, Bangladesh, India, Nepal, Pakistan, Sri LankaThe Rise of Performance Studies: Rethinking Richard Schechner's Broad SpectrumIndian Theatre: Traditions of PerformanceModern Asian Theatre and Performance 1900-2000Critical Theory and PerformanceBetween Theater and AnthropologyKathakali603847011Indian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceBetween Theater and AnthropologyBetween Theater and AnthropologyNambeesan Smaraka AwardsArchivedThe Cambridge Guide to TheatreRoutledge International Encyclopedia of Women: Global Women's Issues and KnowledgeThe Garland Encyclopedia of World Music: South Asia : the Indian subcontinentThe Ethos of Noh: Actors and Their Art10.2307/1145740By Means of Performance: Intercultural Studies of Theatre and Ritual10.1017/s204912550000100xReconceiving the Renaissance: A Critical ReaderPerformance TheoryListening to Theatre: The Aural Dimension of Beijing Opera10.2307/1146013Kathakali: The Art of the Non-WorldlyOn KathakaliKathakali, the dance theatreThe Kathakali Complex: Performance & StructureKathakali Dance-Drama: Where Gods and Demons Come to Play10.1093/obo/9780195399318-0071Drama and Ritual of Early Hinduism"In the Shadow of Hollywood Orientalism: Authentic East Indian Dancing"10.1080/08949460490274013Sanskrit Play Production in Ancient IndiaIndian Music: History and StructureBharata, the Nāṭyaśāstra233639306Table of Contents2238067286469807Dance In Indian Painting10.2307/32047833204783Kathakali Dance-Theatre: A Visual Narrative of Sacred Indian MimeIndian Classical Dance: The Renaissance and BeyondKathakali: an indigenous art-form of Keralaeee

            Method to test if a number is a perfect power? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)Detecting perfect squares faster than by extracting square rooteffective way to get the integer sequence A181392 from oeisA rarely mentioned fact about perfect powersHow many numbers such $n$ are there that $n<100,lfloorsqrtn rfloor mid n$Check perfect squareness by modulo division against multiple basesFor what pair of integers $(a,b)$ is $3^a + 7^b$ a perfect square.Do there exist any positive integers $n$ such that $lfloore^nrfloor$ is a perfect power? What is the probability that one exists?finding perfect power factors of an integerProve that the sequence contains a perfect square for any natural number $m $ in the domain of $f$ .Counting Perfect Powers