0
$\begingroup$

Let $p$ be a prime and let all variables be in $\Bbb{Z}_p$.

Then you can write the result of

if(i > 0)
   k = (a + b)c;

(C code)

as a polynomial $k := i^{p-1} (a+b)c + (1 - i^{p-1}) k$ (notice $:=$ and not $=$). But what about

if (i > j)
    k = (a + b)c; 

?

If you try converting $i \gt j$ when your ordering on $\Bbb{Z}_p$ is $0, 1 \lt 2 \lt \dots \lt p-1 $, then we have that $i - j \gt 0 \not\implies i \gt j$, but the converse holds.

Then how can we construct a polynomial $F$ in $i,j,k,a,b,c$ such that $k := F(i,j,k,a,b,c)$ yields the same computation?

I bet there is one!!!

$\endgroup$

1 Answer 1

1
$\begingroup$

Any function $f$ from $\Bbb Z_p$ to $\Bbb Z_p$ can be written as a polynomial: by Fermat's little theorem, $$ f(i) = \sum_{t=0}^{p-1} f(t)\big( 1-(i-t)^{p-1} \big). $$ In your case, you want the answer to be $k$ when $0\le i\le j$ and $(a+b)c$ when $j<i\le p+1$; so the appropriate polynomial is $$ f(i) = k \sum_{t=0}^{j} \big( 1-(i-t)^{p-1} \big) + (a+b)c \sum_{t=j+1}^{p-1} \big( 1-(i-t)^{p-1} \big). $$ You can look for simpler expressions for this polynomial if you want; it's the unique polynomial of degree at most $p-1$ that does the trick.

$\endgroup$
5
  • $\begingroup$ Your summations don't make any sense (no use of $t$), and why $a$? That's just some arb. value in some data memory slot. $\endgroup$ Apr 16, 2014 at 8:37
  • $\begingroup$ Could you provide a link to an article on FLT? I'm not finding anything related to this. $\endgroup$ Apr 16, 2014 at 8:44
  • $\begingroup$ I think you mean $f(i) = \sum_{t=0}^{p-1} f(t) (1 - (i-t)^{p-1})$. $\endgroup$ Apr 16, 2014 at 8:47
  • $\begingroup$ typos fixed (changed most $a$s to $t$s) $\endgroup$ Apr 16, 2014 at 16:35
  • $\begingroup$ not surprisingly, a link is en.wikipedia.org/wiki/Fermat's_little_theorem $\endgroup$ Apr 16, 2014 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .