How to solve a modular arithmetic equation
A linear modular equation takes the form . It is solved by finding the greatest common divisor of and , reducing the equation, and multiplying by the modular inverse of the reduced coefficient.
The setup
Identify the coefficients , , and the modulus in the equation . Calculate the greatest common divisor (GCD) of and , denoted as .
The steps
- Verify a solution exists: must evenly divide . If it does not, there are no solutions. 2. Divide the entire equation, including the modulus, by to yield , where , , and . Note that . 3. Find the modular multiplicative inverse of modulo , denoted , using the Extended Euclidean Algorithm. 4. Multiply both sides of the reduced equation by to isolate , yielding . 5. Find all distinct solutions modulo the original by computing for integers .
Checking the result
Substitute the derived values of back into the original equation . Evaluate . The result must be an integer multiple of .
Common errors
Forgetting to divide the modulus by the GCD during the reduction step is the most frequent mistake. Another common error is attempting to find a modular inverse for modulo when , which is mathematically undefined.
Worked example
Solve .
Identify variables: , , . Calculate . Since divides , exactly solutions exist modulo . Divide the entire equation by to get . Find the modular inverse of modulo . We need a number such that . Testing values or using the Extended Euclidean Algorithm shows . The inverse is . Multiply both sides of the reduced equation by : . This simplifies to . Reduce modulo to get . Generate the solutions modulo the original modulus . . . The solutions are .
FAQ
Run your own problem
References: Kenneth H. Rosen, Discrete Mathematics and Its Applications · OpenStax, Contemporary Mathematics, Chapter 9: Number Theory
See also