Modular Division

 


Modular Division

Modular division is a mathematical operation that involves dividing two integers under a specified modulus. It’s particularly useful in number theory, cryptography, and computer science. The goal is to find the remainder of the division (modulo) of one number by another.

Definition

Given three positive integers: $a, b$, and $m$, we want to compute $a/b$ under modulo $m$. In other words, we seek to find a number $c$ such that:

$(b \cdot c) \mod m = a \mod m $

When Is Modular Division Defined?
1.Inverse Existence:
  • Modular division is defined when the inverse of the divisor exists.
  • The inverse of an integer $x$ is another integer $y$ such that $(x \cdot y) \mod m = 1$, where $m$ is the modulus.
  • In other words, $x$ and $m$ must be co-prime (i.e., their greatest common divisor is 1).

2.Finding the Inverse:

  • To compute modular division, we need to find the modular multiplicative inverse of $b$ under modulus $m$.
  • If the inverse doesn’t exist (i.e., GCD(b, m) is not 1), then modular division is not defined.

How to Find Modular Division?

Check for Inverse Existence:
First, check if the inverse of  $b$ under modulus $m$ exists.
If the inverse doesn’t exist (i.e., GCD(b, m) is not 1), then print “Division not defined.”

Compute the Result:
If the inverse exists, compute the result as: 
$\text{Result of division} = ( \text{inverse} \cdot a ) \mod m $

Example:
Let $a=8 ,b=3$ and $m=5$. Compute $(\frac{8}{3} \mod 5)$

Inverse Existence:
The GCD of 3 and 5 is 1, so the inverse exists.

Compute the Result:
The inverse of 3 under modulo 5 is 2 (since $(3 \cdot 2 \mod 5 = 1)$).
The result of division is $$(8 \cdot 2) \mod 5 = 1$$.

Therefore, the solution is $\frac{8}{3} \equiv 1 \mod 5$

Remember that modular division behaves differently from ordinary division
Note: Inverse can be computed easily by using the Extended Euclid Algorithm

Example: University Question
Solve the congruence $17x \equiv 3( mod 29)$

$x=17^{-1}.3 \pmod{29}$
$x=12.3 \pmod{29}$
$x=36 \pmod{29}$
$x=7$

Python Code 
from sympy import mod_inverse
print(mod_inverse(17,29))
12

Comments

Popular posts from this blog

Number Theory CST 292 KTU IV Semester Honors Course Notes Dr Binu V P 9847390760

Sum of Squares

Quadratic Residues-Legendre and Jacobi Symbols