Suppose I have matrices a and b, which does not have any value yet.
If I write b * a, mathematica would give me "a b". I'm wondering how to make
it know that a and b are matrices, so that it would give me "b a" rather
than "a b".
Thanks,
Peng
See this link:
http://reference.wolfram.com/mathematica/ref/Dot.html
Be sure to check also MatrixPower, or you will also have problems with
powers of matrices:
http://reference.wolfram.com/mathematica/ref/MatrixPower.html
Hope that helps
Jose
Mexico
-----Mensaje original-----
De: Peng Yu [mailto:peng...@gmail.com]
Enviado el: Viernes, 26 de Septiembre de 2008 05:24
Para: math...@smc.vnet.net
Asunto: How to do symbolic matrix manipulations
>Suppose I have matrices a and b, which does not have any value yet.
>If I write b * a, mathematica would give me "a b". I'm wondering how
>to make it know that a and b are matrices, so that it would give me
>"b a" rather than "a b".
The key here is to realize b*a will always commute including
when both a,b are matrices since this does an element by element
multiplication not a matrix multiplication. Simply do matrix
multiplication using Dot and there is no problem. That is
In[1]:= b.a
Out[1]= b.a
> Suppose I have matrices a and b, which does not have any value yet.
Beware that Mathematica is not a strongly-type language and things like
vector or matrix do not exist per se. A vector can be represented by a
one dimensional list holding appropriate element, a matrix by a two
dimensional list; but a generic type vector or matrix does not exist
natively.
> If I write b * a, mathematica would give me "a b". I'm wondering how to make
> it know that a and b are matrices, so that it would give me "b a" rather
> than "a b".
You could use the non-commutative multiplication operator **.
In[213]:= b ** a
Out[213]= b ** a
If you are going to do extensive symbolic manipulation withe generic
objects, you may want to define your own matrix type (say expression
with head matrix, i.g. something like matrix[a]) and
associate/(re)define properties and operator.
Regards,
-- Jean-Marc
a*b gives the matrix (a_ij * b_ij) which is the same as (b_ij*a_ij),
so a*b=b*a.
I think you want to do matrix multiplication, which ist done by a.b
or Dot[a,b]. If you enter b.a the result will be b.a not a.b
Gruss Peter
--
==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
2008/9/26 Peng Yu <peng...@gmail.com>