# How to solve A=2BXB-Diag(BXB)

Given $$X,B,A \in \mathbb{R}^{p \times p}$$ how do you solve

$$A=2BXB - \text{Diag}(BXB)$$

for $$X$$? Is there a closed-form? One can assume the following: $$A,B$$ and $$X$$ are symmetric positive definite.

I can iteravitly solve the problem as follows : $$B^{-1}(A+\text{Diag}(BXB))B^{-1}/2=X_{+}$$

Note: $$Diag(BXB)$$ is a diagonal matrix containing the diagonal elements of BXB.

• What is $\text{Diag}$ in this context? – Klaas van Aarsen Dec 19 '18 at 22:15
• If "Diag" denotes the diagonal part of a matrix, then a solution exists if and only if $A$ is a symmetric matrix with a zero diagonal. In this case you may just take $X=B^{-1}(A+tI)B^{-1}$ for any $t>-\lambda_\min(A)$. – user1551 Dec 19 '18 at 22:35
• @user1551 excuse me I made a mistake in the equation. It should read $A=2BXB−Diag(BXB)$ (instead of $A=BXB−Diag(BXB)$), this has been corrected. – user28958 Dec 20 '18 at 10:46
• The user in the first comment asked you to clarify the meaning of "Diag". I think you should add a clarification in your question. – user1551 Dec 20 '18 at 10:49
• @IlikeSerena "Diag(A)" is a diagonal matrix containing the diagonal of A. – user28958 Dec 20 '18 at 10:54

Apologies, this has a trivial solution. On the diagonal, it is clear that $$A_{ii}=(BXB)_{ii}$$.

Thus $$X=B^{-1}$$(A + Diag(A))$$B^{-1}/2$$.

• Note, however, that the equation is not always solvable as $A+Diag(A)$ is not necessarily positive definite. – user1551 Dec 20 '18 at 11:31
• @user1551 apparently we can assume that $X$ is positive definite, but it is not required. Without that requirement for the solution, it is always solvable. – Klaas van Aarsen Dec 20 '18 at 12:21
• @user1551 Yes you are correct, but indeed all diagonal values of $A$ are positive, so $det(A+Diag(A)) \geq Det(A) + \Pi A_{ii} > 0$. Sorry, I didn't outline the question well enough. – user28958 Dec 20 '18 at 14:11
• @IlikeSerena $X$ is always positive definite $Det(X)=Det(B)^{-2}Det(A+Diag(A)) \geq Det(B)^{-2}(Det(A)+ \Pi A_{ii}) > 0$ – user28958 Dec 20 '18 at 14:16
• Consider $A=\begin{pmatrix}1&0&2\\0&1&0\\2&0&1\end{pmatrix}$. It has $\det A=-3$ and $\det(A+D)=0$. Both are certainly not positive definite. – Klaas van Aarsen Dec 20 '18 at 18:46

It may be easier for Readers to follow the solution if we decompose the problem into two phases.

Let $$Y = BXB$$, where $$B$$ is symmetric positive definite (and thus invertible). So if $$Y$$ is determined, then also will $$X=B^{-1}YB^{-1}$$ be determined. Furthermore $$Y$$ is symmetric if and only if $$X$$ is symmetric, and indeed $$Y$$ is symmetric positive definite if and only if $$X$$ is symmetric positive definite.

It remains to solve the simple problem:

$$A = 2Y - \operatorname{Diag} (Y)$$

The entries of $$Y$$ are easily deduced. The diagonal entries of $$Y$$ are the same as the diagonal entries of $$A$$, e.g. by taking the diagonal entries on both sides of the above matrix equation. On the other hand the off-diagonal entries of $$Y$$ are half the corrresponding off-diagonal entries of $$A$$. Thus the solution:

$$Y = \frac{1}{2} (A + \operatorname{Diag} (A))$$

If $$A$$ is symmetric positive definite, so too is $$A + \operatorname{Diag} (A)$$. Hence $$Y$$ will be symmetric positive definite if $$A$$ is, but there are slightly weaker conditions that would allow $$A$$ to be not-quite diagonally dominant and yet give $$A + \operatorname{Diag} (A)$$ positive definite.

In any case $$X$$ is symmetric positive definite if and only if $$A + \operatorname{Diag} (A)$$ is symmetric positive definite.