I have a matrix which I know to be positive definite. The entries of the matrix might be complicated but they are all real. To find an expression for the square root of this matrix (i.e., SS = A) I'm trying :

Ftemp = {{F11, F12, F13, 0, 0}, 
         {F12, F22, 0, 0, 0}, 
         {F13, 0, F33, 0,F35}, 
         {0, 0, 0, F44, F45}, 
         {0, 0, F35, F45, F55}}

All the elements in the matrix real. We know there exists a positive square root for this matrix , however , it will be horrible analytically. What I would like to know however, is which entries in the resulting solution will be different from zero (and thus which entries will be zero).

  • 1
    $\begingroup$ As David pointed out, you will get a huge output. I looked at parts of the output, and it appears that the only terms which are not functions of the matrix entries look like Root[some cubic polynomial,integer between 1 and 3]. You can simplify that part further using Solve instead of Root. $\endgroup$ – Michael Wijaya Feb 8 '12 at 4:04
  • $\begingroup$ Wait... your matrix is unsymmetric?! Your results are certainly going to be complicated. Where did this matrix come from? $\endgroup$ – J. M.'s discontentment Feb 8 '12 at 15:26
  • $\begingroup$ It may help to observe that you can compute the square root by finding a (forth degree in the 5x5 case) polynomial P so that P[lamda] = Sqrt[lamda] for all eigenvalues lamda, and then the matrix square root will be P(F), where you replace the constant term by a multiple of the identity matrix and where you replace the powers by matrixpowers. $\endgroup$ – J Tyson Feb 16 '18 at 2:14

Are all of the Fs real? If so, try this:

Assuming[{F11, F12, F13, F21, F22, F24, F33, F35, F44, F45, F53, F54, 
   F55} \[Element] Reals, MatrixPower[Ftemp, 1/2]]

You'll get an answer, but it'll be ugly...

You can use Position to test for zero elements like this (in this case I'm applying it to your original matrix to show that it works):

{{1, 4}, {1, 5}, {2, 3}, {2, 4}, {2, 5}, {3, 2}, {3, 4}, {4, 1}, {4, 
  2}, {4, 3}, {5, 1}, {5, 2}}

So for the matrix you're interested in:

FtempInv = Assuming[{F11, F12, F13, F21, F22, F24, F33, F35, F44, F45, F53, 
     F54, F55} \[Element] Reals, MatrixPower[Ftemp, 1/2]];

Unfortunately, when I do that MMA spends a great deal of time thinking and I have yet to see an answer. There may be better test to use here than PossibleZeroQ; if so, I'm sure someone else will suggest one.

It turns out that PossibleZeroQ is Listable, so you can you just do


But that doesn't solve the speed problem...

I let PossibleZeroQ[FtempInv] run for a while. Here's what I got:

{{False, False, False, False, False}, {False, False, False, False, False}, {False, False, False, False, False}, {False, False, False, False, False}, {False, False, False, False, False}}

| improve this answer | |
  • 1
    $\begingroup$ Actually, I get the same answer regardless of whether or not I assume the elements are real. I wonder if you're running into memory problems or if you're using an older version of Mathematica? I'm using 8.0.4. $\endgroup$ – Cassini Feb 8 '12 at 1:19
  • $\begingroup$ Hi guys, this was my post originally but I lost my account name form yesterday. The matrix comes from the solution to a algebraic ricatti equation. Now, I know F is positive semi definite since it comes from some transition and diffusion matrices in a statespace representation. Obviously this is going to be an ugly output, but thinking about it , I only need to know which elements of the solution are different from zero. $\endgroup$ – PaulW Feb 8 '12 at 21:04
  • $\begingroup$ Is there a mapping rule I can use to test this? $\endgroup$ – PaulW Feb 8 '12 at 21:15
  • $\begingroup$ I'm afraid I don't understand your question. Test what? $\endgroup$ – Cassini Feb 9 '12 at 1:49
  • 1
    $\begingroup$ If the entries of the original matrix are all exact numbers, I'd suggest processing the output of MatrixPower[] with RootReduce[] before submitting to Position[]. $\endgroup$ – J. M.'s discontentment Feb 9 '12 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.