Partial derivative with respect to function of a variable I was wondering what I'm doing wrong by considering $g(x,y)=x^2$ and then considering $\frac{\partial }{\partial x} \left(\frac{\partial g}{\partial (x^2)}\right)  = \frac{\partial}{\partial x} (1) = 0 \neq \frac{\partial}{\partial (x^2)} \left( \frac{\partial g}{\partial x}\right)  = \frac{1}{2x}$?
($\frac{\partial}{\partial (x^2)}$ denotes differentiation with respect to $x^2$)
 A: This is not the correct way to use partial derivatives in the first place. Partial derivatives are used when the two variable with respect to which you are differentiating are independent of each other.
Here, $x^2$ and $x$ are clearly not independent of each other, so Clairaut's theorem that $f_{xy} = f_{yx}$ does not hold.
$\textbf{Edit}$:
This is in response to the comment by the OP.
The LHS of the equation, $\frac{d}{dx} \frac{ d(g(x)) }{ dx^2 }$ is correct, it is clearly $0$ as $\frac{ d(g(x)) }{ dx^2 } = 1$ which is a constant and so further differentiation would give $0$. Note that I'm using $d$, not $\partial$. The only independent variable in this is $x$, the variable $x^2$ is not an independent variable and $y$ is not used anywhere. So your question is now just an application of the single-variable chain rule.
The RHS on evaluation gives,
\begin{align}
\frac{ d }{ d(x^2) } \frac{ d(g(x)) }{ dx } &= 
    \frac{ d(2x) }{ d(x^2) } \\
    &= \frac{ 2 (dx) }{ 2x (dx)} \\
    &= \frac{1}{x}
\end{align}
Here, I've taken advantage of the Liebniz notation in differentiating the numerator and denominator separately, and quote-unquote "cancelling" the $dx$ as in a fraction.
So in reality, this is not a question of multivariable calculus, but single variable only. So these derivatives are clearly not equal, but they can be evaluated using the chain rule like usual.
