# How can I find a solution to this matrix equation?

$$D=X-M(X\circ P)$$ Solve for $$X$$

where

$$D, X, P$$ are vectors of size $$n$$.

$$M$$ is a matrix of size $$n \times n$$.

$$X\circ P$$ indicates element wise multiplication of $$X$$ and $$P$$ such that $$(X \circ P)_i = X_i P_i$$

I am aware that in general, some values of $$M$$ would support multiple solutions of $$X$$. But I suspect that in my cases there are unique solutions, so a strategy that finds any solution in the general case would suffice. Even some iterative algorithm would be acceptable.

For extra credit, is it possible to determine, based on $$M$$, when a unique solution exists?

• If you consider the data of $P$ as "inside your matrix" $M$, you can go back to the standard theory of linear systems. Explicitly, $X\circ P$ is equal to the matrix multiplication $diag(P) X$, where $diag(P)$ is simply the diagonal matrix with entries the coefficients of $P$, so you're asking how to solve $D= (I_n - M diag(P))X$. Commented Apr 26 at 9:10
• @AntonioLorenzin this is an awesome trick to know. I should be able to take it from here. Commented Apr 26 at 9:26

## 1 Answer

Rewrite your equation as $$D= X - M \mathcal{D}_P X$$ where $$\mathcal{D}_P = \begin{pmatrix} p_1 & 0 & \ldots \\ 0 & p_2 & \ldots \\ \ldots & 0 & p_n \end{pmatrix}$$

So the problem becomes a standard system of equations $$D=(I-M\mathcal{D}_P)X$$.

If $$I-M\mathcal{D}_P$$ is invertible, you find $$X= (I-M\mathcal{D}_P)^{-1}D$$. In this case (1 is not an eigenvalue of $$M\mathcal{D}_P$$) you have unique solution of the problem.

Otherwise, use standard linear algebra theorems to find solutions (if any, they will be infinite).