I am working with compressible Navier–Stokes equations. When calculating the derivatives to linearize the equation, I got confused about one term.
If $f=f(u)$, and $u=u(x,t)$, are the two derivatives equal, i.e., $\frac{d}{dx}\left(\frac{df}{du}\right) = \frac{d}{du}\left(\frac{df}{dx}\right)$?
I've tested a simple scalar case, $f=u^2$ and $u=\sqrt x$. In this case, the partial derivatives are not exahcngeable. But I was wondering if there is any requirement, by satisfying which makes them exchangable?
Your case is trickier than the standard interchange of partial derivatives. So let us first recall how that works. If you have a function $F: \mathbb{R}^2 \to \mathbb{R}$ which has continuous second partial derivatives then it is true that $$\dfrac{\partial}{\partial x}\dfrac{\partial F (x,y)}{\partial y}=\dfrac{\partial}{\partial y}\dfrac{\partial F(x,y)}{\partial x}$$
However your case is different because you have a 1-variable function $f: \mathbb{R} \to \mathbb{R}$ and another 2-variable function $u:\mathbb{R}^2 \to \mathbb{R}$.
Notice that since $f$ is a one variable function we first need to make sense of the expression $$\dfrac{d}{dx}\dfrac{df}{du}$$ This one is easy to make sense of: By $\dfrac{d}{dx}\dfrac{df}{du}$ we actually mean:
$$\dfrac{d}{dx}\dfrac{df (u(x,t))}{du}$$
So you first take the partial derivative with respect to $u$, then evaluate $u$ at $u(x,t)$ and then take the derivative with respect to $x$.
On the other hand, by the expression $\dfrac{d}{du}\dfrac{df}{dx}$ we actually mean:
$$\dfrac{d}{du}\dfrac{d}{dx}|_{x=x(u,t)}f(u(x,t))$$
i.e., we first plug in $u(x,t)$ in $f$, so now you have a function of $x$ (and $t$), then we differentiate with respect to $x$, then evaluate $x$ at $x=x(u,t)$ (you can do this under some mild assumptions by implicit function theorem) so now we have a function of $u$ and $t$, and then we differentiate with respect to $u$.
As you can see, even though the expressions $\dfrac{d}{dx}\dfrac{df}{du}$ and $\dfrac{d}{du}\dfrac{df}{dx}$ may seem to differ just by the exchange of partial derivatives they are actually quite different expressions since we have a lot of compositions going on in-between. I know of no general conditions that make this equality true and I doubt there is any. This is really quite apparent in your own answer since $f=u^2$ and $u=\sqrt(x)$ are $C^{\infty}$ (where $x>0$, say) and you pretty much can't get regularity better than that, yet it doesn't work on them.