# A matrix with given row and column sums

There are a set of equations like

$A_x + A_y + A_z = P$
$B_x + B_y + B_z = Q$
$C_x + C_y + C_z = R$

Where the values of only $P, Q, R$ are known.

Also, we have

$A_x + B_x + C_x = I$
$A_y + B_y + C_y = J$
$A_z + B_z + C_z = K$

where only the values of $I, J$ and $K$ are known.

Is there any way we know the individual values of

$A_x, B_x, C_x, A_y, A_z$ and the rest?

Substituting the above equations yield the result that $I + J + K = P + Q + R$ but how can I get the individual component values? Is any other information required to solve these equations?

Here's a good complementary question. If solutions exist, how to generate all of them? Are there some algorithms?

• I suppose you mean $P+Q+R=I+J+K$ (there are no $X,Y,Z$ in the equations). This is indeed a necessary condition for the existence of a solution. Supposing that, you've got effectively $5$ linear equations (since one is dependent on the others) in $9$ unknowns; you cannot hope for a unique solution. – Marc van Leeuwen Oct 31 '13 at 9:42
• @MarcvanLeeuwen Thanks i corrected it I +J + K = P +Q +R, Also, just now a friend told that there should be 9 equations to solve and get 9 unknow's. I guess that settle's it. – Neil Oct 31 '13 at 9:51

The matrix $(\begin{smallmatrix}+1&-1\\-1&+1\end{smallmatrix})$ has all row and column sums zero. So given any matrix$~A$ with at least two rows and at least two columns, you can always add a multiple of this matrix to a $2\times2$ submatrix of $A$ to obtain a different matrix $A'$ with the same row and column sums. So for such matrices, the row and column sums never determine the matrix.
You are trying to solve $$\left(\begin{matrix} 1&1&1&0&0&0&0&0&0\\ 0&0&0&1&1&1&0&0&0\\ 0&0&0&0&0&0&1&1&1\\ 1&0&0&1&0&0&1&0&0\\ 0&1&0&0&1&0&0&1&0\\ 0&0&1&0&0&1&0&0&1 \end{matrix}\right) \left(\begin{matrix} A_x\\A_y\\A_z\\B_x\\B_y\\B_z\\C_x\\C_y\\C_z \end{matrix}\right) = \left(\begin{matrix} P\\Q\\R\\I\\J\\K \end{matrix}\right)$$ If you have any solution, it will be at least a four*-dimensional solution space, and to have a solution, necessarily the equation $P+Q+R=I+J+K$ must hold, as you already found out.
*If the LHS is $Ax$ then the dimension (if $\ge 0$) is at least $9 - {\rm rg}(A) = 9-5 = 4$, the rank is only five because the sum of the first three rows is equal to the sum of the last three rows.
• @MarcvanLeeuwen Thanks for pointing out that the Rank of the $6\times 9$ matrix is only $5$ ;) – AlexR Oct 31 '13 at 10:02