Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Question about Hold

5 views
Skip to first unread message

Daohua Song

unread,
Jun 17, 2004, 4:13:43 AM6/17/04
to
Hi,evryone,
I define a commute relation for quantum operators,i fact i learn this
from the forum.Here is the problem.
Commute[A,B]=C.
Commute[A^2,B], i try to use Hold[A*A] instead of A^2, then mathematica
even won't evaluate it.!
Any suggestion to work on the power commutation?
Thanks
Daohua

Jens-Peer Kuska

unread,
Jun 18, 2004, 2:15:55 AM6/18/04
to
Hi,

Commute[a, b] := c
Commute[a^n_, b] := Commute[a^(n - 1), Commute[a, b]]

Regards
Jens

Steve Luttrell

unread,
Jun 18, 2004, 2:22:00 AM6/18/04
to
You could try the following ( I asssume C is a c-number and not an
operator):

OpProd[x___, A, B, y___] := OpProd[x, B, A, y] + C OpProd[x, y];

OpProd[A, B] then evaluates to C OpProd[] + OpProd[B, A]

OpProd[A, A, B] then evaluates to 2 C OpProd[A] + OpProd[B, A, A]

There are lots of variations on this sort of approach. The basic trick this
depends on is using OpProd[<list of operators in the product>] to hide from
Mathematica the fact that you have a "product" of operators, so you can then
get on with defining your own private set of rules for simplifying OpProd
(as above, for example).

Steve Luttrell

"Daohua Song" <ds2...@columbia.edu> wrote in message
news:carjrn$r76$1...@smc.vnet.net...

Bobby R. Treat

unread,
Jun 18, 2004, 2:29:15 AM6/18/04
to
A few questions:

1) Why write A*A as if that's different from A^2? (It isn't.)

2) Why use Hold[A*A] if you want the argument evaluated?

3) What do you want Commute[Hold[A*A],B] to evaluate to? (Commute[A,C], I suppose.)

4) What have you done to make it happen? Just Commute[A,B]=C? Or something else.

5) Are we mind-readers?

Bobby

Daohua Song <ds2...@columbia.edu> wrote in message news:<carjrn$r76$1...@smc.vnet.net>...

Oleksandr Pavlyk

unread,
Jun 19, 2004, 4:43:44 AM6/19/04
to

Jens-Peer Kuska wrote:

> Hi,
>
> Commute[a, b] := c
> Commute[a^n_, b] := Commute[a^(n - 1), Commute[a, b]]

Jens, this gives plain wrong answer.

Commute[a^2, b] = Commute[a,c]

while it must be a*c + c*a

Hence one must use NonCommutativeMultiply. Below is the code
I use to define algebraic properties of commutator over the
ring of quantum operators.

Commute[(a_)*(b_), c_] := a*Commute[b, c] + Commute[a, c]*b;
Commute[a_, (b_)*(c_)] := b*Commute[a, c] + Commute[a, b]*c;
Commute[(a_)?NumericQ, b_] := 0;
Commute[a_, a_] := 0;
Commute[a_, (b_)?NumericQ] := 0;
Commute[a_, b_Plus] := Module[{LinTMP},
Distribute[LinTMP[a, b], Plus, LinTMP, Plus, Commute]];
Commute[a_Plus, b_] := Module[{LinTMP},
Distribute[LinTMP[a, b], Plus, LinTMP, Plus, Commute]];
JacobiIdentity[a_, b_, c_] := Expand[
Commute[a, Commute[b, c]] +
Commute[b, Commute[c, a]] +
Commute[c, Commute[a, b]]
];
Commute[(a_)**(b_), c_] := a**Commute[b, c] + Commute[a, c]**b;
Commute[c_, (a_)**(b_)] := a**Commute[c, b] + Commute[c, a]**b;

Unprotect[ NonCommutativeMultiply];
(a___)**((b_)?NumericQ*(c_))**(d___) :=
b*NonCommutativeMultiply[Sequence[a, c, d]];
(a___)**0**(b___) := 0;
(a___)**(b_Plus)**(c___) :=
Module[{LinTMP},
Distribute[LinTMP[a, b,c], Plus, LinTMP, Plus,
NonCommutativeMultiply]];
Protect[ NonCommutativeMultiply];

After this is defined, let us define Heisenberg algebra

Commute[ A, B ] = 1;

Commute[ A**A, B ] gives 2 A as expected

Regards,
Sasha


>
> Regards
> Jens

Daohua Song

unread,
Jun 19, 2004, 4:54:54 AM6/19/04
to
Hi,Steve...
Thanks for all your help, also sorry for some uncertainty about the
questions.in fact the questions is quite straightforward:
e.g i define Commute[A,B]=C (all operators), how to let mathematica
knows Commute[A^2,B]=AC+CA.
I figure out one solutions later.

\!\(\*
RowBox[{
RowBox[{\(Commute[a_\^n_Integer, b_] /; n > 1\), ":=",
RowBox[{
RowBox[{"(",
RowBox[{"Commute", "[",
RowBox[{
RowBox[{"Times", "@@",
RowBox[{"Table", "[",
StyleBox[\(SubscriptBox[a, i], {i, n}\),
"MR"], "]"}]}],
",", "b"}], "]"}], ")"}], "/.", \(SubscriptBox[
a, _] :> a\)}]}], ";"}]\)

kinda of foolish:).
Jens give a simple solution, altough (Commute[a,b]=ab-ba)
Commute[a^n_, b] := AntiCommute[a^(n - 1), Commute[a, b]]
.
Thanks again for help!
daohua

On Fri, 18 Jun 2004, Steve Luttrell wrote:

> You could try the following ( I asssume C is a c-number and not an
> operator):
>
> OpProd[x___, A, B, y___] := OpProd[x, B, A, y] + C OpProd[x, y];
>
> OpProd[A, B] then evaluates to C OpProd[] + OpProd[B, A]
>
> OpProd[A, A, B] then evaluates to 2 C OpProd[A] + OpProd[B, A, A]
>
> There are lots of variations on this sort of approach. The basic trick this
> depends on is using OpProd[<list of operators in the product>] to hide from
> Mathematica the fact that you have a "product" of operators, so you can then
> get on with defining your own private set of rules for simplifying OpProd
> (as above, for example).
>
> Steve Luttrell
>

> "Daohua Song" <ds2...@columbia.edu> wrote in message
> news:carjrn$r76$1...@smc.vnet.net...

0 new messages