Swapping registers in an old calculator
$begingroup$
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
$endgroup$
add a comment |
$begingroup$
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
$endgroup$
add a comment |
$begingroup$
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
$endgroup$
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
reachability
asked Jan 3 at 5:43
mlerma54mlerma54
1705
1705
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
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$.
$endgroup$
$begingroup$
I had a feeling this was true. Very neat proof.
$endgroup$
– Dr Xorile
Jan 3 at 15:23
add a comment |
$begingroup$
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$)
$endgroup$
2
$begingroup$
Task 2 the second operation isn't in the list of allowed operations
$endgroup$
– Dr Xorile
Jan 3 at 6:26
2
$begingroup$
@DrXorile Oops, so it seems...
$endgroup$
– jafe
Jan 3 at 6:27
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
$begingroup$
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$.
$endgroup$
$begingroup$
I had a feeling this was true. Very neat proof.
$endgroup$
– Dr Xorile
Jan 3 at 15:23
add a comment |
$begingroup$
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$.
$endgroup$
$begingroup$
I had a feeling this was true. Very neat proof.
$endgroup$
– Dr Xorile
Jan 3 at 15:23
add a comment |
$begingroup$
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$.
$endgroup$
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$.
answered Jan 3 at 10:25
Anders KaseorgAnders Kaseorg
56136
56136
$begingroup$
I had a feeling this was true. Very neat proof.
$endgroup$
– Dr Xorile
Jan 3 at 15:23
add a comment |
$begingroup$
I had a feeling this was true. Very neat proof.
$endgroup$
– Dr Xorile
Jan 3 at 15:23
$begingroup$
I had a feeling this was true. Very neat proof.
$endgroup$
– Dr Xorile
Jan 3 at 15:23
$begingroup$
I had a feeling this was true. Very neat proof.
$endgroup$
– Dr Xorile
Jan 3 at 15:23
add a comment |
$begingroup$
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$)
$endgroup$
2
$begingroup$
Task 2 the second operation isn't in the list of allowed operations
$endgroup$
– Dr Xorile
Jan 3 at 6:26
2
$begingroup$
@DrXorile Oops, so it seems...
$endgroup$
– jafe
Jan 3 at 6:27
add a comment |
$begingroup$
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$)
$endgroup$
2
$begingroup$
Task 2 the second operation isn't in the list of allowed operations
$endgroup$
– Dr Xorile
Jan 3 at 6:26
2
$begingroup$
@DrXorile Oops, so it seems...
$endgroup$
– jafe
Jan 3 at 6:27
add a comment |
$begingroup$
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$)
$endgroup$
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$)
edited Jan 3 at 6:27
answered Jan 3 at 6:12
jafejafe
18.4k351179
18.4k351179
2
$begingroup$
Task 2 the second operation isn't in the list of allowed operations
$endgroup$
– Dr Xorile
Jan 3 at 6:26
2
$begingroup$
@DrXorile Oops, so it seems...
$endgroup$
– jafe
Jan 3 at 6:27
add a comment |
2
$begingroup$
Task 2 the second operation isn't in the list of allowed operations
$endgroup$
– Dr Xorile
Jan 3 at 6:26
2
$begingroup$
@DrXorile Oops, so it seems...
$endgroup$
– jafe
Jan 3 at 6:27
2
2
$begingroup$
Task 2 the second operation isn't in the list of allowed operations
$endgroup$
– Dr Xorile
Jan 3 at 6:26
$begingroup$
Task 2 the second operation isn't in the list of allowed operations
$endgroup$
– Dr Xorile
Jan 3 at 6:26
2
2
$begingroup$
@DrXorile Oops, so it seems...
$endgroup$
– jafe
Jan 3 at 6:27
$begingroup$
@DrXorile Oops, so it seems...
$endgroup$
– jafe
Jan 3 at 6:27
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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