When can one write $f(x,y)$ as $g(x)-g(y)$ for some $g(\cdot)$? Suppose I have a function $f:\mathbb{R}^n \times \mathbb{R}^n \rightarrow \mathbb{R}$. Under what conditions can I write $f(x,y) = g(x) - g(y)$ for some appropriate function $g:\mathbb{R}^n \rightarrow \mathbb{R}$? 
Necessary conditions are obviously that $f(x,x) = 0$ and that $f(x,y) = -f(y,x)$, but are these sufficient?
 A: Note that if $f(x,y)=g(x)-g(y)$, then $$f(x,0)-f(y,0)=g(x)-g(0)-g(y)+g(0)=f(x,y),$$ so without loss of generality, we can assume $g(x)=f(x,0)$.
Thus necessary and sufficient conditions are that $f(x,y)=f(x,0)-f(y,0)$.
The conditions you've given are not sufficient, consider $f(x,y)=(x-y)(x+y)^2$. $f(x,0)=x^3$, but $f(x,y)=x^3+x^2y-xy^2-y^3\ne x^3-y^3$.
A: (i) A highly symmetric criterion is the "cocycle condition"
$$f(x,y)+f(y,z)+f(z,x)\equiv0\ .\tag{1}$$
This is obviously necessary. Conversely: Letting $y=z=x$ in $(1)$ gives $f(x,x)\equiv0$. Then letting $z=x$ in $(1)$ gives $f(x,y)=-f(y,x)$. Defining $g(x):=f(x,0)$ we finally obtain 
$$f(x,y)=-f(y,0)+f(x,0)=g(x)-g(y)\ .$$
(ii) If $f\in C^2$ the following condition is necessary and sufficient:
$$f(x,y)=-f(y,x),\qquad f_{xy}(x,y)=0\qquad\forall x, \forall y\ .\tag{1}$$
Proof. The necessity is obvious. For the sufficiency assume that $(2)$ holds. Then 
$${\partial\over\partial y}\bigl(f_x(x,y)\bigr)\equiv0\ ,$$
hence $f_x(x,y)$ "depends only on $x$", meaning that there is a function $x\mapsto g(x)$ such that
$$f_x(x,y)\equiv g(x)\ .$$
This in turn implies that $f(x,y)=G(x)+C$, whereby $G$ is a primitive of $g$, and the constant of integration may depend on $y$. It follows that there is a function $y\mapsto H(y)$ such that
$$f(x,y)\equiv G(x)+H(y)\ .$$
The antisymmetry condition in $(2)$ then implies
$$G(x)+H(y)\equiv-\bigl(G(y)+H(x)\bigr)\ ,$$
and letting $x=y$ here shows that necessarily $H(x)=-G(x)$.$\quad\square$
