0

Finding the inversion of an easier function is simple. The way I find the way of doing this by flipping the x and the y in the equation and solving for y. But I am stuck on a certain part.

y = (6*x) mod 13

x = (6*y) mod 13

2 Answers2

1

The inverse of that function will only be defined for values between 0 and 12. Also for every possible y (in between 0 and 12) there will be an infinite number of possible x that fulfill the equation.

Let's try to solve for y

x = (6*y) mod 13
x + n*13 = (6*y)
y = (x + n*13)/6 | x ∈ {0,…,12}, n ∈ ℕ

where n is an unknown positive integer that could have any arbitrary value

Tesseract
  • 8,049
  • 2
  • 20
  • 37
0

To compute the inverse of y = 6 * x mod 13, I am first going to solve for x and replace x with y (and vice versa) later.

Since y = 6 * x mod 13, x = 6^(-1) * y mod 13, where 6^(-1) is the modular multiplicative inverse of 6 for the modulus 13. Your task now becomes finding 6^(-1) mod 13. In other words, you have to find m such that 6 * m = 1 mod 13.

Note that 6 * 2 = 12 = -1 mod 13. Squaring both sides, 6 * 6 * 2 * 2 = 1 mod 13, or 6 * 24 = 1 mod 13. Since 24 = 11 mod 13, therefore 6 * 11 = 1 mod 13 and 11 = 6^(-1) mod 13.

Thus, our equation for x now becomes x = 11 * y mod 13. Replacing y -> x and x -> y, the inverse of the given function is given by y = 11 * x mod 13.

This nifty Python script can be used to test the validity of our result:

def f(x):
    return (6 * x) % 13

def f_inv(x):
    return (11 * x) % 13

for x in range(13):
    print x, f_inv(f(x)), x == f_inv(f(x))

When run, it gives the following output:

0 0 True
1 1 True
2 2 True
3 3 True
4 4 True
5 5 True
6 6 True
7 7 True
8 8 True
9 9 True
10 10 True
11 11 True
12 12 True

Thus validating the premise that f^(-1)(x) = 11 * x mod 13 satisfies the required premise that f^(-1)(f(x)) = x.

EvilTak
  • 7,091
  • 27
  • 36
  • Similarly for another question I'm trying your methods and found it is impossible to find the inversion of f(x) = 6x mod 15. Why is this? – Sayan Chakraborti May 06 '18 at 05:52
  • Because `6^(-1) mod 15` does not exist. For `a^(-1) mod m` to exist, `gcd(a, m) = 1`, but `gcd(6, 15) = 3 != 1`. – EvilTak May 06 '18 at 05:59
  • But of course that only means there are no integer solutions. One possible inversion for `y = 6x mod 15` would be `y = x/6 `. Another solution is `y = (x + 15)/6` and so on. But if you put in an integer between 0 and 14 for x, the result will never be an integer. – Tesseract May 06 '18 at 06:08