matrices

*To*: mathgroup at yoda.physics.unc.edu*Subject*: matrices*From*: Cetin Cetinkaya <cetin at acm0.me.uiuc.edu>*Date*: Tue, 30 Mar 1993 14:18:10 -0600

I am planning to do some perturbation analysis for the equations which involves matrices and scalars. My question is simple: Is there any way to have MMA to distingush matrices form scalars and vice versa? Let me give an example to make the question clearer: Let A and B be matrices of the same dimensions and let eps to be a scalar. To calculate (A + eps B)^2, in MMA I can write: In[124]:= A=.;B=.;Distribute[(A + eps B).(A + eps B)] 0. Second 2163.248 KByte Out[124]= A . A + A . (B eps) + (B eps) . A + (B eps) . (B eps) But I would like to collect the terms with respect to eps, that is, the form I want is: A.A + eps ( A.B + B.A ) + eps^2 B^2. I have tried Collect[], of course it did not work, In[125]:= Collect[%,eps] 0. Second 2163.696 KByte Out[125]= A . A + A . (B eps) + (B eps) . A + (B eps) . (B eps) If MMA could see the difference between a matrix and a scalar, this could have been possible, I think. Thank you in advance, cetin