# Gradient in a rotated reference frame

I'm sure this is an embarrassingly simple question, but what is the gradient in a different reference frame whose axes are at an angle $\theta$ to the original frame? i.e. what is

$\nabla=\left(\partial_x \hat{x} + \partial_y \hat{y} \right)$

in a reference frame rotated by $\theta$, expressed in terms of the original $\partial_x$ and $\partial_y$? I can't seem to find anything on the web about it.

Let $(x,y)$ be the coordinates in the original frame and let $(\hat{x},\hat{y})$ be the coordinates in the new (rotated by an angle $\theta$) frame. The rotation $\boldsymbol{R}(\theta)$ is given by $$\boldsymbol{R}(\theta) = \left(\begin{array}{cc} \cos\,\theta & -\sin\,\theta\\ \sin\,\theta & \cos\,\theta \end{array}\right),$$ so that $$\left(\begin{array}{c} x\\ y \end{array}\right) = \left(\begin{array}{cc} \cos\,\theta & \sin\,\theta\\ -\sin\,\theta & \cos\,\theta \end{array}\right)\left(\begin{array}{c} \hat{x}\\ \hat{y} \end{array}\right) = \left(\begin{array}{c} \hat{x}\cos\,\theta+\hat{y}\sin\,\theta\\ -\hat{x}\sin\,\theta+\hat{y}\cos\,\theta \end{array}\right),$$ where the fact that $(\boldsymbol{R}(\theta))^{-1} = (\boldsymbol{R}(\theta))^{T}$ was used. Therefore for a differentiable function $f$, using the chain rule, $$\hat{\nabla}f(\hat{x},\hat{y}) = \left(\begin{array}{c} \frac{\partial f(\hat{x},\hat{y})}{\partial\hat{x}}\\ \frac{\partial f(\hat{x},\hat{y})}{\partial\hat{y}} \end{array}\right) = \left(\begin{array}{c} \frac{\partial f(x,y)}{\partial x}\frac{\partial x}{\partial \hat{x}}+\frac{\partial f(x,y)}{\partial y}\frac{\partial y}{\partial \hat{x}}\\ \frac{\partial f(x,y)}{\partial x}\frac{\partial x}{\partial \hat{y}}+\frac{\partial f(x,y)}{\partial y}\frac{\partial y}{\partial \hat{y}} \end{array}\right) = \left(\begin{array}{cc} \cos\,\theta & -\sin\,\theta\\ \sin\,\theta & \cos\,\theta \end{array}\right)\left(\begin{array}{c} \frac{\partial f(x,y)}{\partial x}\\ \frac{\partial f(x,y)}{\partial y} \end{array}\right).$$ The above shows explicitly that $$\hat{\nabla}f(\hat{x},\hat{y}) = \boldsymbol{R}(\theta)\nabla f(x,y).$$

Gradient is a covarient vector, so it transforms under $$R$$ rather than $$R^T$$ if components of vector are transforming under $$R^T$$. It can be seen as follows:

$$\left(\begin{array}{cc}x'\\y'\end{array}\right)=\boldsymbol{R^T}(\theta)\left(\begin{array}{cc}x\\y\end{array}\right) = \left(\begin{array}{cc} \cos\,\theta & \sin\,\theta\\ -\sin\,\theta & \cos\,\theta \end{array}\right)\left(\begin{array}{cc}x\\y\end{array}\right)$$ and, $$f(x,y)=f(x'\cos\theta -y'\sin\theta,x'\sin\theta +y'\cos\theta)$$

It can be seen here that

\begin{align} \dfrac{\partial f(x,y)}{\partial x'} &= \dfrac{\partial f (x,y)}{\partial x}\dfrac{\partial x}{\partial x'}+\dfrac{\partial f (x,y)}{\partial y}\dfrac{\partial y}{\partial x'}\\ &=\dfrac{\partial f (x'\cos\theta -y'\sin\theta,y)}{\partial (x'\cos\theta -y'\sin\theta)}\dfrac{\partial (x'\cos\theta -y'\sin\theta)}{\partial x'}+\dfrac{\partial f (x,x'\sin\theta +y'\cos\theta)}{\partial (x'\sin\theta +y'\cos\theta)}\dfrac{\partial (x'\sin\theta +y'\cos\theta)}{\partial x'}\\\\ &= \cos\theta \dfrac{\partial f (x,y)}{\partial x}+ \sin\theta\dfrac{\partial f (x,y)}{\partial y} \end{align}

Similarly for $$\partial_{y'} f$$

\begin{align} \dfrac{\partial f(x,y)}{\partial y'} &= \dfrac{\partial f (x,y)}{\partial x}\dfrac{\partial x}{\partial y'}+\dfrac{\partial f (x,y)}{\partial y}\dfrac{\partial y}{\partial y'}\\ &=\dfrac{\partial f (x'\cos\theta -y'\sin\theta,y)}{\partial (x'\cos\theta -y'\sin\theta)}\dfrac{\partial (x'\cos\theta -y'\sin\theta)}{\partial y'}+\dfrac{\partial f (x,x'\sin\theta +y'\cos\theta)}{\partial (x'\sin\theta +y'\cos\theta)}\dfrac{\partial (x'\sin\theta +y'\cos\theta)}{\partial y'}\\\\ &= -\sin\theta \dfrac{\partial f (x,y)}{\partial x}+ \cos\theta\dfrac{\partial f (x,y)}{\partial y} \end{align} Therefore,

$$\left(\begin{array}{cc}\dfrac{\partial f (x,y)}{\partial x'}\\\dfrac{\partial f (x,y)}{\partial y'}\end{array}\right) = \left(\begin{array}{cc} \cos\,\theta & \sin\,\theta\\ -\sin\,\theta & \cos\,\theta \end{array}\right)\left(\begin{array}{cc}\dfrac{\partial f (x,y)}{\partial x}\\\dfrac{\partial f (x,y)}{\partial y}\end{array}\right)=\boldsymbol{R^T}(\theta)\left(\begin{array}{cc}\dfrac{\partial f (x,y)}{\partial x}\\\dfrac{\partial f (x,y)}{\partial y}\end{array}\right)$$

But this is the contravarient representation of gradient, so the covarient representation looks like

$$\left(\begin{array}{cc}\dfrac{\partial f (x,y)}{\partial x'} &\dfrac{\partial f (x,y)}{\partial y'}\end{array}\right) = \left(\begin{array}{cc}\dfrac{\partial f (x,y)}{\partial x}&\dfrac{\partial f (x,y)}{\partial y}\end{array}\right) \left(\begin{array}{cc} \cos\,\theta & -\sin\,\theta\\ \sin\,\theta & \cos\,\theta \end{array}\right)$$

which transforms under $$R$$. Only difference being the representation of covarient vector and contravarient vectors are different which dicate how they transform.