Determine the values of $a,b,c,d \in \Bbb{R}$ such that $g_x(x,y)=ax+by$ and $g_y(x,y)=cx+dy$ are the correct partial derivatives? I've seen the following question:

Determine the values of $a,b,c,d \in \Bbb{R}$ such that $g_x(x,y)=ax+by$ and $g_y(x,y)=cx+dy$ are the correct partial derivatives.

I've answered it as follows:

$g=ax² +byx+k=cyx+dy²+k$
Deriving the first one wrt $y$ and the second wrt $x$, we get:
$g_y=bx \quad \quad \quad \quad g_x=cy$
Comparing with what we have:
$ax+by=cy\quad \quad \quad cx+dy=bx$
Here we see that $b=c$ and $a=d=0.$

But the answer was:

Using Clairaut's Theorem, $g_{xy}=g_{yx}$. From this, we see that $b=c$ and $a,d$ are any numbers.

Although, I don't get what is wrong with my answer and the actual answer seems a little bit suspicious to me. What is actually wrong with what I did?
 A: Since you’re looking at partial derivatives of $g$, the “constants” of integration of their antiderivatives are arbitrary functions of the other variable. That is, $$\int g_x \, dx = ax^2+bxy+h(y)$$ and differentiating this with respect to $y$ gives $bx+h'(y)$, not simply $bx$. Comparing this to the given $g_y$, we have $b=c$ and $h'(y)=dy$. Integrating the latter with respect to $y$ gives $h(y)=dy^2+k$ (now we can use a constant constant). We therefore have $g(x,y)=ax^2+bxy+dy^2+k$ so, just as in the answer you quoted, we can’t say anything about the values of $a$ and $d$.
A: On the one hand:
$$g_x(x,y)=ax+by \Rightarrow g(x,y)=\int g_xdx=\frac12ax^2+bxy+p(y);\\
g_y(x,y)=\left(\frac12ax^2+bxy+p(y)\right)_y=bx+p'(y)=cx+dy \Rightarrow \\
b=c;p'(y)=dy\Rightarrow p(y)=\frac12dy^2+e\\
g(x,y)=\frac12ax^2+bxy+p(y)=\frac12ax^2+bxy+\frac12dy^2+e$$
On the other hand:
$$g_y(x,y)=cx+dy \Rightarrow g(x,y)=\int g_ydy=cxy+\frac12dy^2+q(x);\\
g_x(x,y)=\left(cxy+\frac12dy^2+q(x)\right)_x=cy+q'(x)=ax+by \Rightarrow \\
b=c;q'(x)=ax \Rightarrow q(x)=\frac12ax^2+f\\
g(x,y)=cxy+\frac12dy^2+q(x)=cxy+\frac12dy^2+\frac12 ax^2+f.$$
Hence:
$$\color{red}{\frac12ax^2}+bxy+\color{blue}{\frac12dy^2}+e=cxy+\color{blue}{\frac12dy^2}+\color{red}{\frac12ax^2}+f \Rightarrow \\
b=c, e=f, \forall a,d.$$
