$2\times 2$ matrices that carry the line $y=x$ to the line $y=3x$ This  is exercise in Artin's book Algebra:

Find all real $2\times 2$ matrices that carry the line $y=x$ to the line $y=3x$.

I tried: Rotation matrix: $$\begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\\ \end{bmatrix},$$ where $\theta=\arctan 3-\arctan 1$. But it seems like there are whole lot other matrices.
 A: It is not so sophisticated as that: the vector $(1,1)$ is mapped to the vector $(a+b,c+d)$ and the latter must satisfy the relation
$$c+d=3(a+b).$$
A: There are a lot more matrices, because "moves a given line to another given line" leaves a lot of degrees of freedom, even for something as limited as linear maps.
The simplest solution is probably $$\begin{bmatrix}1&0\\0&3\end{bmatrix}$$ which stretches everything vertically just enough to transform the line the way we want it. But rotation is also a valid solution. A third approach is a shear, like
$$
\begin{bmatrix}1&-\frac23\\0&1\end{bmatrix}
$$
A: The key to questions like this is a clever choice of basis. In this case, the basis $$\mathcal{B}=\left\{\begin{bmatrix} 1 \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ 0 \end{bmatrix}\right\}$$ is best. Once we've chosen a basis, any linear transformation is determined exactly by how it operates on the basis vectors. To see this, note that as $\mathcal{B}$ is a basis for $\mathbb{R}^2$, any $v\in \mathbb{R}^2$ has a unique expansion of the form $\lambda_1v_1+\lambda_2v_2$, so $T(v)=\lambda_1 T(v_1)+\lambda_2 T(v_2)$, where $v_1, v_2$ are the basis vectors.
Now, we want to classify all the linear maps $T$ which send vectors of the form $\begin{bmatrix} \lambda \\ \lambda \end{bmatrix}$ to vectors of the form $\begin{bmatrix} \mu \\ 3\mu \end{bmatrix}$, which are exactly those maps that map $\begin{bmatrix} 1 \\ 1 \end{bmatrix}$ to a vector of the form $\begin{bmatrix} \mu \\ 3\mu \end{bmatrix}$, under our basis. So we have $$T\left(\begin{bmatrix} 1 \\ 1 \end{bmatrix}
\right)=\begin{bmatrix} \mu \\ 3\mu \end{bmatrix}=3\mu\begin{bmatrix} 1 \\ 1 \end{bmatrix}-2\mu\begin{bmatrix} 1 \\ 0 \end{bmatrix}.$$
Thus, the coodinates of $T(v_1)$ are $\begin{bmatrix} 3\mu \\ -2\mu \end{bmatrix}$ in our chosen bases. We don't care were $v_2$ is mapped to, but we want to know its coordinates in our basis so we can write down a matrix. $$T(v_2)=\begin{bmatrix} a \\ b \end{bmatrix}=b\begin{bmatrix} 1 \\ 1 \end{bmatrix}+(a-b)\begin{bmatrix} 1 \\ 0 \end{bmatrix}.$$
So the coordinates of $T(v_2)$ are $\begin{bmatrix} b \\ a-b \end{bmatrix}$ in our basis. Thus, under the basis $\mathcal{B}$, all linear maps sending $y=x$ to $y=3x$ have the matrix form:
$$
\begin{bmatrix}
 3\mu & b \\
-2\mu & a-b \\ 
\end{bmatrix}.$$
