chain rule - legendre transformation let
$$df = \dfrac{∂f}{∂x}\ dx + \dfrac{∂f}{∂y} \ dy
\text{  and  }
\dfrac{∂f}{∂x} = p , \dfrac{∂f}{∂y} = q$$
So we get
$$df = p\ dx + q\ dy$$
$$d(f - qy) = p \ dx - y\ dq$$
and now, define $g$.
$$g = f - q\ y$$
and then I faced problem.
$\dfrac{∂g}{∂x} = p$←←←←←←←←←←←←←←← book said
but I think
$$\dfrac{∂g}{∂x} = \dfrac{∂f}{∂x} - y \ \dfrac{∂q}{∂x} - q \ \dfrac{∂y}{∂x} = p - y \ \dfrac{∂q}{∂x}$$
I'm not sure that $q$ is not the independent function of $x$. if the func $f$ is $xy$??? if I set like that,
$$g = f - qy = xy - xy = 0 = p = \dfrac{∂f}{∂x} = y$$
mathematical methods in the physical sciences, Mary L. Boas 3rd edition page231
 A: You are asked to interpret $g$ as a function of $x$ and $q$ but $y$ is still present in the defining equation $g=f-qy$. So you need the additional equation
\begin{align*}
q = \frac{\partial f}{\partial y}(x,y)
\end{align*}
to express $y$ as function of $q$ (and $x$). For that purpose the function $y\mapsto \frac{\partial f}{\partial y}(x,y)$ must be bijective (for every $x$). For ensuring bijectivity it is often assumed that $f$ is strongly convex.
The partial derivative $\frac{\partial g}{\partial x}$ actually already follows from the total differential
\begin{align*}
dg = p\cdot dx - y\cdot dq
\end{align*}
But also your hard way to calculate $\frac{\partial g}{\partial x}$ works if you carefully consider the dependencies:
\begin{align*}
g(x,q) &= f(x,y(x,q)) - q\cdot y(x,q)\\
\frac{\partial g}{\partial x} &= \frac{\partial f}{\partial x} + \frac{\partial f}{\partial y}\cdot\frac{\partial y}{\partial x} - q\cdot\frac{\partial y}{\partial x}\\
&= p + q\cdot \frac{\partial y}{\partial x} - q\cdot\frac{\partial y}{\partial x}\\
&= p
\end{align*}

Your example $f(x,y) = xy$ is inappropriate since $q=\frac{\partial f}{\partial y} = x$ is not a bijective mapping from $y$ to $q$.
We can fix that by modifying it to $f(x,y)=xy+\frac12y^2$ giving $q=x+y$ which has the inverse $y=q-x$. The Legendre-transformed is then
\begin{align*}
g(x,q) &= x\cdot(q-x) + \frac12\left(q-x\right)^2 - q\cdot(q-x)\\
&= -\frac12 x^2 +qx -\frac12 q^2\\
&= -\frac12(x-q)^2
\end{align*}
and
\begin{align*}
\frac{\partial g}{\partial x} &= q-x
\end{align*}
For comparison: $p=\frac{\partial f}{\partial x} = y = q-x$//.
Note, that you find some stuff about the background of the Legendre transformation in Arnold's book on Mathematical Methods of Classical Mechanics.
