How to solve this Matrix Equation?

7 views (last 30 days)
All matrices are 2*2. A,B,C,D are known, need to solve for X.
A*X*B = diagonal matrix
C*X*D = diagonal matrix
Will this give a unique solution of X? How to solve this?
Many thanks,
Ellen
  1 Comment
Walter Roberson
Walter Roberson on 3 Jun 2011
To check: is it the *same* diagonal matrix to be reached, or potential *different* diagonal matrices?
I'm presuming here you aren't looking for the trivial X = eye(2)

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 3 Jun 2011
The solution is definitely not unique.
Let the two result matrices be [rab11,0;0,rab22] and [rcd11;0;0;rcd22]
Set rcd22 to any non-zero non-infinite value. Then, except for possible singularities,
rab11 = rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b11+b21*d12*d11*(c11*c22-c12*c21))*a12+a11*b11*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((d12*c21*b22*a22-b12*a21*d22*c22)*b11+d12*b12*b21*(-c21*a22+a21*c22))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))*(c11*c22-c12*c21)*(d11*d22-d12*d21))
rab22 = -rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b12+b22*d12*d11*(c11*c22-c12*c21))*a22+a21*b12*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((b11*d22*c22*a11-d12*c21*a12*b21)*b12-d12*b11*b22*(c22*a11-a12*c21))*a22-a12*a21*c22*b12*(b11*d22-b21*d12))*(c11*c22-c12*c21)*(d11*d22-d12*d21))
rcd11 = -rcd22*((d11*c11*(b11*b22-b12*b21)*a22-a21*c12*b12*(b11*d21-b21*d11))*a12+a11*a22*b11*c12*(b12*d21-d11*b22))/((c21*d12*(b11*b22-b12*b21)*a22-a21*c22*b12*(b11*d22-b21*d12))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))
You can see in this that rcd22 acts as an arbitrary scale factor for the other coefficients.
The X matrix then becomes
X(1,1) = (b22*a22*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b11+b21*d12*d11*(c11*c22-c12*c21))*a12+a11*b11*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((d12*c21*b22*a22-b12*a21*d22*c22)*b11+d12*b12*b21*(-c21*a22+a21*c22))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))*(c11*c22-c12*c21)*(d11*d22-d12*d21))-b22*a12*rab21-b21*a22*rab12-b21*a12*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b12+b22*d12*d11*(c11*c22-c12*c21))*a22+a21*b12*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((b11*d22*c22*a11-d12*c21*a12*b21)*b12-d12*b11*b22*(c22*a11-a12*c21))*a22-a12*a21*c22*b12*(b11*d22-b21*d12))*(c11*c22-c12*c21)*(d11*d22-d12*d21)))/((a11*a22-a12*a21)*(b11*b22-b12*b21))
X(1,2) = -(b12*a22*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b11+b21*d12*d11*(c11*c22-c12*c21))*a12+a11*b11*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((d12*c21*b22*a22-b12*a21*d22*c22)*b11+d12*b12*b21*(-c21*a22+a21*c22))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))*(c11*c22-c12*c21)*(d11*d22-d12*d21))-b12*a12*rab21-b11*a22*rab12-b11*a12*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b12+b22*d12*d11*(c11*c22-c12*c21))*a22+a21*b12*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((b11*d22*c22*a11-d12*c21*a12*b21)*b12-d12*b11*b22*(c22*a11-a12*c21))*a22-a12*a21*c22*b12*(b11*d22-b21*d12))*(c11*c22-c12*c21)*(d11*d22-d12*d21)))/((a11*a22-a12*a21)*(b11*b22-b12*b21))
X(2,1) = -(b22*a21*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b11+b21*d12*d11*(c11*c22-c12*c21))*a12+a11*b11*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((d12*c21*b22*a22-b12*a21*d22*c22)*b11+d12*b12*b21*(-c21*a22+a21*c22))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))*(c11*c22-c12*c21)*(d11*d22-d12*d21))-b22*a11*rab21-b21*a21*rab12-b21*a11*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b12+b22*d12*d11*(c11*c22-c12*c21))*a22+a21*b12*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((b11*d22*c22*a11-d12*c21*a12*b21)*b12-d12*b11*b22*(c22*a11-a12*c21))*a22-a12*a21*c22*b12*(b11*d22-b21*d12))*(c11*c22-c12*c21)*(d11*d22-d12*d21)))/((a11*a22-a12*a21)*(b11*b22-b12*b21))
X(2,2) = -(b22*a21*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b11+b21*d12*d11*(c11*c22-c12*c21))*a12+a11*b11*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((d12*c21*b22*a22-b12*a21*d22*c22)*b11+d12*b12*b21*(-c21*a22+a21*c22))*a12+a11*a22*b11*c22*(-d12*b22+b12*d22))*(c11*c22-c12*c21)*(d11*d22-d12*d21))-b22*a11*rab21-b21*a21*rab12-b21*a11*rcd22*(((c12*c21*d12*d21-c11*c22*d11*d22)*b12+b22*d12*d11*(c11*c22-c12*c21))*a22+a21*b12*c12*c22*(d11*d22-d12*d21))*(a11*a22-a12*a21)*(b11*b22-b12*b21)/((((b11*d22*c22*a11-d12*c21*a12*b21)*b12-d12*b11*b22*(c22*a11-a12*c21))*a22-a12*a21*c22*b12*(b11*d22-b21*d12))*(c11*c22-c12*c21)*(d11*d22-d12*d21)))/((a11*a22-a12*a21)*(b11*b22-b12*b21))
This was calculated using straight-forward linear algebra by multiplying appropriate inverses on both sides to get two isolated X equations, and then solve()'ing for the corresponding components to be the same.

More Answers (1)

Walter Roberson
Walter Roberson on 3 Jun 2011
No, it will not necessarily give a unique solution for X.
Consider the possibility that A*B gives a diagonal matrix, and C*D gives a diagonal matrix. Then if X is a diagonal matrix with the two diagonal elements the same, X*B would be a constant multiple of B and so A*X*B would be a constant multiple of A*B. The same X would also lead to C*X*D being a constant multiple of C*D. This will occur for any finite non-zero X of that form, so in this set of circumstances no unique X could be found.
There might be circumstances under which the solution is unique, but I do not have a feel for them at the moment.
  2 Comments
Ellen
Ellen on 3 Jun 2011
Walter,
Thanks a lot for you reply.
Here, A B C D and X are usually not diagonal matrices. And two "diagonal matries" are not necessarily the same.
Any input?
Have a nice weekend,
Ellen
Walter Roberson
Walter Roberson on 3 Jun 2011
A, B, C, and D might not be diagonal matrices, but A*B and C*D might be, I think (I'd have to double-check whether that can happen for 2x2.)
Anyhow the point is that you asked if the solution was unique, and I showed at least one case (which you do not rule out) where the solution cannot be unique.

Sign in to comment.

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!