# Matrix equation with zero diagonal constraint

I have a known matrix $A$ with entries $a_{ij}$ and would like to know matrix $B$ with entries $b_{ij}$ of the same dimension which entries obey:

\begin{equation} b_{ij} = 1 + \sum_{k \neq j} a_{ik} b_{kj} \qquad\text{for $i \neq j$} \end{equation} and \begin{equation} b_{ii} = 0 \qquad\text{for all $i$.} \end{equation}

Is there a simple matrix form for these equations?

The approach I tried only works with out restrictions as explained below.

If it weren't for the restriction of the zero diagonal and the restriction in the sum $k \neq j$. I would have the set of equations:

\begin{equation} b_{ij} = 1 + \sum_{k} a_{ik} b_{kj} \end{equation}

which by definition of matrix product can be expressed as the matrix equation:

$$B = J + AB$$

where $J$ denotes the matrix with all entries equal to $1$ and of same dimensions as $A$ and $B$. One could obtain matrix $B$ if matrix $(I - A)$ is invertible by:

$$B = (I - A)^{-1}J$$

where $I$ is the identity matrix.

Is there a similar matrix equation that corresponds the problem with restrictions in the first equation?

Since $b_{j,j}=0$ for each$~j$, one has $\sum_{k \neq j} a_{i,k} b_{k,j} =\sum_k a_{i,k} b_{k,j}$, and your analysis then applies to the problem. Quite likely $(I - A)^{-1}J$ has some nonzero entries on the main diagonal, in which case your problem has no solutions.
• I understand that if $(I - A)^{-1}J$ had zero entries in the main diagonal the problem would be solved. However even if it has non-zero entries on the main diagonal, couldn't there exist another solution? If $A$ has dimension $n$, we have $n \times n - n$ variables and the same number of equations, so I think there should be a solution to the problem. – RM- Apr 10 '17 at 10:16
• I think your own argument shows there can be no other solutions. Note that you have got $n^2$ equations, not $n^2-n$, since for $i=j$ your equation still gives a constraint on the values $b_{k,j}$ even if the left hand side is $b_{i,i}=0$. – Marc van Leeuwen Apr 10 '17 at 10:22
• Yes, we have $n$ equations which say $b_{i,i} = 0 \forall i$. However these do not constrain the equations for $b_{i,j} \ i \neq j$ since the sum excludes all terms $b_{i,i}$. Therefore, I think, we can focus on a system of $n^2 - n$ equations. – RM- Apr 10 '17 at 10:50
• If you want to count the $b_{i,i}=0$ as separate equations, and the $b_{i,i}$ therefore as separate variables, then you've got $n^2+n$ equations in $n^2$ unknowns. The point is the the displayed equation does not exclude $i=j$, so it is a set of $n^2$ equations by itself. However you look at it, it is an overdetermined system. Unless of course you decide to add a condition $i\neq j$ to the displayed equation. – Marc van Leeuwen Apr 10 '17 at 11:32
• Ah okay, yes. I edited the question so that it has condition $i \neq j$. Now the problem should have a solution, right? – RM- Apr 10 '17 at 11:40