Search code examples
matlabmathmatrixinverse

Multiplication of matrices involving inverse operation: getting infinity


In my earlier question asked here : Matlab: How to compute the inverse of a matrix

I wanted to know how to perform inverse operation

A = [1/2, (1j/2), 0;
     1/2, (-1j/2), 0;
     0,0,1]

 T = A.*1

 Tinv = inv(T)

The output is Tinv =

   1.0000             1.0000                  0          
        0 - 1.0000i        0 + 1.0000i        0          
        0                  0             1.0000 

which is the same as in the second picture. The first picture is the matrix A

T

T inverse

However for a larger matrix say 5 by 5, if I don't use the identity, I to perform element wise multiplication, I am getting infinity value. Here is an example

A = [1/2, (1j/2),  1/2, (1j/2),  0;
     1/2, (-1j/2), 1/2, (-1j/2), 0;
     1/2, (1j/2),  1/2, (1j/2),  0;
     1/2, (-1j/2), 1/2, (-1j/2), 0;
     0,    0 ,     0 ,  0,      1.00
          ];

T = A.*1

Tinv = inv(T)
Tinv =

   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf

So, I tried to multiply T = A.*I where I = eye(5) then took the inverse Eventhough, I don't get infinity value, I am getting element 2 which is not there in the picture for 3 by 3 matrix case. Here is the result

Tinv =

   2.0000                  0                  0                  0                  0          
        0                  0 + 2.0000i        0                  0                  0          
        0                  0             2.0000                  0                  0          
        0                  0                  0                  0 + 2.0000i        0          
        0                  0                  0                  0             1.0000    

If for 3 by 3 matrix case, I use I = eye(3), then again I get element 2.

Tinv =

   2.0000                  0                  0          
        0                  0 + 2.0000i        0          
        0                  0             1.0000 

What is the proper method?

Question : For general case, for any sized matrix m by m, should I multiply using I = eye(m) ? Using I prevents infinity values, but results in new numbers 2. I am really confused. Please help

UPDATE: Here is the full image where Theta is a vector of 3 unknowns which are Theta1, Theta1* and Theta2 are 3 scalar valued parameters. Theta1 is a complex valued number, so we are representing it into two parts, Theta1 and Theta1* and Theta2 is a real valued number. g is a complex valued function. The expression of the derivative of a complex valued function with respect to Theta evaluates to T^H. Since, there are 3 unknowns, the matrix T should be of size 3 by 3.

pic new


Solution

  • your problem is slightly different than you think. The symbols (I, 0) in the matrices in the images are not necessarily scalars (only for n = 1), but they are actually square matrices.

    I is an identity matrix and 0 is a matrix of zeros. if you treat these matrix like that you will get the expected answers:

    n = 2; % size of the sub-matrices
    I = eye(n); % identity matrix
    Z = zeros(n); % matrix of zeros
    % your T matrix
    T = [1/2*I, (1j/2)*I, Z;
        1/2*I, (-1j/2)*I, Z;
        Z,Z,I];
    % inverse of T
    Tinv1 = inv(T);
    % expected result
    Tinv2 = [I,I,Z;
        -1j*I,1j*I,Z;
        Z,Z,I];
    % max difference between computed and expected
    maxDist = max(abs(Tinv1(:) - Tinv2(:)))