Let $z=f(x,y)$ be a function of class $C^1(G;\mathbb{R})$.
a) If $\frac{\partial f}{\partial y}(x,y)\equiv 0$ in $G$, can one assert that $f$ is independent of $y$ in $G$?
b) Under what condition on the domain $G$ does the preceding question have an affirmative answer?
Sorry if this question has been asked many times but my question is a bit different and it is about part b). But I did not find my question in existing topics.
Part a) The answer is NO because one can consider the following function $f:G\to \mathbb{R}$, where $G=\{(x,y)\in \mathbb{R}^2: 1<x^2+y^2<4,\ x>0\}$ and $$f(x,y) = \begin{cases} 0, & \text{if }(x,y)\in G, x\in [1,2), \\ (x-1)^2, & \text{if }(x,y)\in G,\ x\in (0,1),\ y>0, \\ -(x-1)^2, & \text{if }(x,y)\in G,\ x\in (0,1),\ y<0. \end{cases}$$ It is easy to see that $f$ depends on $y$ since $f(\frac{1}{2},1)\neq f(\frac{1}{2},-1)$ and $\frac{\partial f}{\partial y}\equiv 0$ on $G$.
Part b) I can prove that if $G$ is convex open set in $\mathbb{R}^2$ then the answer to part a) is YES. But I believe that it is true for larger family of sets in $\mathbb{R}^2$. More precisely, if $G\subset \mathbb{R}^2$ is an open nonempty set with connected first projections then the answer to part a) is still YES. Here by connected first projections I mean that if $x\in \pi_1(G)$, then for any $y_1, y_2$ such that $z_1:=(x,y_1)\in G$ and $z_2:=(x,y_2)\in G$ the line segment $[z_1,z_2]:=\{(x,\theta y_1+(1-\theta)y_2):\theta\in [0,1]\}\subset G$. This is a larger class of sets since every convex set has this property.
The proof is relatively easy. Indeed, let $x_0\in \pi_1(G)$, then $\exists y_0: (x_0,y_0)\in G$. Let $y$ be such that $(x_0,y)\in G$ and WLOG $y_0<y$. Consider a function $\varphi:[y_0,y]\to \mathbb{R}$ defined as $t\mapsto f(x_0,t)$. One can check that $\varphi$ is continuous and differentiable on $[y_0,y]$ and by MVT, we have: $\varphi(y)-\varphi(y_0)=\varphi'(c)(y-y_0)=\frac{\partial f}{\partial y}(x_0,c)(y-y_0)=0.$ Therefore, $\varphi(y)=\varphi(y_0)$ which is equivalent to $f(x_0,y)=f(x_0,y_0)$. We have shown that for any $(x,y)\in G$, we have $f(x,y)=f(x,F(x))$, where $F:\pi_1(G)\to \mathbb{R}$ which is defined as: $x_0\mapsto y_0$, where $(x_0,y_0)\in G$. For example, this function $F$ can be constructed by Axiom of Choice. We are done since we have shown that $f(x,y)$ is independent of $y$.
So far I do not see any mistake. Thank you!