# Solve a matrix equation of the form $A=XB$

Given matrices $A \in \mathbb{R}^{n \times p}$ and $B \in \mathbb{R}^{m \times p}$, is it possible to solve the matrix equation $A=XB$?

I don't know if this is feasible. It may even be quite easy in fact but I'm stuck with that equation in my work (I'm not a math specialist). I've tried to make the inverse of $B$, but as $B$ is not a square matrix in my data, I can't do that. In my data $A$ is $120 \times 170$ and $B$ is $10 \times 170$. I am expecting $X$ to be $120 \times10$. Any ideas?

EDIT: matrix $B B^\top$ is invertible. Giving a $10 \times 10$ matrix.

• Does $B$ have full row rank? If so, $B B^\top$ is invertible. Apr 6, 2018 at 13:08
• With R i was able to get the inverse of what you said yes. so i guess B is full row rank. It gave me a 10*10 Matrix Apr 6, 2018 at 13:12
• Then you can easily find $X$. Apr 6, 2018 at 13:14
• Ok... I guess it must seems pretty easy. I will edit to say that BBT is inversible. I am not really familiar with matrix manipulation, what should I calcul to get X. Apr 6, 2018 at 13:16
• Right-multiply both sides by $B^\top$ then right-multiply both sides by the inverse of $B B^\top$. Apr 6, 2018 at 13:19

There can not be guaranteed solution. This is evident by the fact, that $A$ can has a rank up to $p$, while the rank of $XB$ is limited by $p$ (if we keep the order of your sizes). If you draw a picture of your matrices (just the boxes) you find, that you are searching for a low rank representation of $A$ with a specific set of right singular vectors. I italize because these are most likely not orthogonal.

You can approximate $A$ by your product. The best (I assume) way to do this, is by choosing the pseudo-inverse of $B$. (Matlab gives this by pinv).

The system has solution $\iff Row(A)\subseteq Row(B)$ thus we can find a basis for $Row (B)$ and check that the condition is matched.

If $Row(A)\subseteq Row(B)$ we can obtain $X$ solving the system row by row

$$R_i(A)=R_i(X)B$$

• I think it is possible to do my calcul line by line indeed as my data lines are individuals. But I don't understand what you mean by Row(A). Apr 6, 2018 at 13:08
• @Untitpoi it is the row space of A
– user
Apr 6, 2018 at 13:11
• @Untitpoi $A=XB$ has solution if and only if each row of A can obtained by a linear combination of B rows and the combination coefficients are the row entris for X
– user
Apr 6, 2018 at 13:13

The way to think of this is as a "multiple right-hand side problem"

$$A = X B$$ can be thought of as $$\left( \begin{array}{c} a_0^T \\ a_1^T \\ \vdots \end{array} \right) = \left( \begin{array}{c} x_0^T \\ x_1^T \\ \vdots \end{array} \right) B = \left( \begin{array}{c} x_0^T B\\ x_1^T B\\ \vdots \end{array} \right)$$ where $a_i^T$ and $x_i^T$ are the rows of $A$ and $X$ indexed with $i$, respectively.

What you recognize is that you are solving many $a_i^T = x_i^T B$ problems. Transpose both sides and you get $B^T x_i = a_i$, which should look a lot more familiar, and then you can extend everything you know about solving such a system.