Re: How to simplify transposed terms?

*To*: mathgroup at smc.vnet.net*Subject*: [mg2720] Re: How to simplify transposed terms?*From*: rubin at msu.edu (Paul A. Rubin)*Date*: Sat, 9 Dec 1995 01:55:47 -0500*Organization*: Michigan State University

In article <49do0r$8a6 at dragonfly.wri.com>, Bernd.Cebulski at e-technik.tu-chemnitz.de (Bernd Cebulski) wrote: ->How could I tell MMA to simplify -> ->Transpose[A*B] ---> Transpose[B]*Transpose[A] ->Transpose[A+B] ---> Transpose[A]+Transpose[B] -> ->And how could I declare 'A' as a matrix without giving values to it, so that ->calculations like the 2 examples could be made. Of course they should be a ->little more complicated ... -> ->Tnx, -> -> Bernd. -> -> -----------------------------------------------. ->| Chemnitz, University of Technology | ->|--- bernd.cebulski at e-technik.tu-chemnitz.de ---| ->| Phone: +49 (371) 5313318 | ->| Fax: +49 (371) 5313361 | ->| DL 1 DTP | ->`------------------------------------------------ First step, unprotect Transpose and add the desired properties: Unprotect[Transpose]; Transpose[ A_ B_ ] := Transpose[ B ] Transpose[ A ] /; MatrixQ[ A ] && MatrixQ[ B ] Transpose[ A_ + B_ ] := Transpose[ A ] + Transpose[ B ] /; MatrixQ[ A ] && MatrixQ[ B ] Protect[ Transpose ]; Note that I've restricted the properties to apply only when both arguments are recognizable as matrices. (You could also do this with the alternate notation Transpose[ A_?MatrixQ B_?MatrixQ ] := Transpose[ A ] Transpose[ B ] and similarly for distribution across addition.) The next step is to define symbols to be matrices using up-values. Note that for undefined A and B, the properties are not invoked: In[]:= Transpose[ A B ] Out[]= Transpose[A*B] In[]:= Transpose[ A + B ] Out[]= Transpose[A + B] But if we define A and B to be matrices then the properties are applied: In[]:= A /: MatrixQ[ A ] := True In[]:= B /: MatrixQ[ B ] := True In[]:= Transpose[ A B ] Out[]= Transpose[A]*Transpose[B] In[]:= Transpose[ A + B ] Out[]= Transpose[A] + Transpose[B] Hope this helps. Paul ************************************************************************** * Paul A. Rubin Phone: (517) 432-3509 * * Department of Management Fax: (517) 432-1111 * * Eli Broad Graduate School of Management Net: RUBIN at MSU.EDU * * Michigan State University * * East Lansing, MI 48824-1122 (USA) * ************************************************************************** Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. J. W. v. GOETHE