Zero gradient may not imply the function is constant

27 Views Asked by At

Let $f:U\to\mathbb{R}$ where $U$ is an open and connected subset of $\mathbb{R}^n$ such that $\nabla f=0$ in $U$. Does it imply the function $f$ is constant in $U$?

I know it is true for a convex $U$, but could not prove neither disprove for an arbitrary open set $U$.

Can some one please help with a counterexample if false.

Thanks.