If $f$ is a real function defined in a convex open set $E\subset \mathbb{R}^n$, such that $(D_1f)(\mathbf{x})=0$ for every $\mathbf{x}\in E$, prove that $f(\mathbf{x})$ depends only on $x_2, \dots, x_n$.
Proof: Let $\overline{a}\in E$ and $\hat{a}\in E$ two points which differs only by first coordinate, i.e. $\overline{a}=(a_1,a_2,\dots, a_n)$ and $\hat{a}=(b_1,a_2,\dots, a_n)$ and WLOG we suppose that $a_1>b_1$. We have to prove that $f(\overline{a})=f(\hat{a})$.
Let $f(t,x_2,\dots,x_n)=g(t)$ then $$f(\overline{a})-f(\hat{a})=f(a_1,a_2,\dots, a_n)-f(b_1,a_2,\dots, a_n)=g(a_1)-g(b_1)=$$ Here we can use Mean value theorem and we get: $$=g'(\theta)(a_1-b_1)$$ where $\theta\in (a_1,b_1)$. But $(\theta, a_2,\dots,a_n)\in E$ since $E$ is convex. Then $g'(\theta)=(D_1f)(\theta)=0$ $\Rightarrow$$g(a_1)-g(b_1)=0$. Thus, $f(\overline{a})=f(\hat{a})$.
I am sorry if this topic is repeated but I solved this problem after many attempts.
Is this proof correct?