# Making the entries of a matrix positive.

Suppose I have an invertable $n \times n$ matrix, $M$, where certain entries are negative. Does there exist another invertible matrix, $P$, which i can multiply with $M$ to obtain a matrix will all positive entries?

And a followup:

Suppose I have some $n \times n$ matrix, $M$, where certain entries are negative. Does there exist another matrix, $P$, which i can multiply with $M$ to obtain a matrix will all positive entries i.e. $PM$ = abs($M$)? In cases where it does exist, how do i find it?

-
Is your matrix $M$ invertible? – user17762 Mar 11 '12 at 22:10
Yes, edited the question thx. – user996522 Mar 11 '12 at 22:11
If $M$ is invertible then I guess $P = M^{-1}$ would work... – TMM Mar 11 '12 at 22:12
You can take any invertible matrix which has all entries positive, say $B$, then if your $M$ is invertible, then set $P = BM^{-1}$. – user17762 Mar 11 '12 at 22:15
If you know $M$, then let $B = \operatorname{abs}(M)$ element-wise. Then $$P = BM^{-1}$$ will do since $PM = BM^{-1}M = BI = B$, which has all elements positive. – user2468 Mar 11 '12 at 22:23

Edit: as noted by Geoff Robinson, my solution does not meet the OP's requirement that the matrix $P$ should be invertible. As given below, $P$ is not necessarily invertible since ${\rm abs}(M)$ need not be invertible, even if $M$ is.

If $M$ is invertible, then matrix $P$ exists. For example, $$P = {\rm abs}(M)M^{-1}$$ as I illustrated in my comments. But computationally, constructing $P$ in the trivial way (${\rm abs}(M)M^{-1}$) is funny because you already computed ${\rm abs}(M)$ in order to construct $P$.

If $M$ is non-invertible, then pseudo-inverse $M^{*}$ can help you in certain cases. For example, if the columns of $M$ are orthogonal, then left inverse $M^{*}M= I$ and $P$ can be constructed. Similarly if rows of $M$ are orthogonal, and right inverse is used.

-

If you want all entries of $PM$ to be positive, then all you have to do is to find an invertible matrix $X$ (of the same size) with all entries positive. Then take $P = XM^{-1}$ and we have $PM = X.$ There is such a matrix $X$. For example, Take $X = I +J,$ where every entry of $J$ is $1.$ Since $J$ is symmetric with trace $n$ and rank $1$, its eigenvalues are $n$ (with multiplicity $1$) and $0$ with multiplicity $n-1.$ Hence $X$ has determinant $n+1$, and is invertible with all entries positive.

-
In the comments, OP wants $PM = {\rm abs}(M).$ – user2468 Mar 11 '12 at 22:29
Well, that can't be done in general. For example, if we take $M = \left( \begin{array}{clcr} 1 & -1 \\1 & 1 \end{array} \right)$, then $M$ is invertible, but ${\rm abs}(M)$ is not invertible, so there is no such invertible $P$ with $PM = {\rm abs}(M).$ – Geoff Robinson Mar 11 '12 at 22:59
If $M$ is invertible, then $P = {\rm abs}(M)M^{-1}$ exists (and unique at least over fields of characteristic $= 0$). And for the example you had, take $P = \begin{pmatrix} 0 & 1 \\ 0 & 1 \end{pmatrix}$, then $PM = {\rm abs}(M)$. – user2468 Mar 11 '12 at 23:03
But the OP wanted $P$ invertible, and that can't be done. – Geoff Robinson Mar 11 '12 at 23:12
Ops. Sorry. I totally forgot that part about $P$ being invertible. – user2468 Mar 11 '12 at 23:15