Let $R \in \{\mathbb{C}[t^2,t^3], \mathbb{Z}[\sqrt{5}]\}$, and let $A=A(x,y) \in R[x,y]$ with $\deg(A) \geq 1$ (total degree).

I wish to prove or find a counterexample to the following claim:

If there exist $w=w(x,y),C=C(x,y) \in R[x,y]$ such that $w_x=CA_x$ and $w_y=CA_y$ (the subscripts denote partial derivatives), then necessarily $w=f(A)$ and $C=f'(A)$, for some $f \in R[T]$.

I have asked the above question here, but have not received an answer; hopefully, my question is appropriate for MO.

Actually, **my 'original' question** is as follows:

Suppose that $A,B,w \in R[x,y]$ satisfy two conditions:

(i)$\operatorname{Jac}(A,B)=1$.(ii)$\operatorname{Jac}(A,w)=0$. Is it true that $w \in R[A]$?Perhaps, if there exists a counterexample to my original question, then it is easier to find a counterexample in the first Weyl algebra than in $R[x,y]$, where the Jacobian is replaced by the commutator? See this question.

New edit 2:If I am not missing something, the following is a counterexample to my original question: $R=\frac{\mathbb{C}[a,b,c]}{\langle a^2-1, bc \rangle}$, $A=(\bar{a}+i\bar{b})x+\bar{b}y$, $B=\bar{b}x+(\bar{a}-i\bar{b})y$, $w=\bar{c}x$; see this for more elaboration. Please, what do you think?

Any hints and comments are welcome!

New edit:A counterexample if $R$ is not a $\mathbb{Q}$-algebra: Adjusting Warning 1.1.17, we obtain: Let $R:=\frac{\mathbb{Z}[t]}{(2t)}$, $R[x,y]$, $A=x-\bar{t}x^2$, $B=Y$, $w=x$. We have:

(i)$\operatorname{Jac}(A,B)=1$.(ii)$\operatorname{Jac}(A,w)=(1-2\bar{t}x)0-01=10-01=0$.(iii)$w=X \notin R[x-\bar{t}x^2]$ from considerations of degrees.

**Motivation:** The motivation to my questions is a result of Cheng-Mckay-Wang that showed that the answer to my 'commutative' question is positive for $R=\mathbb{C}$,
and a result by J.A. Guccione, J.J. Guccione, and C. Valqui that showed that
the answer to my 'non-commutative' question is positive for $R=k$,
a field of characteristic zero.

Then it is possible to show (I can add a complete explanation, if one will ask me to) that the answer to my question is still positive if we replace $R=\mathbb{C}$ by any field of characteristic zero.

Moreover, the answer to my question is still positive if we replace $R=\mathbb{C}$ by any normal integral domain of characteristic zero; this follows quite immediately from this answer (I can add a complete explanation, if one will ask me to). See also this answer.

Therefore, we are left with the case that $R$ is a non-normal integral domain of characteristic zero, for example: $R \in \{\mathbb{C}[t^2,t^3], \mathbb{Z}[\sqrt{5}]\}$.

We have: **(i)** $A_xB_y-A_yB_x=1$ and **(ii)** $A_xw_y-A_yw_x=0$.
Then, $A_xw_y=A_yw_x$, so $\frac{w_y}{A_y}=\frac{w_x}{A_x}=:C$ for some $C \in R(x,y)$; hence, $w_x=CA_x$ and $w_y=CA_y$.
Multiply **(i)** by $C$ and get that
$R[x,y] \ni w_xB_y-w_yB_x=CA_xB_y-CA_yB_x=C$.

Next, as was calculated here (my above mentioned MSE question), $C_yA_x=C_xA_y$, namely, $\operatorname{Jac}(A,C)=0$. Observe that $w_x=CA_x$ (or $w_y=CA_y$) implies that $\deg(w)=\deg(C)+\deg(A)$, so $\deg(C) < \deg(w)$. By induction on the degree of an element $e \in R[x,y]$ in the 'centralizer of $A$' (= $\operatorname{Jac}(A,e)=0$) we obtain that $C \in R[A]$.

Then, if I am not wrong, from $C \in R[A]$, $w_x=CA_x$ and $w_y=CA_y$, it follows that $w \in R[A]$: Write $C=g(A)$ for some $g \in R[T]$, so $w_x=g(A)A_x=\frac{\partial}{\partial{x}}f(A)$, where $f'(T)=g(T)$. Then, $w=f(A)+H(y)$. Then $CA_y=w_y=g(A)A_y+H'(y)=CA_y+H'(y)$, so $H'(y)=0$, namely, $H(y)=r \in R$, concluding that indeed $w=f(A)+r \in R[A]$.

The base case of the induction is $e=\lambda x+\mu y+\nu$; w.l.o.g $\mu=0$ so $e=\lambda x+\nu$. Then we have, $\operatorname{Jac}(A,e)=-A_y \lambda=0$, so $A \in R[x]$. It is easy to see that $A \in R[x]$ which has a Jacobian mate (= $\operatorname{Jac}(A,B)=1$) must be of degree one: $A=\delta x + \epsilon$, and then indeed $e=\lambda x+\nu \in R[x]=R[A]$.

It seems that the above arguments are valid for any integral domain $R$ of characteristic zero, normal or not; am I right?