RE: Defining anti-symmetric operation. New ideas requested.
- To: mathgroup at smc.vnet.net
- Subject: [mg47313] RE: [mg47223] Defining anti-symmetric operation. New ideas requested.
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Mon, 5 Apr 2004 05:22:50 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
By an error of mine, this did not reach MathGroup. The basic idea is the same as communicated by Daniel Lichtblau (and sketched by Jens-Peer Kuska), namely to convert any expression with Commute to a "normal form", which contains the definition (or the default). This then avoids infinite recursion. Here below a slightly polished version of my attempt. >-----Original Message----- >From: Oleksandr Pavlyk [mailto:pavlyk at phys.psu.edu] To: mathgroup at smc.vnet.net >Sent: Wednesday, March 31, 2004 9:58 AM >To: mathgroup at smc.vnet.net >Subject: [mg47313] [mg47223] Defining anti-symmetric operation. New ideas >requested. > > >Dear MathGroup, > >In order to explain the problem I would need to >say few words about what I am trying to accomplish. >So please bear with me. > >I am often define bare bones of a Lie algebra, >and check its consistency by Mathematica. To that >end I have some generators, and I define their >commutation relation. As an example let us take >SU(2) with 3 generators H[], X[], Y[] > >To define the algebra I write > > Commute[ H[], X[] ] = Y[] > Commute[ X[], Y[] ] = H[] > Commute[ Y[], H[] ] = X[] > >now because of properties of Commute, > >Commute[ OperatorA, OperatorB ] = - Commute[OperatorB, OperatorA] > >So far I am realizing this property by defining > > Commute[ X[], H[] ] := -Commute[ H[], X[] ] > Commute[ Y[], X[] ] := -Commute[ X[], Y[] ] > Commute[ H[], Y[] ] := -Commute[ Y[], H[] ] > >So I come to my question. I would like Mathematica to >define automatically > > Commute[OperatorB, OperatorA] > >every time I define Commute[OperatorA, OperatorB]. > >I tried to approach the problem by examining >DownValues of Commute. > >(* This is evaluated if no direct definition was matched *) >Commute[a_, b_]:=Module[{res}, > res = HoldComplete[Commute[b,a]]/.DownValues[Commute]; > If[ res === HoldComplete[Commute[b,a]], (* If nothing in >DownValues *) > Return[0] (* we declare everything else commuting *) > , > Return[ -ReleaseHold[res] ] > ] >] > >This definition indeed gives Commute[ X[], H[] ] = -Y[], but if I try >it on some undefined generators > > Commute[ J[], H[] ] > >I get infinite recursion, which is there because the very definition >of trick solving part of Commute is also in DownValues, and >hence we get > > res = HoldComplete[ Module[{},.... ] ] > >Any ideas on how to encode anti-symmetric properties of Commute would >be very appreciated. > >I am sorry for slightly long post. The Mathematica notebook with the >code is posted at > > http://www.pavlyk.com/SU(2).nb > >Thank you, >Sasha > An idea: define the anticommuting property with respect to normal order: In[2]:= Commute[a__] := Signature[{a}]Sort[Unevaluated[Commute[a]]] If there is no definition for normal order, things commute: In[3]:= Commute[a__] /; OrderedQ[{a}] := 0 You now may work, but have to adhere to a strict discipline as to set up definitions only in normal order. This certainly is inconvenient. Else we might try to convert to normal order at definiton time: In[4]:= Commute /: Set[Commute[a__], c_] /; ! OrderedQ[{a}] := With[{normalOrderedArg = Sequence @@ Sort[{a}]}, Commute[normalOrderedArg] = Signature[{a}] c] Now your definitions: Define commutation relations for SU(2) In[5]:= Commute[H[], X[]] = Y[]; In[6]:= Commute[X[], Y[]] = H[]; In[7]:= Commute[Y[], H[]] = X[]; The last one is not given in normal order, let's see what happens: In[8]:= Commute[H[], X[]] Out[8]= Y[] In[9]:= Commute[X[], H[]] Out[9]= -Y[] In[10]:= Commute[X[], Y[]] Out[10]= H[] In[11]:= Commute[Y[], X[]] Out[11]= -H[] In[12]:= Commute[Y[], H[]] Out[12]= X[] In[13]:= Commute[H[], Y[]] Out[13]= -X[] In[14]:= Commute[J[], H[]] Out[14]= 0 It appears to work; but what had been defined effectively? In[16]:= ?Commute >From In[16]:= Global`Commute >From In[16]:= (Commute[a__] = c_) /; ! OrderedQ[{a}] ^:= With[{normalOrderedArg = Sequence @@ Sort[{a}]}, Commute[normalOrderedArg] = Signature[{a}] c] Commute[H[], X[]] = Y[] Commute[H[], Y[]] = -X[] Commute[X[], Y[]] = H[] Commute[a__] /; OrderedQ[{a}] := 0 Commute[a__] := Signature[{a}] Sort[Unevaluated[Commute[a]]] If you want to to define Commute only for two arguments, just replace everywhere Commute[a__] by Commute[a_,b_], and {a} by {a,b}, Commute[a] by Commute[a,b]. -- Hartmut Wolf