Let $f: \mathbb{R}^{n} \to \mathbb{R}$ be of class $C^{q}$ for $q \geq 1$. Suppose $\frac{\partial f}{\partial x_i}(p) \neq 0$ for some $p \in \mathbb{R}^{n}$. Define $g: \mathbb{R}^{n} \to \mathbb{R}^{n}$ by
$g(x_1, \ldots, x_i, \ldots, x_n) = (x_1, \ldots, x_n, \ldots, x_i)$. That is $g$ swaps the $i$th and $n$th coordinates. $g$ is of class $C^{\infty}$. I need to show that
$$\frac{\partial(f \circ g)}{\partial x_n}(g^{-1}(p)) = \frac{\partial f}{\partial x_i}(p) \neq 0.$$
However, when I do this computation I get
$$\frac{\partial(f \circ g)}{\partial x_n}(g^{-1}(p)) = (\nabla f \cdot \frac{\partial g}{\partial x_n})(g^{-1}(p))$$
where $\frac{\partial{g}}{\partial x_n} = (0, \ldots, 1, \ldots, 0)$ where the $1$ is in the $i$th position. Thus I should get
$\frac{\partial(f \circ g)}{\partial x_n}(g^{-1}(p)) = \frac{\partial{f}}{\partial x_i}(g^{-1}(p))$, which is not what I wanted. Therefore I must be doing something wrong. I think it must be when I do the chain rule. Any insight as to where I went wrong and what the right process would be greatly appreciated.
I think I've figured out what's wrong. The equation
$$\frac{\partial f\circ g}{\partial x_n} = (\nabla f \cdot \frac{\partial g}{\partial x_n}) $$ is not right. Rather we have
$$\frac{\partial f\circ g}{\partial x_n} = \sum_{j = 1}^{n}\left(\frac{\partial f}{\partial x_j}\circ g\right) \frac{\partial{g_j}}{\partial x_n} = \left(\frac{\partial f}{\partial x_i}\circ g\right)$$ Plugging in $g^{-1}(p)$ gives the desired result.