Swapping registers in an old calculator












5














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



























    5














    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

























      5












      5








      5







      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 4 hours ago









      mlerma54

      1434




      1434






















          2 Answers
          2






          active

          oldest

          votes


















          2














          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
            4 hours ago






          • 2




            @DrXorile Oops, so it seems...
            – jafe
            4 hours ago



















          1














          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





















            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









            2














            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
              4 hours ago






            • 2




              @DrXorile Oops, so it seems...
              – jafe
              4 hours ago
















            2














            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
              4 hours ago






            • 2




              @DrXorile Oops, so it seems...
              – jafe
              4 hours ago














            2












            2








            2






            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 4 hours ago

























            answered 4 hours ago









            jafe

            16.8k243168




            16.8k243168








            • 2




              Task 2 the second operation isn't in the list of allowed operations
              – Dr Xorile
              4 hours ago






            • 2




              @DrXorile Oops, so it seems...
              – jafe
              4 hours ago














            • 2




              Task 2 the second operation isn't in the list of allowed operations
              – Dr Xorile
              4 hours ago






            • 2




              @DrXorile Oops, so it seems...
              – jafe
              4 hours ago








            2




            2




            Task 2 the second operation isn't in the list of allowed operations
            – Dr Xorile
            4 hours ago




            Task 2 the second operation isn't in the list of allowed operations
            – Dr Xorile
            4 hours ago




            2




            2




            @DrXorile Oops, so it seems...
            – jafe
            4 hours ago




            @DrXorile Oops, so it seems...
            – jafe
            4 hours ago











            1














            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


























              1














              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
























                1












                1








                1






                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












                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











                share


                share










                answered 7 mins ago









                Anders Kaseorg

                40625




                40625






























                    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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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.


                    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

                    Understanding the information contained in the Deep Space Network XML data?

                    Ross-on-Wye

                    Eastern Orthodox Church