// Numbas version: finer_feedback_settings {"name": "Solve three congruences using Chinese Remainder Theorem", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "variables": {"sb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(12..20)", "description": "", "name": "sb"}, "rb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2..sb-1)", "description": "", "name": "rb"}, "pans": {"templateType": "anything", "group": "Ungrouped variables", "definition": "mod(ra*ea+rb*eb+rc*ec,n)", "description": "", "name": "pans"}, "sc": {"templateType": "anything", "group": "Ungrouped variables", "definition": "chcop3(sa,sb,sb,2,sa-1)", "description": "", "name": "sc"}, "nb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sa*sc", "description": "", "name": "nb"}, "rc": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..sc-1)", "description": "", "name": "rc"}, "ra": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(5..sa-1)", "description": "", "name": "ra"}, "na": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sb*sc", "description": "", "name": "na"}, "sa": {"templateType": "anything", "group": "Ungrouped variables", "definition": "chcop(sb,sb,8,sb-1)", "description": "", "name": "sa"}, "ans": {"templateType": "anything", "group": "Ungrouped variables", "definition": "pans", "description": "", "name": "ans"}, "n": {"templateType": "anything", "group": "Ungrouped variables", "definition": "na*sa", "description": "", "name": "n"}, "eb": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd2(sb,nb)*nb", "description": "", "name": "eb"}, "nc": {"templateType": "anything", "group": "Ungrouped variables", "definition": "sa*sb", "description": "", "name": "nc"}, "ec": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd2(sc,nc)*nc", "description": "", "name": "ec"}, "ea": {"templateType": "anything", "group": "Ungrouped variables", "definition": "extendedgcd2(sa,na)*na", "description": "", "name": "ea"}}, "ungrouped_variables": ["pans", "na", "nb", "nc", "ea", "rc", "ec", "n", "ra", "rb", "ans", "sc", "sb", "sa", "eb"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "name": "Solve three congruences using Chinese Remainder Theorem", "functions": {"mdescext1gcd": {"type": "string", "language": "jme", "definition": "\n \n \n if(a
$\\var{a}$ | $\\var{b}$ | $\\simplify[std]{{c1}a+{c2}b}$ | $\\simplify[std]{{d1}a+{d2}b}$ |
Solve the following simultaneous congruences:
\\[\\begin{eqnarray*}\n \n x\\;&\\equiv&\\;\\var{ra}\\;&\\mod&\\;\\var{sa}\\\\\n \n \\\\\n \n x\\;&\\equiv&\\;\\var{rb}\\;&\\mod&\\;\\var{sb}\\\\\n \n \\\\\n \n x\\;&\\equiv&\\;\\var{rc}\\;&\\mod&\\;\\var{sc}\n \n \\end{eqnarray*}\n \n \\]
$x=\\;\\;$ [[0]]
Your value of $x$ should satisfy $0 \\leq x \\lt \\var{n}$
\n \n \n \nSteps gives you information on the Chinese Remainder Theorem and the steps you need to take to solve the congruences.
\n \n ", "steps": [{"type": "information", "prompt": "\n \n \nGiven the simultaneous congruences:
\\[\\begin{eqnarray*}\n \n x\\;&\\equiv&\\;a_1\\;&\\mod&\\;n_1\\\\\n \n \\\\\n \n x\\;&\\equiv&\\;a_2\\;&\\mod&\\;n_2\\\\\n \n \\\\\n \n x\\;&\\equiv&\\;a_3\\;&\\mod&\\;n_3\n \n \\end{eqnarray*}\n \n \\]
where $\\operatorname{gcd}(n_1,n_2,n_3)=1$ we first observe that:
$N_1=n_2 n_3$ and $n_1$ are coprime, $N_2=n_1 n_3$ and $n_2$ are coprime, $N_3=n_1 n_2$ and $n_3$ are coprime.
\n \n \n \nSo there is an inverse $x_1$ of $N_1$ in $Z_{n_1}$ such that $N_1x_1\\equiv 1 \\;\\mod\\;n_1$. Let $E_1=N_1x_1$, and similarly:
\n \n \n \nThere is an inverse $x_2$ of $N_2$ in $Z_{n_2}$ such that $N_2x_2\\equiv 1 \\;\\mod\\;n_2$. Let $E_2=N_2x_2$.
\n \n \n \nThere is an inverse $x_3$ of $N_3$ in $Z_{n_3}$ such that $N_3x_3\\equiv 1 \\;\\mod\\;n_3$. Let $E_3=N_3x_3$.
\n \n \n \nThen $x=a_1 E_1+a_2 E_2 + a_3 E_3 \\;\\mod\\;n_1n_2n_3$ is a solution to the simultaneous congruences.
\n \n \n \nSee your notes for a full explanation.
\n \n ", "showCorrectAnswer": true, "scripts": {}, "marks": 0}], "showCorrectAnswer": true, "marks": 0}], "statement": "", "tags": ["checked2015", "Chinese Remainder Theorem", "congruences", "coprime", "euclidean algorithm", "gcd", "MAS3214", "Modular arithmetic", "modular arithmetic", "simultaneous congruences", "solving equations", "Solving equations"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "Solving three simultaneous congruences using the Chinese Remainder Theorem:
\n\\[\\begin{eqnarray*} x\\;&\\equiv&\\;b_1\\;&\\mod&\\;n_1\\\\ x\\;&\\equiv&\\;b_2\\;&\\mod&\\;n_2\\\\x\\;&\\equiv&\\;b_3\\;&\\mod&\\;n_3 \\end{eqnarray*} \\] where $\\operatorname{gcd}(n_1,n_2,n_3)=1$
"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "\n \n \nUsing the notation in Steps we have:
\n \n \n \n1) $n_1=\\var{sa},\\;n_2=\\var{sb},\\;n_3=\\var{sc}$ are coprime as they have no factors in common.
$n=n_1n_2n_3=\\var{n}$
2)
$N_1=\\var{sb}\\times \\var{sc}=\\var{na},\\;\tN_2=\\var{sa}\\times \\var{sc}=\\var{nb},\\;N_3=\\var{sa}\\times \\var{sb}=\\var{nc}$
3)
\n \n \n \nUsing the Extended Euclidean Algorithm for $N_1=\\var{na}$ and $n_1=\\var{sa}$ we find:
\\[\\simplify[std]{{extendedgcd2(sa,na)}* {na} +{extendedgcd1(sa,na)}*{sa}=1} \\Rightarrow E_1=\\var{extendedgcd2(sa,na)}\\times \\var{na}=\\var{ea}\\]
Using the Extended Euclidean Algorithm for $N_2=\\var{nb}$ and $n_2=\\var{sb}$ we find:
\\[\\simplify[std]{{extendedgcd2(sb,nb)}* {nb} +{extendedgcd1(sb,nb)}*{sb}=1} \\Rightarrow E_2=\\var{extendedgcd2(sb,nb)}\\times \\var{nb}=\\var{eb}\\]
Using the Extended Euclidean Algorithm for $N_3=\\var{nc}$ and $n_3=\\var{sc}$ we find:
\\[\\simplify[std]{{extendedgcd2(sc,nc)}* {nc} +{extendedgcd1(sc,nc)}*{sc}=1} \\Rightarrow E_3=\\var{extendedgcd2(sc,nc)}\\times \\var{nc}=\\var{ec}\\]\t
4)
Then the general solution is:\\[\\begin{eqnarray*}\n \n x&=& a_1 E_1+a_2 E_2+a_3 E_3\\;\\mod\\;n\\\\\n \n &=& \\simplify[std]{{ra}*{ea}+{rb}*{eb}+{rc}*{ec}}\\;\\mod\\;\\var{n}\\\\\n \n &=&\\var{ra*ea+rb*eb+rc*ec}\\;\\mod\\;\\var{n}\\\\\n \n &=& \\var{ans}\\;\\mod\\;\\var{n}\n \n \\end{eqnarray*}\n \n \\]