How to solve this linear algebra equation I become very bad in linear algebra when matrices are involved in the calculation.
Here is one equation:
$$H = (A_2 - a_2p)(A_1 - a_1p)^{-1}$$
where:
$H$, $A_1$ and $A_2$ are $3\times3$ matrices, 
$a_1$ and $a_2$ are $3\times 1$ matrices
$p$ is a $1\times3$ matrix.
$p$ is the only unknown I want to find. How can I do please?
Thanks.
 A: Multiplying on the right by $A_1-a_1p$, one gets 
$$
K=bp\quad\text{with}\quad K=A_2-HA_1\quad\text{and}\quad b=a_2-Ha_1.
$$
Recall that $K=(K_{ij})_{1\leqslant i,j\leqslant3}$ is a $3\times3$ matrix, $b=(b_i)_{1\leqslant i\leqslant3}$ is a $3\times1$ (column) vector and one looks for a $1\times3$ (line) vector $p=(p_j)_{1\leqslant j\leqslant 3}$. 
That is, $K=bp$ is a shorthand for the condition that 
$K_{ij}=b_ip_j$ for every $(i,j)$. Thus, $K=bp$ is solved by 
$$
p_j=K_{ij}/b_i
$$ 
for every $(i,j)$ if $K_{ij}/b_i$ does not depend on $i$, and has no solution otherwise. Recall finally that, by definition,
$$
K_{ij}=(A_2)_{ij}-\sum\limits_{k=1}^3H_{ik}(A_1)_{kj}\quad\text{and}\quad b_i=(a_2)_i-\sum\limits_{k=1}^3H_{ik}(a_1)_k.
$$
Edit (This is due to @David Mitra in a comment.)
Drawing the matrices $K$ and $bp$ may help to see what is going on: 
$$
\underbrace{
\left[
\matrix {K_{11} & K_{12}& K_{13}\cr   K_{21}& K_{22}& K_{23}\cr  K_{31}& K_{32}& K_{33}\cr    }  \right]}_{K=A_2-HA_1}=
\underbrace{
\left[
\matrix { b_1p_1& b_1p_2& b_1p_3 \cr   b_2p_1& b_2p_2& b_2p_3 \cr  b_3p_1& b_3p_2& b_3p_3 \cr  }  \right]}_{bp=(a_2-Ha_1)p }.
$$
