# Functions where the sum of its partial derivatives is zero

I am currently studying Calculus of Variations and have come up with this problem.

What functions $$f:\Bbb R^n\to\Bbb R$$ satisfy $$\sum\limits_i\frac{\partial f}{\partial x_i}=0\tag1$$ with $$f$$ of differentiability class $$C^\infty$$?

It can be shown that if the total derivative is zero; that is, if $$\frac{dF}{dt}=\sum_i\frac{\partial f}{\partial x_i}\cdot\frac{dx_i}{dt}=0$$ with $$F(t)=f(x_1(t),\cdots,x_n(t))$$, then $$f$$ is constant. However, I cannot see how the same approach can be used for $$(1)$$.

The trivial function $$f(x)=c$$ satisfies $$(1)$$. For even $$n>1$$, a non-trivial solution is the function $$f(x_1,\cdots,x_n)=\exp\left(\sum_i(-1)^{i+1}x_i\right)$$ since consecutive partial derivatives of $$f$$ cancel each other out. I suspect there are more solutions that invoke trigonometric expressions.

Is it possible to derive the entire family/families of functions $$f$$ that satisfy $$(1)$$?

Note that your equation is equivalent to $$(1,1,1,\dots,1)\cdot\nabla f=0$$ This means that $$f$$ is constant on lines parallel to $$(1,1,1,\dots,1)$$; these lines are the characteristics of the partial differential equation.
Thus, we can define $$f$$ freely on $$x_n=0$$ and then $$f(x_1,x_2,x_3,\dots,x_n)=f(x_1-x_n,x_2-x_n,x_3-x_n,\dots,0)$$
Define $$y_i:=x_i-x_n$$ for every $$i=1,2,\ldots,n-1$$, and $$y_n:=x_n\,.$$ Then, we have $$x_i=y_{i}+y_n$$ for each $$i=1,2,\ldots,n-1$$, and $$x_n=y_n\,.$$ Observe that $$\frac{\partial}{\partial y_n}=\sum_{k=1}^n\,\left(\frac{\partial x_k}{\partial y_n}\right)\,\frac{\partial}{\partial x_k}=\sum_{k=1}^n\,\frac{\partial}{\partial x_k}\,.$$ Hence, the given partial differential equation is equivalent to $$\frac{\partial \phi}{\partial y_n}(y_1,y_2,\ldots,y_{n-1},y_n)=0\,,$$ where $$\phi(y_1,y_2,\ldots,y_{n-1},y_n):=f\left(y_1+y_n,y_2+y_n,\ldots,y_{n-1}+y_n,y_n\right)\,.$$ Consequently, $$\phi(y_1,y_2,\ldots,y_{n-1},y_n)$$ is a function of $$y_1,y_2,\ldots,y_{n-1}$$. In other words, there exists a smooth function $$\Phi:\mathbb{R}^{n-1}\to \mathbb{R}$$ such that $$f\left(x_1,x_2,\ldots,x_{n-1},x_n\right)=\Phi\left(x_1-x_n,x_2-x_n,\ldots,x_{n-1}-x_n\right)\,.$$ We can check that such $$f$$ satisfies the condition. Your nontrivial example for even $$n$$ arises from taking $$\Phi(t_1,t_2,\ldots,t_{n-1}):=\exp\left(\sum_{i=1}^{n-1}\,(-1)^{i+1}\,t_i\right)\,.$$
In general, let $$\alpha_1,\alpha_2,\ldots,\alpha_n\in\mathbb{R}$$ be arbitrary with $$\alpha_n\neq 0$$. Then, all differentiable functions $$f:\mathbb{R}^n\to\mathbb{R}$$ that satisfy the partial differential equation $$\sum_{i=1}^n\,\alpha_i\,\frac{\partial f}{\partial x_i}(x_1,x_2,\ldots,x_n)=0$$ for every $$x_1,x_2,\ldots,x_n\in\mathbb{R}$$ take the form $$f(x_1,x_2,\ldots,x_n)=\Phi\left(\alpha_n\,x_1-\alpha_1\,x_n,\alpha_n\,x_2-\alpha_2\,x_n,\ldots,\alpha_n\,x_{n-1}-\alpha_{n-1}\,x_n\right)\,,$$ where $$\Phi:\mathbb{R}^{n-1}\to\mathbb{R}$$ is a differentiable function.