Let $U \subset \mathbb{R}^n$ be open and convex and $f : U \rightarrow \mathbb{R}$ differentiable such that $\partial_1f(x)=0$ for all $x \in U.$ Show that the value of $f(x)$ for $x = (x_1,...,x_n) \in U$ does not depend on $x_1.$
$\text{Proof:}$
Suppose for a contradiction that $f$ depends on the first coordinate. Let $x,y \in U$ be such that $x_i=y_i$ except for $i=1.$ Since $U$ is open and convex we can use the Mean Value Theorem. Hence there is $c= t_0x+(1-t_0)y,$ for some $t_0 \in [0,1]$ such that \begin{align*} f(x)-f(y) &=\nabla f(c)\cdot\langle x-y \rangle\\ &=\langle 0,\partial_2f(c),...,\partial_nf(c) \rangle \cdot \langle x_1-y_1,0,...,0 \rangle \\ &=0. \end{align*}
Therefore, we have that $f(x)=f(y),$ which is a contraction, since $f$ is not constant. Thus, $f$ does not depend on the first coordinate.
Is this the correct approach to this problem? Any feedback is much appreciated. Thank you in advance.
Your proof is fine, but it is needless to phrase it as a proof by contradiction. The same computation that you did shows that $g(t) = f(t,x_2,\dots,x_n)$ is a constant function, which is all you want. As a matter of style, direct proofs are preferred to proofs by contradiction.