A sufficient condition for $U \subseteq \mathbb{R}^2$ such that $f(x,y) = f(x)$ I have another short question. Let $U \subseteq \mathbb{R}^2$ be open and $f: U \rightarrow \mathbb{R}$ be continuously differentiable. Also, $\partial_y f(x,y) = 0$ for all $(x,y) \in U$. I want to find a sufficient condition for $U$ such that $f$ only depends on $x$. Of course, the condition shouldn't be too restrictive. Is it sufficient for $U$ to be connected?
Thanks a lot for any help.

It's enough for $U$ to have the property that, whenever $(x,y_1)$ and $(x,y_2)$ are in $U$, so is the line segment between them. This can be proved by applying the mean value theorem to the function $g(y)=f(x,y)$.
It is not enough for $U$ to be connected. For example, take $U=\mathbb{R} \setminus \{(x,0)|x \le 0 \}$. Let $f(x,y)=0$ for $x \ge 0$, $f(x,y)=x^2$ for $x<0, y<0$ and $f(x,y)=-x^2$ for $x<0, y>0$.
