# How to find a matrix given how it transforms some vectors

Given that you have $n$ vectors $v$ in some basis (the basis vectors will be denoted with $b$) and you know in what vectors $u$ they are transformed after multiplying them by some matrix A, how can you find the matrix A? The number of vectors ($n$) is equal you the rank of $A$. So:

$Av_i=u_i$ for all $i$ from $1$ to $n$

My idea is to take the matrix $B$ that transforms the basis vectors into the $v$ vectors. (this is trivial):

Let $B$ be a matrix such that $Bb_i=v_i$ for all $i$ from $1$ to $n$

Then we multiply the $u$ vectors by $B$ and we get the $w$ vectors:

$w_i:=B^{-1}u_i$ for all $i$ from $1$ to $n$

If I am not mistaken the $w$ vectors are just the the $u$ vectors but in the basis of the $v$ vectors (so using the $v$ vectors as a basis).

Now we take the matrix $C$ which transforms the basis vectors into the $w$ vectors (this is trivial):

Let $C$ be a matrix such that $Cb_i=w_i$ for all $i$ from $1$ to $n$

I think that A should be calculated in the following way:

$A=BCB^{-1}$

Is this correct?

EDIT: I tried it with an example and it appears it is wrong, but I am not sure why.

EDIT2: I think I found my mistake, so I corrected it. It works with my example now.

• the very same question was asked recently, let me find the post.
– zwim
Mar 19, 2017 at 23:35
• If $A[v_1\ v_2\ ...\ v_n]=[u_1\ u_2\ ...\ u_n]$ and $v_i$ span the whole space then $A=[u_1\ u_2\ ...\ u_n][v_1\ v_2\ ...\ v_n]^{-1}$.
– A.Γ.
Mar 19, 2017 at 23:43
• – zwim
Mar 19, 2017 at 23:50
• You’re making several assumptions that you haven’t spelled out. What are the dimensions of the domain and codomain? The latter must be at least as big as the former, but it looks like you might be assuming they’re the same. Why do you believe that $B$ is invertible? Simply having a set of $n$ vectors isn’t going to guarantee this.
– amd
Mar 19, 2017 at 23:54
• @amd The number of vectors is equal to the number of dimensions. And there is an unique solution. Mar 20, 2017 at 6:17