0

The language reference for getting parts of a matrix seems to make sense. I'm wondering why my covariance matrix behaves differently.

x1 := sigma1*2^(-1/2)*(z1re + I*z1im) 
x2 := sigma2*2^(-1/2)*(z2re + I*z2im)
x3 := sigma3*2^(-1/2)*(z3re + I*z3im)
x := {x1, x2, x3}

rvars := {z1re \[Distributed] NormalDistribution[0, 1], 
          z1im \[Distributed] NormalDistribution[0, 1], 
          z2re \[Distributed] NormalDistribution[0, 1], 
          z2im \[Distributed] NormalDistribution[0, 1],
          z3re \[Distributed] NormalDistribution[0, 1], 
          z3im \[Distributed] NormalDistribution[0, 1]}

Eargs := Outer[Times, x, Conjugate[x]]
Eresult := Expectation[Eargs, rvars]
assume := Element[{sigma1, sigma2, sigma3}, Reals]
R = FullSimplify[Eresult, assume] // MatrixForm
Part[R, 1, 1]
Part[R, 1, 1, 1]

enter image description here

For whatever reason,

Part[R,1,1]

selects the first row of the matrix while

Part[R,1,1,1]

selects the upper left element. It appears as if I have a 1-by-3-by-3 object instead of 3-by-3. Where did I goof up?

  • Because you use MatrixForm. That's only a wrapper for display. Leave it aways; it will (and does) always confuse you. – Henrik Schumacher May 20 '18 at 21:37
  • 1
    I think I learned this from @BobHanlon: wrap parentheses around the statement prior to using //MatrixForm: (R = FullSimplify[Eresult, assume]) // MatrixForm – JimB May 20 '18 at 21:39
  • Thanks both of you for the quick responses. MatrixForm was indeed the issue. @JimB your suggestion did the trick! – David Wurtz May 20 '18 at 21:50

0 Answers0