1

Say for example I have the formula:

y = x%2 * x%3

or to put it in word notation:

y = mod(x,2) * mod(x,3)

Is there any way to combine them to leave only 1 modulo operator e.g.

y = mod(x,k)

(k will likely have to include an x term, or the x term may have to change to x^m, as any constant k gives a linear correlation for each line segment, whereas the initial formula gives a non-linear correlation.

Thanks

  • The short answer is no, this notation is not defined and cannot be usefully employed. The mathematical concept of congruence classes (explicitly developed by Gauss) is that of equivalence relations, not "modulo operators" as the Question presents them. – hardmath Jun 13 '16 at 12:34

2 Answers2

1

Analysis:

  • $x\equiv0\pmod6\implies(x\bmod2)\cdot(x\bmod3)=0\cdot0=0$
  • $x\equiv1\pmod6\implies(x\bmod2)\cdot(x\bmod3)=1\cdot1=1$
  • $x\equiv2\pmod6\implies(x\bmod2)\cdot(x\bmod3)=0\cdot2=0$
  • $x\equiv3\pmod6\implies(x\bmod2)\cdot(x\bmod3)=1\cdot0=0$
  • $x\equiv4\pmod6\implies(x\bmod2)\cdot(x\bmod3)=0\cdot1=0$
  • $x\equiv5\pmod6\implies(x\bmod2)\cdot(x\bmod3)=1\cdot2=2$

So a simple polynomial interpolation with n = x%6 yields:

$$\frac{7n^5}{120}-\frac{3n^4}{4}+\frac{85n^3}{24}-\frac{29n^2}{4}+\frac{27n}{5}$$

barak manos
  • 43,109
  • The given formula is not an identity for all values of x, it only works for the 6 integer values of x given. – Harrison Harris Jun 16 '16 at 14:21
  • @HarrisonHarris: The formula DOES work for every value of $x$. Note that it is using $n=x\bmod6$ (or in "your" language, n = x%6, which I have very explicitly stated in the answer). You have asked for a single usage of the modulo operator, and this formula indeed makes use of this operator only once. – barak manos Jun 16 '16 at 14:29
1

After looking around and playing with some numbers I found that:

x (mod n) ≡ -(n/pi)*arctan(cot(xpi/n))+n/2

Note: x%n ≡ mod(x,n) ≡ x (mod n)

thus

x (mod n) * x (mod m) = (-(n/pi)*arctan(cot(xpi/n))+n/2) * (-(m/pi)*arctan(cot(xpi/m))+m/2)

and so the initial question's example can be substituted in to form the equation

y = (-(2/pi)*arctan(cot(xpi/2))+1) * (-(3/pi)*arctan(cot(xpi/3))+1.5)