can anyone give me a function on the integer defined as $f_n(f_n(x))=x$ please?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I need a function $f_n$ wich for all integer n is an Involution on the integer.



Put in another way I need a function $f_n$ so that $f_n(f_n(x))=x$ for all integer x and n)



ps: And wich is as much as possible is "different" when given different n since this function is supposed to be used with x corresponding to a character to encode and n a corresponding to a character of the key.







share|cite|improve this question





















  • Here is a smaller example from which you can try to build larger examples: $f_n(x)=begincases n&textif~x=1\1&textif~x=n\x&textotherwiseendcases$. If you were to think of $f_n$ as a "permutation" on the integers (ignoring the requirement that permutations are ordinarily only from a finite set to itself), in the disjoint cyclic representation the only appearing cycles would be of length $2$ for every $n$. The above would be represented in disjoint cyclic representation as $(1~n)$.
    – JMoravitz
    Jul 19 at 15:59











  • actually i started by using a pseudo random algorithm to randomly shuffle the integer in the range i needed and using n as a seed but I prefer using a well defined function because storing shuffled list require a lot of memory.
    – Joseph Touzet
    Jul 19 at 16:14














up vote
3
down vote

favorite












I need a function $f_n$ wich for all integer n is an Involution on the integer.



Put in another way I need a function $f_n$ so that $f_n(f_n(x))=x$ for all integer x and n)



ps: And wich is as much as possible is "different" when given different n since this function is supposed to be used with x corresponding to a character to encode and n a corresponding to a character of the key.







share|cite|improve this question





















  • Here is a smaller example from which you can try to build larger examples: $f_n(x)=begincases n&textif~x=1\1&textif~x=n\x&textotherwiseendcases$. If you were to think of $f_n$ as a "permutation" on the integers (ignoring the requirement that permutations are ordinarily only from a finite set to itself), in the disjoint cyclic representation the only appearing cycles would be of length $2$ for every $n$. The above would be represented in disjoint cyclic representation as $(1~n)$.
    – JMoravitz
    Jul 19 at 15:59











  • actually i started by using a pseudo random algorithm to randomly shuffle the integer in the range i needed and using n as a seed but I prefer using a well defined function because storing shuffled list require a lot of memory.
    – Joseph Touzet
    Jul 19 at 16:14












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I need a function $f_n$ wich for all integer n is an Involution on the integer.



Put in another way I need a function $f_n$ so that $f_n(f_n(x))=x$ for all integer x and n)



ps: And wich is as much as possible is "different" when given different n since this function is supposed to be used with x corresponding to a character to encode and n a corresponding to a character of the key.







share|cite|improve this question













I need a function $f_n$ wich for all integer n is an Involution on the integer.



Put in another way I need a function $f_n$ so that $f_n(f_n(x))=x$ for all integer x and n)



ps: And wich is as much as possible is "different" when given different n since this function is supposed to be used with x corresponding to a character to encode and n a corresponding to a character of the key.









share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Jul 19 at 15:58
























asked Jul 19 at 15:53









Joseph Touzet

184




184











  • Here is a smaller example from which you can try to build larger examples: $f_n(x)=begincases n&textif~x=1\1&textif~x=n\x&textotherwiseendcases$. If you were to think of $f_n$ as a "permutation" on the integers (ignoring the requirement that permutations are ordinarily only from a finite set to itself), in the disjoint cyclic representation the only appearing cycles would be of length $2$ for every $n$. The above would be represented in disjoint cyclic representation as $(1~n)$.
    – JMoravitz
    Jul 19 at 15:59











  • actually i started by using a pseudo random algorithm to randomly shuffle the integer in the range i needed and using n as a seed but I prefer using a well defined function because storing shuffled list require a lot of memory.
    – Joseph Touzet
    Jul 19 at 16:14
















  • Here is a smaller example from which you can try to build larger examples: $f_n(x)=begincases n&textif~x=1\1&textif~x=n\x&textotherwiseendcases$. If you were to think of $f_n$ as a "permutation" on the integers (ignoring the requirement that permutations are ordinarily only from a finite set to itself), in the disjoint cyclic representation the only appearing cycles would be of length $2$ for every $n$. The above would be represented in disjoint cyclic representation as $(1~n)$.
    – JMoravitz
    Jul 19 at 15:59











  • actually i started by using a pseudo random algorithm to randomly shuffle the integer in the range i needed and using n as a seed but I prefer using a well defined function because storing shuffled list require a lot of memory.
    – Joseph Touzet
    Jul 19 at 16:14















Here is a smaller example from which you can try to build larger examples: $f_n(x)=begincases n&textif~x=1\1&textif~x=n\x&textotherwiseendcases$. If you were to think of $f_n$ as a "permutation" on the integers (ignoring the requirement that permutations are ordinarily only from a finite set to itself), in the disjoint cyclic representation the only appearing cycles would be of length $2$ for every $n$. The above would be represented in disjoint cyclic representation as $(1~n)$.
– JMoravitz
Jul 19 at 15:59





Here is a smaller example from which you can try to build larger examples: $f_n(x)=begincases n&textif~x=1\1&textif~x=n\x&textotherwiseendcases$. If you were to think of $f_n$ as a "permutation" on the integers (ignoring the requirement that permutations are ordinarily only from a finite set to itself), in the disjoint cyclic representation the only appearing cycles would be of length $2$ for every $n$. The above would be represented in disjoint cyclic representation as $(1~n)$.
– JMoravitz
Jul 19 at 15:59













actually i started by using a pseudo random algorithm to randomly shuffle the integer in the range i needed and using n as a seed but I prefer using a well defined function because storing shuffled list require a lot of memory.
– Joseph Touzet
Jul 19 at 16:14




actually i started by using a pseudo random algorithm to randomly shuffle the integer in the range i needed and using n as a seed but I prefer using a well defined function because storing shuffled list require a lot of memory.
– Joseph Touzet
Jul 19 at 16:14










3 Answers
3






active

oldest

votes

















up vote
2
down vote



accepted










A classical example is $f_n(x) = x oplus n$ where $oplus$ is the binary XOR.






share|cite|improve this answer





















  • oh and as it turned out the xor operator even fill a implicit condition i didn't mentioned :if i apply a function to two integer representing character and the result is greater than both integer i may have a result too big to be represented as a character and applying a modulo may broke the involutional property of the function. But in this case if i apply the xor operator to each bit represeneting two number the resulting number has to be smaller than both number. Great solution thanks ! ironicly i thinked of that first but i turned away from it since i wanted to keep my character as integer
    – Joseph Touzet
    Jul 19 at 17:32


















up vote
1
down vote













I dont not have enough reputations to do this request like a comment



I am not sure but what do you think about $f_n(x)=(-1)^nx $






share|cite|improve this answer




























    up vote
    1
    down vote













    How about $f_n(x)$ splits the integers into intervals of length $n$ and reverses each interval, i.e.
    $$
    f_1(x) = 1,2,3,4,5,6,7,8,9,10,...\
    f_2(x) = 2,1,4,3,6,5,8,7,10,9,...\
    f_3(x) = 3,2,1,6,5,4,9,8,7,12...\
    f_4(x) = 4,3,2,1,8,7,6,5,12,11,...\
    f_5(x) = 5,4,3,2,1,10,9,8,7,6,...
    $$
    and so on.






    share|cite|improve this answer





















      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',
      convertImagesToLinks: true,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      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%2f2856769%2fcan-anyone-give-me-a-function-on-the-integer-defined-as-f-nf-nx-x-plea%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote



      accepted










      A classical example is $f_n(x) = x oplus n$ where $oplus$ is the binary XOR.






      share|cite|improve this answer





















      • oh and as it turned out the xor operator even fill a implicit condition i didn't mentioned :if i apply a function to two integer representing character and the result is greater than both integer i may have a result too big to be represented as a character and applying a modulo may broke the involutional property of the function. But in this case if i apply the xor operator to each bit represeneting two number the resulting number has to be smaller than both number. Great solution thanks ! ironicly i thinked of that first but i turned away from it since i wanted to keep my character as integer
        – Joseph Touzet
        Jul 19 at 17:32















      up vote
      2
      down vote



      accepted










      A classical example is $f_n(x) = x oplus n$ where $oplus$ is the binary XOR.






      share|cite|improve this answer





















      • oh and as it turned out the xor operator even fill a implicit condition i didn't mentioned :if i apply a function to two integer representing character and the result is greater than both integer i may have a result too big to be represented as a character and applying a modulo may broke the involutional property of the function. But in this case if i apply the xor operator to each bit represeneting two number the resulting number has to be smaller than both number. Great solution thanks ! ironicly i thinked of that first but i turned away from it since i wanted to keep my character as integer
        – Joseph Touzet
        Jul 19 at 17:32













      up vote
      2
      down vote



      accepted







      up vote
      2
      down vote



      accepted






      A classical example is $f_n(x) = x oplus n$ where $oplus$ is the binary XOR.






      share|cite|improve this answer













      A classical example is $f_n(x) = x oplus n$ where $oplus$ is the binary XOR.







      share|cite|improve this answer













      share|cite|improve this answer



      share|cite|improve this answer











      answered Jul 19 at 16:01









      orlp

      6,6051228




      6,6051228











      • oh and as it turned out the xor operator even fill a implicit condition i didn't mentioned :if i apply a function to two integer representing character and the result is greater than both integer i may have a result too big to be represented as a character and applying a modulo may broke the involutional property of the function. But in this case if i apply the xor operator to each bit represeneting two number the resulting number has to be smaller than both number. Great solution thanks ! ironicly i thinked of that first but i turned away from it since i wanted to keep my character as integer
        – Joseph Touzet
        Jul 19 at 17:32

















      • oh and as it turned out the xor operator even fill a implicit condition i didn't mentioned :if i apply a function to two integer representing character and the result is greater than both integer i may have a result too big to be represented as a character and applying a modulo may broke the involutional property of the function. But in this case if i apply the xor operator to each bit represeneting two number the resulting number has to be smaller than both number. Great solution thanks ! ironicly i thinked of that first but i turned away from it since i wanted to keep my character as integer
        – Joseph Touzet
        Jul 19 at 17:32
















      oh and as it turned out the xor operator even fill a implicit condition i didn't mentioned :if i apply a function to two integer representing character and the result is greater than both integer i may have a result too big to be represented as a character and applying a modulo may broke the involutional property of the function. But in this case if i apply the xor operator to each bit represeneting two number the resulting number has to be smaller than both number. Great solution thanks ! ironicly i thinked of that first but i turned away from it since i wanted to keep my character as integer
      – Joseph Touzet
      Jul 19 at 17:32





      oh and as it turned out the xor operator even fill a implicit condition i didn't mentioned :if i apply a function to two integer representing character and the result is greater than both integer i may have a result too big to be represented as a character and applying a modulo may broke the involutional property of the function. But in this case if i apply the xor operator to each bit represeneting two number the resulting number has to be smaller than both number. Great solution thanks ! ironicly i thinked of that first but i turned away from it since i wanted to keep my character as integer
      – Joseph Touzet
      Jul 19 at 17:32











      up vote
      1
      down vote













      I dont not have enough reputations to do this request like a comment



      I am not sure but what do you think about $f_n(x)=(-1)^nx $






      share|cite|improve this answer

























        up vote
        1
        down vote













        I dont not have enough reputations to do this request like a comment



        I am not sure but what do you think about $f_n(x)=(-1)^nx $






        share|cite|improve this answer























          up vote
          1
          down vote










          up vote
          1
          down vote









          I dont not have enough reputations to do this request like a comment



          I am not sure but what do you think about $f_n(x)=(-1)^nx $






          share|cite|improve this answer













          I dont not have enough reputations to do this request like a comment



          I am not sure but what do you think about $f_n(x)=(-1)^nx $







          share|cite|improve this answer













          share|cite|improve this answer



          share|cite|improve this answer











          answered Jul 19 at 16:01









          Bernstein

          8312




          8312




















              up vote
              1
              down vote













              How about $f_n(x)$ splits the integers into intervals of length $n$ and reverses each interval, i.e.
              $$
              f_1(x) = 1,2,3,4,5,6,7,8,9,10,...\
              f_2(x) = 2,1,4,3,6,5,8,7,10,9,...\
              f_3(x) = 3,2,1,6,5,4,9,8,7,12...\
              f_4(x) = 4,3,2,1,8,7,6,5,12,11,...\
              f_5(x) = 5,4,3,2,1,10,9,8,7,6,...
              $$
              and so on.






              share|cite|improve this answer

























                up vote
                1
                down vote













                How about $f_n(x)$ splits the integers into intervals of length $n$ and reverses each interval, i.e.
                $$
                f_1(x) = 1,2,3,4,5,6,7,8,9,10,...\
                f_2(x) = 2,1,4,3,6,5,8,7,10,9,...\
                f_3(x) = 3,2,1,6,5,4,9,8,7,12...\
                f_4(x) = 4,3,2,1,8,7,6,5,12,11,...\
                f_5(x) = 5,4,3,2,1,10,9,8,7,6,...
                $$
                and so on.






                share|cite|improve this answer























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  How about $f_n(x)$ splits the integers into intervals of length $n$ and reverses each interval, i.e.
                  $$
                  f_1(x) = 1,2,3,4,5,6,7,8,9,10,...\
                  f_2(x) = 2,1,4,3,6,5,8,7,10,9,...\
                  f_3(x) = 3,2,1,6,5,4,9,8,7,12...\
                  f_4(x) = 4,3,2,1,8,7,6,5,12,11,...\
                  f_5(x) = 5,4,3,2,1,10,9,8,7,6,...
                  $$
                  and so on.






                  share|cite|improve this answer













                  How about $f_n(x)$ splits the integers into intervals of length $n$ and reverses each interval, i.e.
                  $$
                  f_1(x) = 1,2,3,4,5,6,7,8,9,10,...\
                  f_2(x) = 2,1,4,3,6,5,8,7,10,9,...\
                  f_3(x) = 3,2,1,6,5,4,9,8,7,12...\
                  f_4(x) = 4,3,2,1,8,7,6,5,12,11,...\
                  f_5(x) = 5,4,3,2,1,10,9,8,7,6,...
                  $$
                  and so on.







                  share|cite|improve this answer













                  share|cite|improve this answer



                  share|cite|improve this answer











                  answered Jul 19 at 16:02









                  Dark Malthorp

                  777212




                  777212






















                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2856769%2fcan-anyone-give-me-a-function-on-the-integer-defined-as-f-nf-nx-x-plea%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What is the equation of a 3D cone with generalised tilt?

                      Color the edges and diagonals of a regular polygon

                      Relationship between determinant of matrix and determinant of adjoint?