Let $U$ be an open subset of $\mathbb{R}^n$. Let $f: U \to \mathbb{R}$ be differentiable with $\nabla f(x) = 0$ for all $x \in U$.
I have already shown that if $U$ is path-connected then $f$ is constant.
In the next task I have to show, that this statement is wront, if $U$ is not path-connected. I assume that I need a counterexample here with a $f$ is above where $U$ is not path-connected and $f$ is not constant, but I am struggling to understand which function should have $\nabla f(x)=0$ and not be constant.
I would really appreciate some help.
Take $f(x,y)=1$ if $(x,y) \in B((0,0),1)$
and $f(x,y)=0$ if $(x,y) \in B((3,0),1)$
So $U=B((0,0),1) \cup B((3,0),1)$