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

            How should I support this large drywall patch? Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How do I cover large gaps in drywall?How do I keep drywall around a patch from crumbling?Can I glue a second layer of drywall?How to patch long strip on drywall?Large drywall patch: how to avoid bulging seams?Drywall Mesh Patch vs. Bulge? To remove or not to remove?How to fix this drywall job?Prep drywall before backsplashWhat's the best way to fix this horrible drywall patch job?Drywall patching using 3M Patch Plus Primer

            random experiment with two different functions on unit interval Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)Random variable and probability space notionsRandom Walk with EdgesFinding functions where the increase over a random interval is Poisson distributedNumber of days until dayCan an observed event in fact be of zero probability?Unit random processmodels of coins and uniform distributionHow to get the number of successes given $n$ trials , probability $P$ and a random variable $X$Absorbing Markov chain in a computer. Is “almost every” turned into always convergence in computer executions?Stopped random walk is not uniformly integrable

            Lowndes Grove History Architecture References Navigation menu32°48′6″N 79°57′58″W / 32.80167°N 79.96611°W / 32.80167; -79.9661132°48′6″N 79°57′58″W / 32.80167°N 79.96611°W / 32.80167; -79.9661178002500"National Register Information System"Historic houses of South Carolina"Lowndes Grove""+32° 48' 6.00", −79° 57' 58.00""Lowndes Grove, Charleston County (260 St. Margaret St., Charleston)""Lowndes Grove"The Charleston ExpositionIt Happened in South Carolina"Lowndes Grove (House), Saint Margaret Street & Sixth Avenue, Charleston, Charleston County, SC(Photographs)"Plantations of the Carolina Low Countrye