# Find a transformation in specified basis

My task is to find a matrix of linear transformation $\varphi$ in basis $A,B$

$\varphi:\mathbb{R}^{2}\to\mathbb{R}^{4} \varphi((x_{1},x_{2}))=(3x_{1}+x_{2},x_{1}+5x_{2},-x_{1}+4x_{2},2x_{1}+x_{2})$

$\mathcal{A}=\{(3,1),(4,2)\} \mathcal{B}=\{(1,0,1,0),(0,1,1,1),(0,1,2,3),(0,0,0,1)\}$

How I've started:

$M_{st}^{st}(\varphi)=\left[\begin{matrix}3 & 1\\ 1 & 5\\ -1 & 4\\ 2 & 1 \end{matrix}\ \right]$

$M_{B}^{st}(id)=\left[\begin{array}{cccc} 1 & 0 & 0 & 0\\ 0 & 1 & 1 & 0\\ 1 & 1 & 2 & 0\\ 0 & 1 & 3 & 1 \end{array}\right]$

$M_{A}^{st}(id)=\left[\begin{matrix}3 & 4\\ 1 & 2 \end{matrix}\right]$

$M_{st}^{A}(id)=(M_{A}^{st}(id))^{-1}$

$\left[\begin{matrix}3 & 4 & 1\\ 1 & 2 & & 1 \end{matrix}\right]\sim\left[\begin{matrix}1 & 0 & 1 & -2\\ 1 & 2 & & 1 \end{matrix}\right]\sim\left[\begin{matrix}1 & 0 & 1 & -2\\ 0 & 2 & -1 & 3 \end{matrix}\right]\sim\left[\begin{matrix}1 & 0 & 1 & -2\\ 0 & 1 & -\frac{1}{2} & \frac{3}{2} \end{matrix}\right]$

$M_{st}^{A}(id)=\left[\begin{matrix}1 & -2\\ -\frac{1}{2} & \frac{3}{2} \end{matrix}\right]$

$M(id)_{st}^{A}\cdot M_{st}^{st}(\varphi)=M_{st}^{A}(\varphi)$

$M_{st}^{A}(\varphi)=\left[\begin{matrix}1 & -2\\ -\frac{1}{2} & \frac{3}{2} \end{matrix}\right]\cdot\left[\begin{matrix}3 & 1\\ 1 & 5\\ -1 & 4\\ 2 & 1 \end{matrix}\right] = ???$

I was doing everything with my algorithm. But I did something wrong. Could someone point me where and how to fix it?

Assuming that vectors in $\mathbb{R}^2$ and $\mathbb{R}^4$ are represented by column vectors, you should find $M_B^{st}(id)^{-1}M_{st}^{st}(\varphi)M_A^{st}(id)$ instead. If you adopt a row vector convention, just transpose the resulting matrix.