I am new to tensors and I have just learned that the contravarient components of a vector transforms in the following way (using Einstein summation convention) $$A^{'i}=\frac {\partial x^{'i}}{\partial x^j}A^j$$ I want to transform the components of a vector from polar $(r,\theta)$ coordinate to cartesian $(x,y)$ coordinate. So, I use $x^{'1}=x, x^{'2}=y, x^1=r$ and $x^2=\theta$. Also, $x=r\cos\theta$ and $y=r\sin\theta$. After performing the partial derivatives, I obtain the transformation matrix as $$ \begin{pmatrix} \cos\theta & -r\sin\theta \\ \sin\theta & r\cos\theta \\ \end{pmatrix} $$ But, I know from my basic vector studies that $$\hat r=\cos \theta \hat x + \sin \theta \hat y$$ $$\hat \theta=-\sin \theta \hat x + \cos \theta \hat y$$ So, $$\vec A=A_x\hat x+A_y\hat y=A_r\hat r+A_\theta\hat \theta=(A_r\cos \theta-A_\theta\sin \theta)\hat x+(A_r\sin \theta+A_\theta\cos \theta)\hat y$$
Now, equating the $\hat x$ and $\hat y$ components, we obtain the transformation matrix as $$ \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \\ \end{pmatrix} $$ Can anyone please explain why this discrepancy arises? Have I misunderstood something? What am I doing wrong here?