Re: simplifying operator experessions with Dot, Times and Plus
- To: mathgroup at smc.vnet.net
- Subject: [mg35519] Re: [mg35481] simplifying operator experessions with Dot, Times and Plus
- From: Andrzej Kozlowski <andrzej at yhc.att.ne.jp>
- Date: Wed, 17 Jul 2002 02:09:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
The reason why Dot won't work is that it is meant operate on explicit
vectors, which in Mathematica means lists, like
In[7]:=
{a,b,c}.{x,y,z}
Out[7]=
a x+b y+c z
and not on symbols that stand for vectors, as in your case. It would not
be a good idea to try to modify Dot to behave differently in case you
then tried using it on list and started getting strange results. A
better approach is to define your own dot product:
In[1]:=
SetAttributes[dot, {Flat, OneIdentity}]
In[2]:=
dot[x_ + y_, w_] := dot[x, w] + dot[y, w];
dot[w_, x_ + y_] := dot[w, x] + dot[w, y];
dot[x_, 0] = 0;
dot[0, x_] = 0;
dot[(a_)?NumericQ*x_, y_] := a*dot[x, y];
dot[x_, (b_)?NumericQ*y_] = b*dot[x, y];
Next you can temporarily replace Dot by dot, for example:
In[8]:=
Block[{Dot = dot}, -ex[0, 1] . (ex[0, 1] . ex[1, 2] -
ex[1, 2] . ex[0, 1])] /. dot -> Dot
Out[8]=
-ex[0, 1] . ex[0, 1] . ex[1, 2] + ex[0, 1] . ex[1, 2] . ex[0, 1]
Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/
On Tuesday, July 16, 2002, at 04:49 AM, JL wrote:
> I am trying to expand a large expression that has terms that look as
> follows:
>
> -ex[0,1].(ex[0,1].ex[1,2]-ex[1,2].ex[0,1])
>
> where ex[i,j] are unevaluated expressions. I would like Mathematica to
> simplify this and analogous expressions so that they read:
>
> ex[0,1].ex[1,2].ex[0,1]-ex[0,1].ex[0,1].ex[1,2]
>
> However, I cannot seem to find anything that will work. The problem is
> that
> I need to keep track of the order of the expressions ex[i,j]. If Dot
> were
> replaced by Times, there would be no problem whatsoever.
>
> If anyone knows how to help me with this problem, I would greatly
> appreciate
> it.
>
> Thanks,
>
> Jeremy Levy
> jlevy at pitt.edu
>
>
>
>
>
>
>