Design a Turing machine which computes the sum of two numbers in base $2$
$begingroup$
Question:
Design a Turing machine which computes the sum of two numbers in base $2$. For example, If the input is $110x1$, The machine should return $000x111$ (which means: $6+1=7$)
My try:
At each iteration, decrease the first number by $1$, and increase the second one by $1$. Repeat this until the first number becomes $0$. (I know how to increase and decrease a number in base $2$ using a Turing machine)
Problem:
(I) I don't know what to do if the input is like $111x001$. My algorithm is not general enough to solve this one too.
(II) It seems like the numbers should have the same number of digits. But I'm not sure of that. Can we design the machine without presuming this condition?
automata turing-machines
$endgroup$
add a comment |
$begingroup$
Question:
Design a Turing machine which computes the sum of two numbers in base $2$. For example, If the input is $110x1$, The machine should return $000x111$ (which means: $6+1=7$)
My try:
At each iteration, decrease the first number by $1$, and increase the second one by $1$. Repeat this until the first number becomes $0$. (I know how to increase and decrease a number in base $2$ using a Turing machine)
Problem:
(I) I don't know what to do if the input is like $111x001$. My algorithm is not general enough to solve this one too.
(II) It seems like the numbers should have the same number of digits. But I'm not sure of that. Can we design the machine without presuming this condition?
automata turing-machines
$endgroup$
add a comment |
$begingroup$
Question:
Design a Turing machine which computes the sum of two numbers in base $2$. For example, If the input is $110x1$, The machine should return $000x111$ (which means: $6+1=7$)
My try:
At each iteration, decrease the first number by $1$, and increase the second one by $1$. Repeat this until the first number becomes $0$. (I know how to increase and decrease a number in base $2$ using a Turing machine)
Problem:
(I) I don't know what to do if the input is like $111x001$. My algorithm is not general enough to solve this one too.
(II) It seems like the numbers should have the same number of digits. But I'm not sure of that. Can we design the machine without presuming this condition?
automata turing-machines
$endgroup$
Question:
Design a Turing machine which computes the sum of two numbers in base $2$. For example, If the input is $110x1$, The machine should return $000x111$ (which means: $6+1=7$)
My try:
At each iteration, decrease the first number by $1$, and increase the second one by $1$. Repeat this until the first number becomes $0$. (I know how to increase and decrease a number in base $2$ using a Turing machine)
Problem:
(I) I don't know what to do if the input is like $111x001$. My algorithm is not general enough to solve this one too.
(II) It seems like the numbers should have the same number of digits. But I'm not sure of that. Can we design the machine without presuming this condition?
automata turing-machines
automata turing-machines
asked Sep 30 '17 at 15:36
Arman MalekzadehArman Malekzadeh
1,7951028
1,7951028
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
I think your representation of $6+1$ as $110x1$ is quite reasonable. Thus, the two numbers do not have to contain the same number of digits, and no number will be preceded by any $0$'s.
Either way, you do need to solve the issue of having to (sometimes) shift the number on the right. This is necessary when the number on the right is all $1$'s, and you are trying to add one more to that.
To solve that, do the following: go to the rightmost digit of the right number. If you see a $1$ replace it with a $0$ and move left and repeat ... if you see an $x$, write a $1$ after the $x$ and add a $0$ at the end of the right number and you are done. If you see a zero change it into a $1$ and you are done.
$endgroup$
$begingroup$
I thought of the shift but I don't know how ...
$endgroup$
– Arman Malekzadeh
Oct 1 '17 at 6:21
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: "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
});
}
});
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%2fmath.stackexchange.com%2fquestions%2f2451687%2fdesign-a-turing-machine-which-computes-the-sum-of-two-numbers-in-base-2%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
$begingroup$
I think your representation of $6+1$ as $110x1$ is quite reasonable. Thus, the two numbers do not have to contain the same number of digits, and no number will be preceded by any $0$'s.
Either way, you do need to solve the issue of having to (sometimes) shift the number on the right. This is necessary when the number on the right is all $1$'s, and you are trying to add one more to that.
To solve that, do the following: go to the rightmost digit of the right number. If you see a $1$ replace it with a $0$ and move left and repeat ... if you see an $x$, write a $1$ after the $x$ and add a $0$ at the end of the right number and you are done. If you see a zero change it into a $1$ and you are done.
$endgroup$
$begingroup$
I thought of the shift but I don't know how ...
$endgroup$
– Arman Malekzadeh
Oct 1 '17 at 6:21
add a comment |
$begingroup$
I think your representation of $6+1$ as $110x1$ is quite reasonable. Thus, the two numbers do not have to contain the same number of digits, and no number will be preceded by any $0$'s.
Either way, you do need to solve the issue of having to (sometimes) shift the number on the right. This is necessary when the number on the right is all $1$'s, and you are trying to add one more to that.
To solve that, do the following: go to the rightmost digit of the right number. If you see a $1$ replace it with a $0$ and move left and repeat ... if you see an $x$, write a $1$ after the $x$ and add a $0$ at the end of the right number and you are done. If you see a zero change it into a $1$ and you are done.
$endgroup$
$begingroup$
I thought of the shift but I don't know how ...
$endgroup$
– Arman Malekzadeh
Oct 1 '17 at 6:21
add a comment |
$begingroup$
I think your representation of $6+1$ as $110x1$ is quite reasonable. Thus, the two numbers do not have to contain the same number of digits, and no number will be preceded by any $0$'s.
Either way, you do need to solve the issue of having to (sometimes) shift the number on the right. This is necessary when the number on the right is all $1$'s, and you are trying to add one more to that.
To solve that, do the following: go to the rightmost digit of the right number. If you see a $1$ replace it with a $0$ and move left and repeat ... if you see an $x$, write a $1$ after the $x$ and add a $0$ at the end of the right number and you are done. If you see a zero change it into a $1$ and you are done.
$endgroup$
I think your representation of $6+1$ as $110x1$ is quite reasonable. Thus, the two numbers do not have to contain the same number of digits, and no number will be preceded by any $0$'s.
Either way, you do need to solve the issue of having to (sometimes) shift the number on the right. This is necessary when the number on the right is all $1$'s, and you are trying to add one more to that.
To solve that, do the following: go to the rightmost digit of the right number. If you see a $1$ replace it with a $0$ and move left and repeat ... if you see an $x$, write a $1$ after the $x$ and add a $0$ at the end of the right number and you are done. If you see a zero change it into a $1$ and you are done.
edited Oct 1 '17 at 12:48
answered Sep 30 '17 at 21:45
Bram28Bram28
60.6k44590
60.6k44590
$begingroup$
I thought of the shift but I don't know how ...
$endgroup$
– Arman Malekzadeh
Oct 1 '17 at 6:21
add a comment |
$begingroup$
I thought of the shift but I don't know how ...
$endgroup$
– Arman Malekzadeh
Oct 1 '17 at 6:21
$begingroup$
I thought of the shift but I don't know how ...
$endgroup$
– Arman Malekzadeh
Oct 1 '17 at 6:21
$begingroup$
I thought of the shift but I don't know how ...
$endgroup$
– Arman Malekzadeh
Oct 1 '17 at 6:21
add a comment |
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.
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%2fmath.stackexchange.com%2fquestions%2f2451687%2fdesign-a-turing-machine-which-computes-the-sum-of-two-numbers-in-base-2%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