0
$\begingroup$

Let $m \in\mathbb N, m > 2$ and $S_m = \{0, 1,4\pmod{m},...,(m-1)^2 \pmod{m}\}.$

We are given a function $f_m(x) = 9x^2 + 18ax + 9a^2 - b \pmod{m}$ where $a, b \in\mathbb N$.

Can we find every $x \in\mathbb N$ such that $f_m(x) \in S_m$ efficiently for large $m$?

If not, can we get a number of these valid $x$ somehow?


I know two ways of accomplishing this, but these are both inefficient for large $m$:

  1. Compute and store $S_m$ and then search for $f_m(1), f_m(2), ... , f_m(m)$ one by one.
    It's fast enough, but storing $S_m$ becomes a problem if $m$ is quite a large number.

  2. For each $x = 1, 2, ... m$ iterate over $S_m$ and test if $f_m(x) = s_j \in S_m$ for some $j$.
    We avoid storing $S_m$ here but this is not that fast since we need to iterate $m$ times.

1 Answers 1

0

There exists a technique called "inverse image", which can solve this problem without the issues that you listed. The basis for inverse image is simply "function composition", but to solve this problem, it needs to be constructed in certain way.

First represent the set $S_m$ as a function $g : [0..m] \rightarrow 2$, which is a test-function for deciding if $x \in S_m$. The $g$ function is called characteristic function for set $S_m$. Then use the given $f_m(x) = 9x^2+18ax+9a^2-b \pmod{m}$, we note that there's specification $f_m : [0..m] \rightarrow [0..m]$. The two available functions are compatible for function composition, we can do $g(f_m(x))$ to find a test function for whether $f_m(x) \in S_m$. This would require iterating the set $[0..m]$ exactly once to test $g(f_m(x))=true$.

Note (added afterwards): there's another minor detail that might be important. The $f_m(x)$ has something called currying in it. It deals with how to handle the $a$ and $b$ constants. Instead of marking $f_m :: (x,a,b) \rightarrow (f_m(x,a,b))$, you can use $f_m :: (a,b) \rightarrow (x) \rightarrow (f_m(x,a,b))$, and this is necessary step in the analysis above, since it allows us to mark $f_m : [0..m] \rightarrow [0..m]$ which is needed in it. Real problem is that inverse image gets very difficult if you have to deal with products like $(x,a,b)$ instead of simply $(x)$.

  • 0
    Thank you very much! It helped a lot!2017-01-30