(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



(* ::Input::Initialization:: *)
\[Epsilon] /: \[Epsilon]^2=0; \[Epsilon] /: \[Epsilon]^3=0;
PBWRule={v->1,c->2,w->3};
B[U@c,U@w]=-(B[U@w,U@c]=U@w);
B[U@v,U@c]=-(B[U@c,U@v]=U@v);
B[U@w,U@v]=-(B[U@v,U@w]=(t-1) U[]+\[Epsilon] (t+1) U@c);


(* ::Input::Initialization:: *)
UU[l___,x_^n_,r___]:= UU[l,Sequence@@Table[x,{n}],r];
UU[l___,1,r___]:= UU[l,r];
UU[]=U[]; UU[l_,r___]:=U[l]**UU[r];Subscript[U, i_][\[ScriptCapitalE]_] := \[ScriptCapitalE] /. {b->Subscript[b, i],t->Subscript[t, i], u_U :> Replace[u, x_ :> Subscript[x, i],1]};


(* ::Input::Initialization:: *)
B[x_,x_]=0;
B[U[Subscript[(x_), i_]],U[Subscript[(y_), i_]]]:=B[U[Subscript[x, i]],U[Subscript[y, i]]]=Subscript[U, i][B[U@x,U@y]];
B[U[Subscript[(x_), i_]],U[Subscript[(y_), j_]]] /; i=!=j := 0;
B[x_,y_] := x**y-y**x;


(* ::Input::Initialization:: *)
x_\[PrecedesEqual]y_:=OrderedQ[{x,y}/.PBWRule]; x_\[Precedes]y_:=!OrderedQ[{y,x}/.PBWRule];
Simp[\[ScriptCapitalE]_]:= Collect[\[ScriptCapitalE], _U, Expand];


(* ::Input::Initialization:: *)
Unprotect[NonCommutativeMultiply];
NonCommutativeMultiply[x_] := x;
0**_=_**0=0;
x_**U[]:=x; U[]**x_:=x;
(a_*x_U)**(b_*y_U) := If[a b === 0, 0, Simp[a b (x**y)]];
(a_*x_U)**y_ := Simp[a(x**y)]; x_**(a_*y_U) := Simp[a(x**y)];
(x_Plus)**y_ := (#**y)& /@ x; x_**(y_Plus) := (x**#)& /@ y;
U[x_]**U[y_] := If[x\[Precedes]y, U[x,y], U[y,x]+B[U@x,U@y]];
U[x_] ** U[y1_,yy__] := If[x\[PrecedesEqual]y1,U[x,y1,yy],(U@x**U@y1)**U@yy];
U[xx__,xn_]**U[yy__] := U@xx**(U@xn**U@yy);


(* ::Input::Initialization:: *)
U[l___,x_^n_,r___]:= U[l,Sequence@@Table[x,{n}],r];
U[l___,1,r___]:= U[l,r];


(* ::Input::Initialization:: *)
ToDegree[n_][\[ScriptCapitalE]_] := Simp[\[ScriptCapitalE]] /. a_. x_U :>Normal[Series[a,{\[HBar],0,n}]]*x


(* ::Input::Initialization:: *)
LBasis[n_Integer] := LBasis[Range[n]];
LBasis[S_] := DeleteCases[0]@Module[{i,j,k,l}, SortBy[(# /. {\[Epsilon]->2,Subscript[c, _]->2,Subscript[v, _]->2,Subscript[w, _]->2, U->Times})&][
Union@Flatten[{{U[],\[Epsilon] U[]},
Table[{U@Subscript[c, i],U@Subscript[v, i],U@Subscript[w, i],\[Epsilon] U@Subscript[c, i],\[Epsilon] U@Subscript[v, i],\[Epsilon] U@Subscript[w, i]}, {i,S}],
Table[{U[Subscript[v, i],Subscript[w, j]],\[Epsilon] U[Subscript[v, i],Subscript[w, j]],\[Epsilon] U@@Sort@{Subscript[c, i],Subscript[c, j]},\[Epsilon] U[Subscript[v, j],Subscript[c, i]],\[Epsilon] U[Subscript[c, i],Subscript[w, j]]}, {i,S}, {j,S}],
Table[{\[Epsilon] U[Subscript[v, j],Subscript[c, i],Subscript[w, k]],\[Epsilon] U@@Sort@{Subscript[v, i],Subscript[v, j],Subscript[w, k]},\[Epsilon] U@@Sort@{Subscript[v, i],Subscript[w, j],Subscript[w, k]}}, {i,S}, {j,S},{k,S}],
Table[\[Epsilon] U@@Sort@{Subscript[v, i],Subscript[v, j],Subscript[w, k],Subscript[w, l]}, {i,S}, {j,S},{k,S},{l,S}] }]
]]


(* ::Input::Initialization:: *)
BLBasis[n_Integer] := BLBasis[Range[n]];
BLBasis[S_] := DeleteCases[0]@Module[{i,j,k,l}, SortBy[(# /. {\[Epsilon]->2,Subscript[c, _]->2,Subscript[v, _]->2,Subscript[w, _]->2, U->Times})&][
Union@Flatten[{{U[],\[Epsilon] U[]},
Table[{U@Subscript[c, i],\[Epsilon] U@Subscript[c, i]}, {i,S}],
Table[{U[Subscript[v, i],Subscript[w, j]],\[Epsilon] U[Subscript[v, i],Subscript[w, j]],\[Epsilon] U@@Sort@{Subscript[c, i],Subscript[c, j]}}, {i,S}, {j,S}],
Table[{\[Epsilon] U[Subscript[v, j],Subscript[c, i],Subscript[w, k]]}, {i,S}, {j,S},{k,S}],
Table[\[Epsilon] U@@Sort@{Subscript[v, i],Subscript[v, j],Subscript[w, k],Subscript[w, l]}, {i,S}, {j,S},{k,S},{l,S}] }]
]]


(* ::Input::Initialization:: *)
\[DoubleStruckCapitalO][n_, poly_, specs___] := Module[{vs,us},
vs=Join@@(First /@ {specs});
us=Join@@({specs} /. (l_->s_) :> (l/.Subscript[x_, i_]:>Subscript[x, s]));
Total[CoefficientRules[Normal@Series[poly, {\[HBar],0,n}], vs] /. (p_->c_) :> c UU@@(us^p)]]


(* ::Input::Initialization:: *)
\[CapitalLambda][\[Alpha]_,\[Beta]_,\[Delta]_,\[Mu]_ ,v_,c_,w_,t_]:=-((1+t)/4)(4v c w \[Delta]^2 \[Mu]^2+\[Delta] (1+\[Mu])(w^2 \[Alpha]^2+ v^2 \[Beta]^2 )+ v^2 w^2 \[Delta]^3 (1+3 \[Mu])+(1-t)(2(\[Alpha] \[Beta]+\[Delta] \[Mu])^2-\[Alpha]^2 \[Beta]^2)+2(\[Alpha] \[Beta]+2\[Delta] \[Mu]+ v w \[Delta]^2 (1+2 \[Mu])+2c  \[Delta] \[Mu]^2)(w \[Alpha] +v \[Beta] )+ 4(c \[Mu]^2+v w \[Delta] (1+\[Mu]) )(\[Alpha] \[Beta]+\[Delta] \[Mu]) );



