Solving equations with mod 1 numbers and multiple variables

130 Views Asked by At

I have two numbers (inputs): $ca$ and $cb$ and an expected result (output): $cc$. All of those are $mod 1$ numbers, usually represented as fractions like $\frac ab$ where $a$ and $b$ are integers, e.g. $\frac{5}{32}$. I can add, subtract, and multiply inputs, but cannot divide them. (I can only use integers for multiplication)

So, based on those limitations, I came up with a general equation as follows:
$(\frac{x}{y})\ + (n * ca) + (m * cb) = cc$

Again, $\frac xy$ is a $mod 1$ number and $n$ and $m$ are some integers. $cc$, the output, is again in the form of the fraction but it’s also a $mod 1$ number.

Now, in my specific case, at the high level, $mod 1$ values are divided into two categories:
if the $mod 1$ value is $< 0.5$, we categorize it as $1$;
when the value is $> 0.5$, we categorize it as $0$.

So, if $ca$ has the value $\frac 18$, it’s basically $0.125$ which is $< 0.5$ and is considered to be $1$. If $cb$ has the value of $-\frac 18 \equiv \frac 78$, it’s $0.875$ which is $> 0.5$ and is considered to be $0$.

Now, given values of $ca$ and $cb$, I know what output ($cc$) it should be giving, but only in terms of high-level categories - $0$ or $1$. Hence $cc$ could take any value from a certain range depending on if it is $0$ or $1$.

For example:
$ca$: $\frac 18$ (high-level category: $1$)
$cb$: $-\frac 18$ (high-level category: $0$)
Let’s say $cc$ should be categorized as $1$, so it could have any value $< 0.5$

One of the possible solutions is:
With $\frac xy = \frac 18$, $n = 1$ and $m = 1$, I will have $cc = \frac 18 = 0.125$ which is $< 0.5$

Since there are two high-level categories for numbers, there are 4 possible set of inputs with 4 outputs. For example, consider an OR gate taking $ca$ and $cb$ as input and $cc$ as output:

+--------------+-----------------------------------+  
|  High-level  |             Low-level             |  
+----+----+----+------+------+---------------------+  
| ca | cb | cc |  ca  |  cb  | cc = 1/8 + ca + cb  |  
+----+----+----+------+------+-------------+-------+  
| 0  | 0  | 0  | -1/8 | -1/8 | -1/8 ~= 7/8 | 0.875 |  
+----+----+----+------+------+-------------+-------+  
| 0  | 1  | 1  | -1/8 | 1/8  | 1/8         | 0.125 |  
+----+----+----+------+------+-------------+-------+  
| 1  | 0  | 1  | 1/8  | -1/8 | 1/8         | 0.125 |  
+----+----+----+------+------+-------------+-------+  
| 1  | 1  | 1  | 1/8  | 1/8  | 3/8         | 0.375 |  
+----+----+----+------+------+-------------+-------+  

Given this situation,
• what is the best way to determine the values of $\frac xy$, $n$, $m$, mathematically?
• Is there any other modulo arithmetic properties I could leverage on?
• Are there any different general equations I should be considering given that I could only add, subtract and multiply inputs?

As of now, I have tried the following approaches:
• picked some values to start with and tried to adjust them manually so as to get the possible solutions
• used programming to brute force and find some combinations of values
• applied the simple algebra using a particular (low-level) constant value for $cc$ instead of using the whole range e.g. using $cc = \frac 18$ instead of using range of $0$ to $0.5$

Any help is appreciated!