Message Boards Message Boards

0
|
17873 Views
|
39 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Invert a 2x2 matrix with 2x2 matrix elements?

Posted 6 years ago

If this is my matrix a as follows: a00 a01 a10 a11

Element a00 would be comprised of a matrix b as follows: b00 b01 b10 b11

And so on ...

I want to solve my A matrix using Mathematica algorithm.

Thanks for your help.

Stan

POSTED BY: stan gianzero
39 Replies
Posted 5 years ago

These results are extremely helpful. Please allow me some time to digest them. Thanks ...Stan

POSTED BY: stan gianzero

A quite general solution to this problem is given here

https://community.wolfram.com/groups/-/m/t/1732127

POSTED BY: Hans Dolhaine
Posted 5 years ago

Hans, You have made an immeasurable difference in my work. As I have said before the error in the signs of the reflection and transmission coefficients is totally on my side. After sending you the analysis up to the point in which I needed your help should show you that there are many places in which I could have made a mistake. I still have not resolved this issue but I will. The other issue that I had is in understanding how you arrived at the inverse matrix. I think this was hinted out in your first example called Has_example.nb. I modified this and spelled out the details to my satisfaction.That is, after showing the details I am almost entirely clear on how you arrived at the solution. Please do not trouble yourself in my lack of understanding. Remember, I have been retired for 6 years and there is no urgency for my having this understanding but much appreciation for your help. Regards...Stan

POSTED BY: stan gianzero

Hello Stan,

I refer to your text in the notebook Hans_ Example_ Comments.nb given in your last post.

...... , why does it not make the following simplifications?

Because your A, B, C and D are not matrices. matmul2 operates on (square) matrices, whose elements are matrices themselves. Your M and G are "normal" matrices (you did not define A, B and so as matrices). The product of two such "normal" matrices is given by M . G (note the full-stop, which is an abbreviation for the function Dot - see Help ) or Dot[M,G]. Along the same lines : if there is A^(-1) and A is a matrix you should use Inverse[A] instead of A^(-1) .

Try

Dot[M,G]//FullSimplify
MatrixForm[%]

.....you kept refering to wcom20190424 that is obviously the date for an \ earlier mailing, and again I did (not?) know how to find it.

You can find it in this thread , somewhere above. But I attach it here again. Do you know how to open such an attachment?

Did you read my last post? I checked the info given in "Abbreviated ...." and found that the "correct inverse" is the same as Ainv, which I calculated earlier. So with respect to the problems with signs in tau and gamma there is something wrong elsewhere.

Greetings, Hans

Attachments:
POSTED BY: Hans Dolhaine
Posted 5 years ago

Hans, I decided to return to the beginning. Please look at my attachment, since it will help you understand why I have been in the dark for so long. Stan

POSTED BY: stan gianzero

Hello Stan,

I did the work and "translated" the matrices you gave in your notebook "Abbreviated solution..." again, and also your "correct inverse". See the notebook attached (at the very end).

The result: Your matrices A and B are correct, and your "correct inverse" is equal to the inverse mAinv of A that I calculated.

Multiplying the "correct inverse" to your matrix B gives the same problems with the signs of gammas and taus. Of course, as "correct inverse" = mAinv.

So, it seems that there is a problem somewhere else.

Regards, Hans

Attachments:
POSTED BY: Hans Dolhaine

Hello Stan

Can you show the specific steps so I can better understand how you arrived at your solution.

I noted all the steps you ask for in the notebook wcom20190507.nb attached to a post above. Did you ever look into this notebook?

Recently I tried to "translate" the matrix A you gave in your notebook "Abbreviated solution...." to a more readable form, but got somehow lost with the large numbers of indices and variables. Besides, you use sometimes an index i and then I (capital i) . Is this a typo? Are i and I essentially the same?

I think you should look if your matrices A and B are correct.

Regards, Hans

POSTED BY: Hans Dolhaine
Posted 5 years ago

Hans, Please look at my attachment and I promise I will not burden you with any more questions. Regards...Stan

Attachments:
POSTED BY: stan gianzero
Posted 5 years ago

Hans, All your results are correct. They error must be on my side. I have furnished you with the complete problem up until taking the inverse becomes central. i simply do not want to put you out any longer. The only thing that I would like to have is a description of the manner you developed the inverse for my own edification. Thank you very much again. I hope that someday I may be able to assist you. Stan

POSTED BY: stan gianzero

Stan,

I don' t know what to do now, I am helpless. You gave a matrix of matrices A and asked for the inverse Ainv of A. I calculated Ainv, and indeed A.Ainv = Ainv.A = 1 (this 1 being {{1, 0}, {0, 1}}, and here 1 and 0 being (2, 2) - matrices, 1 = Identiymatrix[2] and 0 = {{0, 0}, {0, 0}}.) So I dare say your problem is solved.I have no idea what is it about the signs of your taus and gammas.In the notebookyou sent you give "THE CORRECT INVERSE" wich contains quite a lot of symbols. I suggest you abbreviate them in an appropriate way and check if it is really the Inverse of your matrix A. Perhaps it would be helpfull to execute (in the notebook wcom20190424 )

mAinv // FullSimplify // MatrixForm

In fact I think, Ainv and "THE CORRECT INVERSE" are very simmilar. Compare the two.

Regards, Hans

POSTED BY: Hans Dolhaine
Posted 6 years ago

Hans, You have been most helpful, but I feel that the entire problem that I am attempting to solve would not be helpful to you. Consequently, I am sending a small portion of the solution that leads up to the area of difficulty. I am not ignoring you and I need some time to sort things out. In any event, I still would like to know how you arrived at your inverse solution. Many thanks. Stan PS I have added on your correct expressions for the inverse to further clarify the differences.

Attachments:
POSTED BY: stan gianzero
Posted 6 years ago

Hans, You have been most helpful, but I feel that the entire problem that I am attempting to solve would not be helpful to you. Consequently, I am sending a small portion of the solution that leads up to the area of difficulty. I am not ignoring you and I need some time to sort things out. In any event, I still would like to know how you arrived at your inverse solution. Many thanks. Stan PS I have added on your correct expressions for the inverse to further clarify the differences.

Attachments:
POSTED BY: stan gianzero
Posted 6 years ago

Hans, You have been most helpful, but I feel that the entire problem that I am attempting to solve would not be helpful to you. Consequently, I am sending a small portion of the solution that leads up to the area of difficulty. I am not ignoring you and I need some time to sort things out. In any event, I still would like to know how you arrived at your inverse solution. Many thanks. Stan PS I have added on your correct expressions for the inverse to further clarify the differences.

Attachments:
POSTED BY: stan gianzero
Posted 6 years ago

Hans, You have been most helpful, but I feel that the entire problem that I am attempting to solve would not be helpful to you. Consequently, I am sending a small portion of the solution that leads up to the area of difficulty. I am not ignoring you and I need some time to sort things out. In any event, I still would like to know how you arrived at your inverse solution. Many thanks. Stan PS I have added on your correct expressions for the inverse to further clarify the differences.

Attachments:
POSTED BY: stan gianzero
Posted 6 years ago

Hans, You have been most helpful, but I feel that the entire problem that I am attempting to solve would not be helpful to you. Consequently, I am sending a small portion of the solution that leads up to the area of difficulty. I am not ignoring you and I need some time to sort things out. In any event, I still would like to know how you arrived at your inverse solution. Many thanks. Stan

Attachments:
POSTED BY: stan gianzero

Hello Stan,

At this stage, what would be most helpful for me is to have the solution that you obtained in a separate file that I can see.

I attach a notebook in which the algebra I used is written down. And again: have a close look at the notebook wcom20190424 (attached to a post somewhere above). Your problem is solved there. I don't know what is happening to the signs of your taus and gammas. Please make sure that your matrix A is correct.

Regards, Hans

Attachments:
POSTED BY: Hans Dolhaine
Posted 6 years ago

Hans, Once again, I sincere thank you for your assistance. I have already gone through some of your suggestions and am completely satisfied. Again, the different signs in my taus and gammas I will study because the errors must be on my end. However, I would like to know how you arrived at a Left or Right inverse. Did it have something to do with your first example? I will attach that example for your perusal. If I am asking too much of you, please direct me to a reference. Regards...Stan

Attachments:
POSTED BY: stan gianzero

Hi Stan,

The multiplier Zin appeared in some earlier posts of yours. I omitted it in the notebook wcom20190424, which is attached to a post above. I arrived at the inverse matrix of your matrix of matrices by multiplying your matrix with another one and setting the matrix-elements to 1 and 0 (this being matrices) and doing some (matrix)algebra. I can show you the details, but would prefer to send you an email. (Today I know that this is not the most general expression for an inverse, but that doesn't matter here) .So I got the inverse of your matrix A, and it works - look at the statement

matmul2[mAinv, mA]

in the notebook wcom20190424. And then I muliplied it to your matrix B. I have to take the results as they are. If you are not happy with the signs of numerators/denominators in your taus and gammas I would suggest that you please check your matrices A and B.

POSTED BY: Hans Dolhaine
Posted 6 years ago

Hans, I think that I have implemented your code correctly. However, upon execution there appear to be some differences in the final manipulation for the so-called Fresnel coefficients. Please take a look at what I have and if possible explain to me how you arrived at the inverse matrix. If that is too cumbersome please point me to some helpful references, Thank you so much, Stan

Attachments:
POSTED BY: stan gianzero
Posted 6 years ago

Hans, I think that I have implemented your code correctly. However, upon execution there appear to be some differences in the final manipulation for the so-called Fresnel coefficients. Please take a look at what I have and if possible explain to me how you arrived at the inverse matrix. If that is too cumbersome please point me to some helpful references, Thank you so much, Stan

Attachments:
POSTED BY: stan gianzero
Posted 6 years ago

Hans, My humblest apologies. First of all, I have never used a chat room before so I was unable to reply immediately. Let's start from the beginning. You sent me an example in our first discussion and I was unable to find how this was connected to finding an inverse. I did not answer since I was unsure how to do this so I continued with my approach by using a scalar representation hoping that this would lead me to a matrix solution. Obviously, I could not do this successfully. After communicating with me again you sent me a solution that I claimed was too large such that Mathematica could not express it in matrix form. I guess It did not work because I had not used matmul2. I simply saw what you have done and type matmul2 and it did not apply this procedure since I did not have access to the self-written procedure. At this stage, what would be most helpful for me is to have the solution that you obtained in a separate file that I can see. I will them be able to the proof of it the inverse and also see the multiplication by the B matrix that lead to the so-called Fresnel equations in electromagnetics. Finally, I need to understand how you arrived at your solution. I would like you to understand the exercise in inverting a matrix was a small part of a large problem that I solved a long time ago. I was simply looking at this problem to keep my mind alert. Presently, I am 81 years old and I am asking that you be patient with the elderly. Thank you very much. Stan P.S. My computer crashed and I was unable to respond earlier.

POSTED BY: stan gianzero

And there is a typo. You speak of matmult2, but its name in the notebook is matmul2.

POSTED BY: Hans Dolhaine

Hi Stan,

please have a close look at the notebook I posted at last ( wcom20190424.nb - see above) Everything is explained in the notebook. Go through it step by step, and if you have questions, please feel free to write me an email for further details ( h.dolhaine@gmx.de). (I suggest you load the notebook and execute it: Evaluation - Evaluate Notebook) and see what happens.

You can't find anything about matmult2 in Help, because it is a self-written procedure to do a matrixmultiplication (I assume, you know the rules how to multiply two matrices with numbers as elements. matmult2 is written to cope with matrices which have matrices as elements. It is a function (see the := sign) with two parameters which are supposed to be matrices. See above:

matmul2[a_, b_] := Module[{},
  res = Table[
    Sum[a[[i, k]].b[[k, j]], {k, 1, 2}], {i, 1, 2}, {j, 1, 2}];
  FullSimplify[res]
  ]  

You have to execute this statement prior to any use of matmult2. Obviously it is missing in one or both of the notebooks you sent, and without it all the rest will not work. That is the reason you get a lengthy result when using it: it is simply not available and nothing is done.

So again, have a close (!) look at wcom20190424.nb and see if that helps.

Kind regards, Hans

POSTED BY: Hans Dolhaine
Posted 6 years ago

Hans, My idea in finding an inverse was to build upon a scalar solution and mimic the steps with the proper matrix algebra. That did not work! Now, if you do not mind let us return to your first letter. i called it Hans_Example.nb. I simply did not know what you were showing me. Next when you addressed my specific matrix and showed what you must do, I could not understand the results because Mathematica could not show me the results in matrix form. That is what I meant when saying the matrix was too large. Finally, I looked up under Help what matmult2 meant and could not find an answer. I would appreciate any help you can give. Stan

POSTED BY: stan gianzero
Posted 6 years ago

Hans, My idea in finding an inverse was to build upon a scalar solution and mimic the steps with the proper matrix algebra. That did not work! Now, if you do not mind let us return to your first letter. i called it Hans_Example.nb. I simply did not know what you were showing me. Next when you addressed my specific matrix and showed what you must do, I could not understand the results because Mathematica could not show me the results in matrix form. That is what I meant when saying the matrix was too large. Finally, I looked up under Help what matmult2 meant and could not find an answer. I would appreciate any help you can give. Stan

POSTED BY: stan gianzero
Posted 6 years ago

Hans, My idea in finding an inverse was to build upon a scalar solution and mimic the steps with the proper matrix algebra. That did not work! Now, if you do not mind let us return to your first letter. i called it Hans_Example.nb. I simply did not know what you were showing me. Next when you addressed my specific matrix and showed what you must do, I could not understand the results because Mathematica could not show me the results in matrix form. That is what I meant when saying the matrix was too large. Finally, I looked up under Help what matmult2 meant and could not find an answer. I would appreciate any help you can give. Stan

POSTED BY: stan gianzero
Posted 6 years ago

Hans, My idea in finding an inverse was to build upon a scalar solution and mimic the steps with the proper matrix algebra. That did not work! Now, if you do not mind let us return to your first letter. i called it Hans_Example.nb. I simply did not know what you were showing me. Next when you addressed my specific matrix and showed what you must do, I could not understand the results because Mathematica could not show me the results in matrix form. That is what I meant when saying the matrix was too large. Finally, I looked up under Help what matmult2 meant and could not find an answer. I would appreciate any help you can give. Stan

POSTED BY: stan gianzero

Hello Stan,

in the meantime I could show that despite the elements of your matrix being matrices which products might not commute the left- and right - inverse of your matrix are equal. So once again:

If your matrix is

A = { { a, b }, { c, d } }

and a, b, c and d are (invertible) matrices themselves, then

A^(-1) = { {  Inverse[ a - b . Inverse[d] . c],  Inverse[ c - d . Inverse[b] . a] },
           {  Inverse[ b - a . Inverse[c] . d],  Inverse[ d - c . Inverse[a] . b ] } }

and

A^(-1) . A  =  A .  A^(-1)  = Identity  =  { { 1 , 0 }, { 1, 0  } }

with 1 and 0 the appropriate Identity- and Zero-Matrix respectively.

POSTED BY: Hans Dolhaine

Hello Stan,

I looked at your file, but I am afraid I do not understand what you are doing there. I think using scalars is absolutely not appropriate.

As multiplication of matrices is associative left- and right-inverse should be equal, and indeed they are.

your inverse either Left or Right does not yield a unit matrix when multiplied by the original matrix.

Yes, it does. Look at the notebook. Are you sure that you used the multiplication for matrices whose elements are matrices themselves (matmul2) ?

I attach another notebook in which the inverse of your matrix is given and also the product you asked for. The m = 0 - case is included. I hope this is helpful.

Attachments:
POSTED BY: Hans Dolhaine
Posted 6 years ago

Hans, What I meant by the matrix being so large is that MatrixForm could not be executed so I cannot even read the results. So, if your take a simple case, m=0, your could display the MatrixForm and your inverse either Left or Right does not yield a unit matrix when multiplied by the original matrix. I am sure that I am not understanding your results. This is not your fault but just mine. Please take a look at my attachment. Thanks! Stan

POSTED BY: stan gianzero
Posted 6 years ago

Hans, What I meant by the matrix being so large is that MatrixForm could not be executed so I cannot even read the results. So, if your take a simple case, m=0, your could display the MatrixForm and your inverse either Left or Right does not yield a unit matrix when multiplied by the original matrix. I am sure that I am not understanding your results. This is not your fault but just mine. Please take a look at my attachment. Thanks! Stan

POSTED BY: stan gianzero

Hello Stan,

frankly spoken I thought your problem is solved. What do you mean by "the matrix was so large"? And note: in general there is no simple inverse of your A-Matrix. But there are in general two, a right- and a left-inverse. Your equations should show which is needed.

I wrote about this in the notebook you sent and attach the modified version to this post. Please let me know if it is helpful.

Attachments:
POSTED BY: Hans Dolhaine
Posted 6 years ago

Hans, Since the matrix was so large Mathematica was unable to print it a matrix. So, I simplified the results for the m=0 case and tested the inverse and the product of the inverse and the original matrix was NOT a unit matrix. I have more send you, but I will do this at a later date.

See my attachment.

Stan

Attachments:
POSTED BY: stan gianzero

Multiplication of (2,2)matrices of (2,2)matrices

matmul2[a_, b_] := Module[{},
  res = Table[
    Sum[a[[i, k]].b[[k, j]], {k, 1, 2}], {i, 1, 2}, {j, 1, 2}];
  FullSimplify[res]
  ]

A-matrix

ma = {
    {1, 0},
    {0, 1}
   } ;
mb =  {
    {-1, 0},
    {0, -1}
   } ;
mc =  {
    {-Zout2, m},
    {m, -Yout2}
   } ;
md =  {
    {Zin1, m},
    {m, Yin1}
   } ;
mA = {
    {ma, mb},
    {mc, md}
   } ;
% // MatrixForm

Its (Left)inverse

mp = Inverse[mc - md.Inverse[mb].ma];
mr = Inverse[md - mc.Inverse[ma].mb];
mo = -mp.md.Inverse[mb];
mq = -mr.mc.Inverse[ma];
LinvA =  {
    {mo, mp},
    {mq, mr}
   } ;

check this

matmul2[LinvA, mA];
% // MatrixForm

The B-matrix

 mB = {{{{Zin, 0}, {0, Zin}}, {{-Zin, 0}, {0, -Zin}}}, 
{{{-Zin Zout1, m Zin},{m Zin, -Yout1 Zin}}, {{Zin Zin2, m Zin}, {m Zin, Yin2 Zin}}}};
    % // MatrixForm

and the result

matmul2[LinvA, mB];
% // MatrixForm
POSTED BY: Hans Dolhaine

Hello Stan,

I am not quite sure whether I understand what you really want to do. I attach a notebook, perhaps this is useful for you. Greetings, Hans

Attachments:
POSTED BY: Hans Dolhaine
Posted 6 years ago

Hans, Thank you for responding to my question. I too am retired 6 years ago. Here is my matrix. A={{I.-I],{T,R}} where I={{1,0},{0,1}};T={{-Zout2},{m}},{{m,-Yout2}};R={{Zin1,{m}},{m,Yin1}}; As you can readily see that matrix elements in my matrix are 2x2 matrices themselves. I want to establish that the inverse of my matrix times the original matrix is a unit matrix with 2x2 elements. Thereafter I want to multiply my inverse matrix with a second matrix with elements that are also 2x2 matrices. In particular, B={{1,1} I do not know how to edits anything that I am saying, so I am attaching a file that specifies the matrix and another operation dealing with the matrix. Stan

Attachments:
POSTED BY: stan gianzero

I think you'll have to be more specific to be able to get an answer. Are you familiar with tensor algebra? If so, can you be more explicit about what you're asking for? You're asking how to get an inverse of an order 3 tensor and I don't know that I've ever seen that before or would know what that is.

POSTED BY: Sean Clarke

Assume your matrix is

{ {A, B}, {C, D} } and A, B, C, D are "wellbehaved" 2x2 matrices (meaning inverses and so do exist.

Then look what happens if multiplying your matrix from the right with

{ {U, V}, {X, Y} }

where

X = ( B - A C^(-1) D )^(-1)
Y = ( D - C A^(-1) B )^(-1)
U = - C^(-1) D X
V = - A^(-1) B Y
POSTED BY: Hans Dolhaine

There appears to be a problem with this approach. If my simple understanding of matrices is correct, you cannot invert a matrix if there is a matrix inside of it because the inverse of a matrix and the original matrix multiply (A A^-1 or A^-1 A) to produce the identity matrix, perhaps there is something else you are wanting? Although I do find the idea of matries within matrices tedious and entertaining.

POSTED BY: Joshua Champion
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract