Modular Fraction Arithmetic

Hint $\,\ {\rm mod}\ 7\!:\,\ \color{#c00}{5\equiv -2}\,\Rightarrow\, \dfrac{3\cdot 2}{\color{#c00}5}\equiv \dfrac{3\cdot 2}{\color{#c00}{\,-2}}\equiv -3\equiv 4 $

Beware $ $ While, as usual, fractions may serve to greatly simplify arithmetic, their modular analog increases the probability of division exceptions, since the modular analog of "you can't (uniquely) divide by $0$" is "you can't (uniquely) divide by a zero-divisor", i.e. divisors and denominators $d$ must be coprime to the modulus $m$ ($\!\iff\! d$ is invertible mod $m)$ for the quotient to be well-defined. Then the fraction $\,c/d \equiv cd^{-1}$ denotes the unique solution of $\, dx\equiv c\,$ and the common grade-school fraction arithmetic holds true for all such fraction writable with denominator coprime to the modulus. For example, the addition law $\,a/b+c/d = (ad+bc)/(bd)\,$ holds because $$\,(ad+bc)\color{#0a0}{(bd)^{-1}}\equiv ad\,\color{#0a0}{d^{-1}b^{-1}}+ \color{#0a0}{d^{-1}b^{-1}}bc\equiv ab^{-1}+d^{-1}b $$

Recall that by Euclid: $\,b,d\,$ coprime to $m$ $\iff$ $bd$ coprime to $m,\,$ indeed $\,\color{#0a0}{(bd)^{-1}\! \equiv d^{-1}b^{-1}}$ so the fractions in the addition rule are all well-defined, i.e. have denominators coprime to $m.\,$ It is essential to restrict modular fractions to such fractions else one can deduce contradictions such as the following: $\,{\rm mod}\ 10\!:\ 0\equiv 0/2\equiv 10/2\equiv 5.\,$ Let's examine more closely what goes wrong here.

Generally a fraction $\,x \equiv a/b\,$ with noninvertible denominator (not coprime to modulus) is not well-defined because the equation $\,b x \equiv a\,$ does not have a unique solution, i.e. there may be no solutions, or there may be more than one solution. For example, mod $\rm 10\!:$ $\rm\:4\,x\equiv 2\:$ has solutions $\rm\:x\equiv 3,8,\:$ so the "fraction" $\rm\:x \equiv 2/4\pmod{\!10}\,$ cannot designate a unique solution of $\,4x\equiv 2.\,$ Indeed, the solution is $\rm\:x\equiv 1/2\equiv 3\pmod 5,\,$ which requires canceling $\,2\,$ from the modulus too, because $\rm\:10\:|\:4x-2\iff5\:|\:2x-1.\,$ An unsolvable example is the fraction $\,x \equiv 1/4,\,$ since $\,10\mid 4x-1\,\Rightarrow 10n = 4x-1\,$ $\Rightarrow$ $\,4x-10 = 1\,$ is even, contradiction. See here for further discussion, including use of multi-valued modular fractions in the Extended Euclidean Algorithm.

Ring-theoretically, this may be viewed as a generalization of the fact that division by zero is not well-defined, i.e. division by a $\,\rm\color{#c00}{zero\!-\!divisor}\,$ is not well-defined (in a nontrivial ring), since if $\,\color{#c00}{bc=0,\ b,c\ne 0}\,$ then $\,bx = a\,\Rightarrow\,\color{#c00}b(\color{#c00}c\!+\!x) = a\,$ so if a solution $\,x\,$ exists then it is not unique.

Generally the grade-school rules of fraction arithmetic apply universally (i.e. in all rings) where the denominators are all invertible, e.g. $\, 1/2 - 1/3 = 1/6\,$ can be interpreted in any ring where $\,6\,$ is invertible, e.g. in the integers $\bmod n$ for all $\,n\,$ coprime to $\,6,\,$ e.g. $\bmod 5\,$ it is $\,3-2\equiv 1,\,$ and $\bmod 11\,$ it is $\,6 - 4 \equiv 2.\,$ This fundamental universal property of fractions will be clarified conceptually in university algebra as the universal properties of fractions rings (and localizations).


We want to find $(3)(2)(x)\pmod{7}$, where $x$ is the inverse of $5$ modulo $7$, that is, where $5x\pmod 7=1$.

There are general procedures for finding inverses modulo $m$, but $7$ is a very small number, so we can do it efficiently by trial and error. Note that $(5)(3)$ has remainder $1$ on division by $7$. So $x\pmod 7=3$.

Thus we want to compute $(3)(2)(3)\pmod 7$. This is $4$.