# Given a finite set of points of a mapping from $R^3 \rightarrow \{-1, 1\}$, where $R$ is a finite field, find a polynomial that matches the map.

For instance given the mapping in the table below for the field $\mathbb{Z}_5$, for a mapping $f:(\mathbb{Z}_5)^3 \rightarrow \{-1, 1\} \subset \mathbb{Z}_5$: $$\begin{vmatrix} 1 & 1 & 2 & \rightarrow & 1 \\ 2 & 1 & 3 & \rightarrow & -1 \\ 1 & 1 & 4 & \rightarrow & 1 \\ 3 & 2 & 3 & \rightarrow & -1 \\ \end{vmatrix}$$

where the rest of the domain can map to anything ("don't cares"), how do I calculate a polynomial that will achieve this?

Use for it: there exists a polynomial $f$ for each ordering $\lt$ on $\mathbb{Z}_5$ say for example $0 \lt 1 \lt 2 \lt \dots \lt 4$, such that if $a\lt b$, then $f(a,b,c)\ c a \lt f(a,b,c) \ c b$ for all $a,b,c \in \mathbb{Z}_5$

-

For the example you give, you have 4 pieces of information, so you need 4 unknown coefficients in your polynomial. It should work to assume $f(x,y,z)=ax+by+cz+d$ for some unknown $a,b,c,d$. From the data, you get the equations, \eqalign{a+b+2c+d&=1\cr2a+b+3c+d&=-1\cr a+b+4c+d&=1\cr3a+2b+3c+d&=-1\cr} Now solve by the usual methods for solving a system of linear equations.
In this example, equations 1 and 3 tell you $c=0$; then equations 1 and 3 are identical, so you can chuck out equation 3 and play with \eqalign{a+b+d&=1\cr2a+b+d&=-1\cr3a+2b+d&=-1\cr}
Now the first two equations tell you $a=-2$, so you are left with $b+d=3$, $2b+d=0$. This forces $b=2$, $d=1$, so $f(x,y,z)=3x+2y+1$.