# How to find the set of solutions of $Ax=By$ for $A,B$ matrices?

Let $$A,B$$ be arbitrary matrices with the same number of rows.

How can we find the set of solutions $$x,y$$ to the matrix equation $$Ax=By$$?

I understand that this problem is probably related to that of finding a basis for the intersection of two vector spaces, which can be solved as shown in the answers to this question. However, the methods outlined there work when $$A,B$$ have as columns orthonormal sets, and therefore $$\operatorname{Ker}(A)=\operatorname{Ker}(B)=\{0\}$$, which needs not be the case here.

How is this kind of equation solved in the general case?

## 3 Answers

construct the matrix (using blockmatrices): $$M = \begin{pmatrix} A& -B\\ \end{pmatrix}$$ and solve the system $$Mz = 0$$ where $$z = \begin{pmatrix} x_1\\ \vdots\\ x_n\\ y_1\\ \vdots\\ y_m\end{pmatrix}$$.

The problem makes sense only if $$A$$ is $$n\times m$$ and $$B$$ is $$n\times k$$, i.e., $$A$$ and $$B$$ must have the same number of rows. Let $$C$$ be the $$n\times(m+k)$$ matrix obtained by juxtaposing $$A$$ and $$-B$$. Then The solutions $$z$$ of $$Cz=0$$ correspond to solutions of the original claim, namely the top $$m$$ components are your $$x$$ and the bottom $$k$$ components are $$y$$.

You can solve for the column vector x if the column vector $$y$$ is given.

Once you have $$y$$ you have the vector $$b=By$$ and solve the system $$Ax=b$$ For $$x$$

• doesn't this assume that I know possible solutions of the equation? What is there to ensure that $Ax=By$ has a solution for a given $y$? – glS Aug 13 at 14:19
• The matrix $A$ should be non singular in order to have a unique solution – Mohammad Riazi-Kermani Aug 13 at 14:27
• sure, but you cannot know whether a candidate $y$ is such that there is an $x$ satisfying $Ax=By$. Both $x$ and $y$ are the unknown variables here – glS Aug 13 at 14:46
• Once $A$ is non singular the system $Ax=b$ will have a solution regardless of $y$ so $x$ is found in terms of $y$ – Mohammad Riazi-Kermani Aug 13 at 14:56
• but $A,B$ need not be square matrices. Say for example $B$ is $10\times 2$ and $A$ is $10\times4$. Then given $b=B y$ there is a solution for $Ax=b$ only if $b$ is in the range of $A$, right? So I need to pick a $y$ such that this is true. How do you do that? – glS Aug 13 at 16:02