How to solve system of linear congruences with the same modulo?
I have to write program which is solving linear congruences withe the same modulo. I have system of congruences like that(only 2 unknowns x and y):
$$begin{cases}
a_1x+b_1y equiv c_1pmod n \
a_2x+b_2y equiv c_2pmod n \
end{cases}
$$
I'm using Cramer's rule now and it works when the modulus is prime, but when modulus is not prime, my program behaves incorrectly.
modular-arithmetic matrix-congruences
add a comment |
I have to write program which is solving linear congruences withe the same modulo. I have system of congruences like that(only 2 unknowns x and y):
$$begin{cases}
a_1x+b_1y equiv c_1pmod n \
a_2x+b_2y equiv c_2pmod n \
end{cases}
$$
I'm using Cramer's rule now and it works when the modulus is prime, but when modulus is not prime, my program behaves incorrectly.
modular-arithmetic matrix-congruences
Search on Hermite(-Smith) normal form for the general ideas.
– Bill Dubuque
Nov 22 '18 at 19:20
add a comment |
I have to write program which is solving linear congruences withe the same modulo. I have system of congruences like that(only 2 unknowns x and y):
$$begin{cases}
a_1x+b_1y equiv c_1pmod n \
a_2x+b_2y equiv c_2pmod n \
end{cases}
$$
I'm using Cramer's rule now and it works when the modulus is prime, but when modulus is not prime, my program behaves incorrectly.
modular-arithmetic matrix-congruences
I have to write program which is solving linear congruences withe the same modulo. I have system of congruences like that(only 2 unknowns x and y):
$$begin{cases}
a_1x+b_1y equiv c_1pmod n \
a_2x+b_2y equiv c_2pmod n \
end{cases}
$$
I'm using Cramer's rule now and it works when the modulus is prime, but when modulus is not prime, my program behaves incorrectly.
modular-arithmetic matrix-congruences
modular-arithmetic matrix-congruences
asked Nov 22 '18 at 12:13
Jacek Kurek
1
1
Search on Hermite(-Smith) normal form for the general ideas.
– Bill Dubuque
Nov 22 '18 at 19:20
add a comment |
Search on Hermite(-Smith) normal form for the general ideas.
– Bill Dubuque
Nov 22 '18 at 19:20
Search on Hermite(-Smith) normal form for the general ideas.
– Bill Dubuque
Nov 22 '18 at 19:20
Search on Hermite(-Smith) normal form for the general ideas.
– Bill Dubuque
Nov 22 '18 at 19:20
add a comment |
1 Answer
1
active
oldest
votes
This is not as simple as it may look. For example, there may be multiple solutions for even a single equation ($2xequiv 0 pmod 4$ has 2 solutions$pmod 4$, for example). This breaks the nice theory one knows from the reals. That it works for primes $p$ is due to the fact that the the numbers you are working with also form a field, just like the reals.
It seems you have to go the hard way and
- factor $n$ into prime powers: $n=p_1^{alpha_1}p_2^{alpha_2}ldots$,
- you need to solve the problem independently for each prime power $p_i^{alpha_i}$ (see next steps) and at the end combine the results using the Chineese reminder theorem.
- for each prime power $p_i^{alpha_i}$, first solve it$pmod {p_i}$. This will work with what you have it seems. This gives you for all variables either a result$pmod {p_i}$ or no information (if the coefficinet before the variable was a multiple of $p_i$ in all equations). Introduce new variables ($x_i'$) for the ones you got results for ($x_i$) in the form of $x_i=p_ix_i' + r_i$.
- reformulate your equations using the new $x_i'$ variables and the older ones that did not yield information in step 3. You will see that now all coefficients before variables contain the factor $p_i$. Now it's time to consider$pmod {p_i^2}$
- You can divide all your equations by $p_i$. If the constant term is not divisible by $p_i$, the system has no solution. You must also divide the modulus by $p_i$, this is an equivalent operation! ($paequiv pb pmod {p^2}$ means the same as $aequiv b pmod {p}$.
- Now you are back where you started, you can solve the system with (possibly) some new variables $pmod {p}$ and continue as in steps 3-5. Each time you get information about your variables modulo a higer power of $p_i$, and at the end you get them for what you need, $pmod {p_i^{alpha_i}}$
Again, this is probably at least a few days work, not a few hours. Maybe somebody else has a better idea, though.
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%2f3009056%2fhow-to-solve-system-of-linear-congruences-with-the-same-modulo%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
This is not as simple as it may look. For example, there may be multiple solutions for even a single equation ($2xequiv 0 pmod 4$ has 2 solutions$pmod 4$, for example). This breaks the nice theory one knows from the reals. That it works for primes $p$ is due to the fact that the the numbers you are working with also form a field, just like the reals.
It seems you have to go the hard way and
- factor $n$ into prime powers: $n=p_1^{alpha_1}p_2^{alpha_2}ldots$,
- you need to solve the problem independently for each prime power $p_i^{alpha_i}$ (see next steps) and at the end combine the results using the Chineese reminder theorem.
- for each prime power $p_i^{alpha_i}$, first solve it$pmod {p_i}$. This will work with what you have it seems. This gives you for all variables either a result$pmod {p_i}$ or no information (if the coefficinet before the variable was a multiple of $p_i$ in all equations). Introduce new variables ($x_i'$) for the ones you got results for ($x_i$) in the form of $x_i=p_ix_i' + r_i$.
- reformulate your equations using the new $x_i'$ variables and the older ones that did not yield information in step 3. You will see that now all coefficients before variables contain the factor $p_i$. Now it's time to consider$pmod {p_i^2}$
- You can divide all your equations by $p_i$. If the constant term is not divisible by $p_i$, the system has no solution. You must also divide the modulus by $p_i$, this is an equivalent operation! ($paequiv pb pmod {p^2}$ means the same as $aequiv b pmod {p}$.
- Now you are back where you started, you can solve the system with (possibly) some new variables $pmod {p}$ and continue as in steps 3-5. Each time you get information about your variables modulo a higer power of $p_i$, and at the end you get them for what you need, $pmod {p_i^{alpha_i}}$
Again, this is probably at least a few days work, not a few hours. Maybe somebody else has a better idea, though.
add a comment |
This is not as simple as it may look. For example, there may be multiple solutions for even a single equation ($2xequiv 0 pmod 4$ has 2 solutions$pmod 4$, for example). This breaks the nice theory one knows from the reals. That it works for primes $p$ is due to the fact that the the numbers you are working with also form a field, just like the reals.
It seems you have to go the hard way and
- factor $n$ into prime powers: $n=p_1^{alpha_1}p_2^{alpha_2}ldots$,
- you need to solve the problem independently for each prime power $p_i^{alpha_i}$ (see next steps) and at the end combine the results using the Chineese reminder theorem.
- for each prime power $p_i^{alpha_i}$, first solve it$pmod {p_i}$. This will work with what you have it seems. This gives you for all variables either a result$pmod {p_i}$ or no information (if the coefficinet before the variable was a multiple of $p_i$ in all equations). Introduce new variables ($x_i'$) for the ones you got results for ($x_i$) in the form of $x_i=p_ix_i' + r_i$.
- reformulate your equations using the new $x_i'$ variables and the older ones that did not yield information in step 3. You will see that now all coefficients before variables contain the factor $p_i$. Now it's time to consider$pmod {p_i^2}$
- You can divide all your equations by $p_i$. If the constant term is not divisible by $p_i$, the system has no solution. You must also divide the modulus by $p_i$, this is an equivalent operation! ($paequiv pb pmod {p^2}$ means the same as $aequiv b pmod {p}$.
- Now you are back where you started, you can solve the system with (possibly) some new variables $pmod {p}$ and continue as in steps 3-5. Each time you get information about your variables modulo a higer power of $p_i$, and at the end you get them for what you need, $pmod {p_i^{alpha_i}}$
Again, this is probably at least a few days work, not a few hours. Maybe somebody else has a better idea, though.
add a comment |
This is not as simple as it may look. For example, there may be multiple solutions for even a single equation ($2xequiv 0 pmod 4$ has 2 solutions$pmod 4$, for example). This breaks the nice theory one knows from the reals. That it works for primes $p$ is due to the fact that the the numbers you are working with also form a field, just like the reals.
It seems you have to go the hard way and
- factor $n$ into prime powers: $n=p_1^{alpha_1}p_2^{alpha_2}ldots$,
- you need to solve the problem independently for each prime power $p_i^{alpha_i}$ (see next steps) and at the end combine the results using the Chineese reminder theorem.
- for each prime power $p_i^{alpha_i}$, first solve it$pmod {p_i}$. This will work with what you have it seems. This gives you for all variables either a result$pmod {p_i}$ or no information (if the coefficinet before the variable was a multiple of $p_i$ in all equations). Introduce new variables ($x_i'$) for the ones you got results for ($x_i$) in the form of $x_i=p_ix_i' + r_i$.
- reformulate your equations using the new $x_i'$ variables and the older ones that did not yield information in step 3. You will see that now all coefficients before variables contain the factor $p_i$. Now it's time to consider$pmod {p_i^2}$
- You can divide all your equations by $p_i$. If the constant term is not divisible by $p_i$, the system has no solution. You must also divide the modulus by $p_i$, this is an equivalent operation! ($paequiv pb pmod {p^2}$ means the same as $aequiv b pmod {p}$.
- Now you are back where you started, you can solve the system with (possibly) some new variables $pmod {p}$ and continue as in steps 3-5. Each time you get information about your variables modulo a higer power of $p_i$, and at the end you get them for what you need, $pmod {p_i^{alpha_i}}$
Again, this is probably at least a few days work, not a few hours. Maybe somebody else has a better idea, though.
This is not as simple as it may look. For example, there may be multiple solutions for even a single equation ($2xequiv 0 pmod 4$ has 2 solutions$pmod 4$, for example). This breaks the nice theory one knows from the reals. That it works for primes $p$ is due to the fact that the the numbers you are working with also form a field, just like the reals.
It seems you have to go the hard way and
- factor $n$ into prime powers: $n=p_1^{alpha_1}p_2^{alpha_2}ldots$,
- you need to solve the problem independently for each prime power $p_i^{alpha_i}$ (see next steps) and at the end combine the results using the Chineese reminder theorem.
- for each prime power $p_i^{alpha_i}$, first solve it$pmod {p_i}$. This will work with what you have it seems. This gives you for all variables either a result$pmod {p_i}$ or no information (if the coefficinet before the variable was a multiple of $p_i$ in all equations). Introduce new variables ($x_i'$) for the ones you got results for ($x_i$) in the form of $x_i=p_ix_i' + r_i$.
- reformulate your equations using the new $x_i'$ variables and the older ones that did not yield information in step 3. You will see that now all coefficients before variables contain the factor $p_i$. Now it's time to consider$pmod {p_i^2}$
- You can divide all your equations by $p_i$. If the constant term is not divisible by $p_i$, the system has no solution. You must also divide the modulus by $p_i$, this is an equivalent operation! ($paequiv pb pmod {p^2}$ means the same as $aequiv b pmod {p}$.
- Now you are back where you started, you can solve the system with (possibly) some new variables $pmod {p}$ and continue as in steps 3-5. Each time you get information about your variables modulo a higer power of $p_i$, and at the end you get them for what you need, $pmod {p_i^{alpha_i}}$
Again, this is probably at least a few days work, not a few hours. Maybe somebody else has a better idea, though.
answered Nov 22 '18 at 15:27
Ingix
3,344145
3,344145
add a comment |
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.
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.
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%2f3009056%2fhow-to-solve-system-of-linear-congruences-with-the-same-modulo%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
Search on Hermite(-Smith) normal form for the general ideas.
– Bill Dubuque
Nov 22 '18 at 19:20