Swapping registers in an old calculator












10















I came up with this problem inspired by the limitations of an old non-scientific calculator I owned years ago (the two registers were the display, and an internal memory for an additional number).



We have a primitive calculator with only two registers $R_1$ and $R_2$, and the following four operations:




  • $R_1+R_2to R_2$ (add the content of register $R_1$ to register $R_2$.)


  • $-R_1+R_2to R_2$ (subtract the content of register $R_1$ from register $R_2$.)


  • $R_1+R_2to R_1$ (add the content of register $R_2$ to register $R_1$.)


  • $R_1-R_2to R_1$ (subtract the content of register $R_2$ from register $R_1$.)



For instance, if $R_1=x$ (register $R_1$ contains number $x$) and
$R_2=y$ ($R_2$ contains $y$), after applying the operation $R_1+R_2to
R_2$
we end up with $R_1=x$ and $R_2=x+y$.



Assume that initially we have $R_1=x$ and $R_2=y$, where $x$ and $y$ are arbitrary numbers. For each of the following tasks describe a sequence of operations that would allow us to perform it, or prove that the task cannot be performed (task 1 is very easy, the real challenge is about task 2):




  • Task 1. Swap the contents of registers $R_1$ and $R_2$ changing the sign of $y$ in the process, so we would end up with $R_1=-y$, $R_2=x$.


  • Task 2. Swap the contents of registers $R_1$ and $R_2$, so that we would end up with $R_1=y$, $R_2=x$.











share|improve this question



























    10















    I came up with this problem inspired by the limitations of an old non-scientific calculator I owned years ago (the two registers were the display, and an internal memory for an additional number).



    We have a primitive calculator with only two registers $R_1$ and $R_2$, and the following four operations:




    • $R_1+R_2to R_2$ (add the content of register $R_1$ to register $R_2$.)


    • $-R_1+R_2to R_2$ (subtract the content of register $R_1$ from register $R_2$.)


    • $R_1+R_2to R_1$ (add the content of register $R_2$ to register $R_1$.)


    • $R_1-R_2to R_1$ (subtract the content of register $R_2$ from register $R_1$.)



    For instance, if $R_1=x$ (register $R_1$ contains number $x$) and
    $R_2=y$ ($R_2$ contains $y$), after applying the operation $R_1+R_2to
    R_2$
    we end up with $R_1=x$ and $R_2=x+y$.



    Assume that initially we have $R_1=x$ and $R_2=y$, where $x$ and $y$ are arbitrary numbers. For each of the following tasks describe a sequence of operations that would allow us to perform it, or prove that the task cannot be performed (task 1 is very easy, the real challenge is about task 2):




    • Task 1. Swap the contents of registers $R_1$ and $R_2$ changing the sign of $y$ in the process, so we would end up with $R_1=-y$, $R_2=x$.


    • Task 2. Swap the contents of registers $R_1$ and $R_2$, so that we would end up with $R_1=y$, $R_2=x$.











    share|improve this question

























      10












      10








      10


      0






      I came up with this problem inspired by the limitations of an old non-scientific calculator I owned years ago (the two registers were the display, and an internal memory for an additional number).



      We have a primitive calculator with only two registers $R_1$ and $R_2$, and the following four operations:




      • $R_1+R_2to R_2$ (add the content of register $R_1$ to register $R_2$.)


      • $-R_1+R_2to R_2$ (subtract the content of register $R_1$ from register $R_2$.)


      • $R_1+R_2to R_1$ (add the content of register $R_2$ to register $R_1$.)


      • $R_1-R_2to R_1$ (subtract the content of register $R_2$ from register $R_1$.)



      For instance, if $R_1=x$ (register $R_1$ contains number $x$) and
      $R_2=y$ ($R_2$ contains $y$), after applying the operation $R_1+R_2to
      R_2$
      we end up with $R_1=x$ and $R_2=x+y$.



      Assume that initially we have $R_1=x$ and $R_2=y$, where $x$ and $y$ are arbitrary numbers. For each of the following tasks describe a sequence of operations that would allow us to perform it, or prove that the task cannot be performed (task 1 is very easy, the real challenge is about task 2):




      • Task 1. Swap the contents of registers $R_1$ and $R_2$ changing the sign of $y$ in the process, so we would end up with $R_1=-y$, $R_2=x$.


      • Task 2. Swap the contents of registers $R_1$ and $R_2$, so that we would end up with $R_1=y$, $R_2=x$.











      share|improve this question














      I came up with this problem inspired by the limitations of an old non-scientific calculator I owned years ago (the two registers were the display, and an internal memory for an additional number).



      We have a primitive calculator with only two registers $R_1$ and $R_2$, and the following four operations:




      • $R_1+R_2to R_2$ (add the content of register $R_1$ to register $R_2$.)


      • $-R_1+R_2to R_2$ (subtract the content of register $R_1$ from register $R_2$.)


      • $R_1+R_2to R_1$ (add the content of register $R_2$ to register $R_1$.)


      • $R_1-R_2to R_1$ (subtract the content of register $R_2$ from register $R_1$.)



      For instance, if $R_1=x$ (register $R_1$ contains number $x$) and
      $R_2=y$ ($R_2$ contains $y$), after applying the operation $R_1+R_2to
      R_2$
      we end up with $R_1=x$ and $R_2=x+y$.



      Assume that initially we have $R_1=x$ and $R_2=y$, where $x$ and $y$ are arbitrary numbers. For each of the following tasks describe a sequence of operations that would allow us to perform it, or prove that the task cannot be performed (task 1 is very easy, the real challenge is about task 2):




      • Task 1. Swap the contents of registers $R_1$ and $R_2$ changing the sign of $y$ in the process, so we would end up with $R_1=-y$, $R_2=x$.


      • Task 2. Swap the contents of registers $R_1$ and $R_2$, so that we would end up with $R_1=y$, $R_2=x$.








      reachability






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 5:43









      mlerma54mlerma54

      1705




      1705






















          2 Answers
          2






          active

          oldest

          votes


















          15














          Task 1 was answered. Task 2:




          Not possible. We always have $begin{bmatrix}R_1 \ R_2end{bmatrix} = Mbegin{bmatrix}x \ yend{bmatrix}$ for some matrix $M$ that depends only on the sequence of operations. Initially $M = begin{bmatrix}1 & 0 \ 0 & 1end{bmatrix}$, and the given operations cause $M$ to be left-multiplied by $begin{bmatrix}1 & 0 \ 1 & 1end{bmatrix}$, $begin{bmatrix}1 & 0 \ -1 & 1end{bmatrix}$, $begin{bmatrix}1 & 1 \ 0 & 1end{bmatrix}$, and $begin{bmatrix}1 & -1 \ 0 & 1end{bmatrix}$ respectively. All of these matrices have determinant $1$, so we will always have $det M = 1$, which makes it impossible to reach the desired $begin{bmatrix}0 & 1 \ 1 & 0end{bmatrix}$ with determinant $-1$.







          share|improve this answer
























          • I had a feeling this was true. Very neat proof.

            – Dr Xorile
            Jan 3 at 15:23



















          4














          Task 1




          1. $R_1 - R_2to R_1$ (now $R_1 = x-y$, $R_2 = y$)

          2. $R_1 + R_2to R_2$ (now $R_1 = x-y$, $R_2 = x$)

          3. $R_1 - R_2to R_1$ (now $R_1 = -y$, $R_2 = x$)







          share|improve this answer





















          • 2





            Task 2 the second operation isn't in the list of allowed operations

            – Dr Xorile
            Jan 3 at 6:26






          • 2





            @DrXorile Oops, so it seems...

            – jafe
            Jan 3 at 6:27











          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: "559"
          };
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2fpuzzling.stackexchange.com%2fquestions%2f78059%2fswapping-registers-in-an-old-calculator%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          15














          Task 1 was answered. Task 2:




          Not possible. We always have $begin{bmatrix}R_1 \ R_2end{bmatrix} = Mbegin{bmatrix}x \ yend{bmatrix}$ for some matrix $M$ that depends only on the sequence of operations. Initially $M = begin{bmatrix}1 & 0 \ 0 & 1end{bmatrix}$, and the given operations cause $M$ to be left-multiplied by $begin{bmatrix}1 & 0 \ 1 & 1end{bmatrix}$, $begin{bmatrix}1 & 0 \ -1 & 1end{bmatrix}$, $begin{bmatrix}1 & 1 \ 0 & 1end{bmatrix}$, and $begin{bmatrix}1 & -1 \ 0 & 1end{bmatrix}$ respectively. All of these matrices have determinant $1$, so we will always have $det M = 1$, which makes it impossible to reach the desired $begin{bmatrix}0 & 1 \ 1 & 0end{bmatrix}$ with determinant $-1$.







          share|improve this answer
























          • I had a feeling this was true. Very neat proof.

            – Dr Xorile
            Jan 3 at 15:23
















          15














          Task 1 was answered. Task 2:




          Not possible. We always have $begin{bmatrix}R_1 \ R_2end{bmatrix} = Mbegin{bmatrix}x \ yend{bmatrix}$ for some matrix $M$ that depends only on the sequence of operations. Initially $M = begin{bmatrix}1 & 0 \ 0 & 1end{bmatrix}$, and the given operations cause $M$ to be left-multiplied by $begin{bmatrix}1 & 0 \ 1 & 1end{bmatrix}$, $begin{bmatrix}1 & 0 \ -1 & 1end{bmatrix}$, $begin{bmatrix}1 & 1 \ 0 & 1end{bmatrix}$, and $begin{bmatrix}1 & -1 \ 0 & 1end{bmatrix}$ respectively. All of these matrices have determinant $1$, so we will always have $det M = 1$, which makes it impossible to reach the desired $begin{bmatrix}0 & 1 \ 1 & 0end{bmatrix}$ with determinant $-1$.







          share|improve this answer
























          • I had a feeling this was true. Very neat proof.

            – Dr Xorile
            Jan 3 at 15:23














          15












          15








          15







          Task 1 was answered. Task 2:




          Not possible. We always have $begin{bmatrix}R_1 \ R_2end{bmatrix} = Mbegin{bmatrix}x \ yend{bmatrix}$ for some matrix $M$ that depends only on the sequence of operations. Initially $M = begin{bmatrix}1 & 0 \ 0 & 1end{bmatrix}$, and the given operations cause $M$ to be left-multiplied by $begin{bmatrix}1 & 0 \ 1 & 1end{bmatrix}$, $begin{bmatrix}1 & 0 \ -1 & 1end{bmatrix}$, $begin{bmatrix}1 & 1 \ 0 & 1end{bmatrix}$, and $begin{bmatrix}1 & -1 \ 0 & 1end{bmatrix}$ respectively. All of these matrices have determinant $1$, so we will always have $det M = 1$, which makes it impossible to reach the desired $begin{bmatrix}0 & 1 \ 1 & 0end{bmatrix}$ with determinant $-1$.







          share|improve this answer













          Task 1 was answered. Task 2:




          Not possible. We always have $begin{bmatrix}R_1 \ R_2end{bmatrix} = Mbegin{bmatrix}x \ yend{bmatrix}$ for some matrix $M$ that depends only on the sequence of operations. Initially $M = begin{bmatrix}1 & 0 \ 0 & 1end{bmatrix}$, and the given operations cause $M$ to be left-multiplied by $begin{bmatrix}1 & 0 \ 1 & 1end{bmatrix}$, $begin{bmatrix}1 & 0 \ -1 & 1end{bmatrix}$, $begin{bmatrix}1 & 1 \ 0 & 1end{bmatrix}$, and $begin{bmatrix}1 & -1 \ 0 & 1end{bmatrix}$ respectively. All of these matrices have determinant $1$, so we will always have $det M = 1$, which makes it impossible to reach the desired $begin{bmatrix}0 & 1 \ 1 & 0end{bmatrix}$ with determinant $-1$.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 3 at 10:25









          Anders KaseorgAnders Kaseorg

          56136




          56136













          • I had a feeling this was true. Very neat proof.

            – Dr Xorile
            Jan 3 at 15:23



















          • I had a feeling this was true. Very neat proof.

            – Dr Xorile
            Jan 3 at 15:23

















          I had a feeling this was true. Very neat proof.

          – Dr Xorile
          Jan 3 at 15:23





          I had a feeling this was true. Very neat proof.

          – Dr Xorile
          Jan 3 at 15:23











          4














          Task 1




          1. $R_1 - R_2to R_1$ (now $R_1 = x-y$, $R_2 = y$)

          2. $R_1 + R_2to R_2$ (now $R_1 = x-y$, $R_2 = x$)

          3. $R_1 - R_2to R_1$ (now $R_1 = -y$, $R_2 = x$)







          share|improve this answer





















          • 2





            Task 2 the second operation isn't in the list of allowed operations

            – Dr Xorile
            Jan 3 at 6:26






          • 2





            @DrXorile Oops, so it seems...

            – jafe
            Jan 3 at 6:27
















          4














          Task 1




          1. $R_1 - R_2to R_1$ (now $R_1 = x-y$, $R_2 = y$)

          2. $R_1 + R_2to R_2$ (now $R_1 = x-y$, $R_2 = x$)

          3. $R_1 - R_2to R_1$ (now $R_1 = -y$, $R_2 = x$)







          share|improve this answer





















          • 2





            Task 2 the second operation isn't in the list of allowed operations

            – Dr Xorile
            Jan 3 at 6:26






          • 2





            @DrXorile Oops, so it seems...

            – jafe
            Jan 3 at 6:27














          4












          4








          4







          Task 1




          1. $R_1 - R_2to R_1$ (now $R_1 = x-y$, $R_2 = y$)

          2. $R_1 + R_2to R_2$ (now $R_1 = x-y$, $R_2 = x$)

          3. $R_1 - R_2to R_1$ (now $R_1 = -y$, $R_2 = x$)







          share|improve this answer















          Task 1




          1. $R_1 - R_2to R_1$ (now $R_1 = x-y$, $R_2 = y$)

          2. $R_1 + R_2to R_2$ (now $R_1 = x-y$, $R_2 = x$)

          3. $R_1 - R_2to R_1$ (now $R_1 = -y$, $R_2 = x$)








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 3 at 6:27

























          answered Jan 3 at 6:12









          jafejafe

          17.8k350176




          17.8k350176








          • 2





            Task 2 the second operation isn't in the list of allowed operations

            – Dr Xorile
            Jan 3 at 6:26






          • 2





            @DrXorile Oops, so it seems...

            – jafe
            Jan 3 at 6:27














          • 2





            Task 2 the second operation isn't in the list of allowed operations

            – Dr Xorile
            Jan 3 at 6:26






          • 2





            @DrXorile Oops, so it seems...

            – jafe
            Jan 3 at 6:27








          2




          2





          Task 2 the second operation isn't in the list of allowed operations

          – Dr Xorile
          Jan 3 at 6:26





          Task 2 the second operation isn't in the list of allowed operations

          – Dr Xorile
          Jan 3 at 6:26




          2




          2





          @DrXorile Oops, so it seems...

          – jafe
          Jan 3 at 6:27





          @DrXorile Oops, so it seems...

          – jafe
          Jan 3 at 6:27


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Puzzling 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%2fpuzzling.stackexchange.com%2fquestions%2f78059%2fswapping-registers-in-an-old-calculator%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

          Human spaceflight

          Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

          File:DeusFollowingSea.jpg