(* ::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:: *)
CCF[\[ScriptCapitalE]_] := Subscript[PP, CCF]@ExpandDenominator@ExpandNumerator@Subscript[PP, Together]@Together[Subscript[PP, Exp][
Expand[\[ScriptCapitalE]] //. E^x_ E^y_:>E^(x+y) /. E^x_:>E^CCF[x]]];
CF[\[ScriptCapitalE]_List]:=CF/@\[ScriptCapitalE];
CF[sd_SeriesData] := MapAt[CF,sd,3];
CF[\[ScriptCapitalE]_] := Subscript[PP, CF]@Module[
{vs=Cases[\[ScriptCapitalE],Subscript[(y|b|t|w|a|x|\[Eta]|\[Beta]|\[Tau]|\[Omega]|\[Alpha]|\[Xi]), _],\[Infinity]]\[Union]{y,b,t,w,a,x,\[Eta],\[Beta],\[Tau],\[Omega],\[Alpha],\[Xi]}},
Total[CoefficientRules[Expand[\[ScriptCapitalE]], vs] /. (ps_->c_) :> CCF[c](Times@@(vs^ps))]
];
CF[\[ScriptCapitalE]_\[DoubleStruckCapitalE]]:=CF/@\[ScriptCapitalE]; CF[Subscript[\[DoubleStruckCapitalE], sp___][\[ScriptCapitalE]s___]]:=CF/@Subscript[\[DoubleStruckCapitalE], sp][\[ScriptCapitalE]s];


(* ::Input::Initialization:: *)
K\[Delta]/:Subscript[K\[Delta], i_,j_]:=If[i===j,1,0];


(* ::Input::Initialization:: *)
\[DoubleStruckCapitalE]/:\[DoubleStruckCapitalE][L1_,Q1_,P1_]\[Congruent]\[DoubleStruckCapitalE][L2_,Q2_,P2_]:=CF[L1==L2]\[And]CF[Q1==Q2]\[And]CF[Normal[P1-P2]==0];
\[DoubleStruckCapitalE]/:\[DoubleStruckCapitalE][L1_,Q1_,P1_]\[DoubleStruckCapitalE][L2_,Q2_,P2_]:=\[DoubleStruckCapitalE][L1+L2,Q1+Q2,P1*P2];
Subscript[\[DoubleStruckCapitalE][L_,Q_,P_], $k_]:=\[DoubleStruckCapitalE][L,Q,Series[Normal@P,{\[Epsilon],0,$k}]];


(* ::Input::Initialization:: *)
{SuperStar[t],SuperStar[b],SuperStar[y],SuperStar[w],SuperStar[a],SuperStar[x],SuperStar[z]}={\[Tau],\[Beta],\[Eta],\[Omega],\[Alpha],\[Xi],\[Zeta]}; 
{SuperStar[\[Tau]],SuperStar[\[Beta]],SuperStar[\[Eta]],SuperStar[\[Omega]],SuperStar[\[Alpha]],SuperStar[\[Xi]],SuperStar[\[Zeta]]}={t,b,y,w,a,x,z}; SuperStar[(Subscript[u_, i_])]:=Subscript[(SuperStar[u]), i];


(* ::Input::Initialization:: *)
U2l={\!\(
\*SubsuperscriptBox[\(B\), \(i_\), \(p_.\)] :> 
\*SuperscriptBox[\(E\), \(\(-p\)\ \[HBar]\ \[Gamma]\ 
\*SubscriptBox[\(b\), \(i\)]\)]\),B^p_.:>E^(-p \[HBar] \[Gamma] b), \!\(
\*SubsuperscriptBox[\(T\), \(i_\), \(p_.\)] :> 
\*SuperscriptBox[\(E\), \(\(-p\)\ \[HBar]\ 
\*SubscriptBox[\(t\), \(i\)]\)]\),T^p_.:>E^(-p \[HBar] t),\!\(
\*SubsuperscriptBox[\(\[ScriptCapitalA]\), \(i_\), \(p_.\)] :> 
\*SuperscriptBox[\(E\), \(p\ \[Gamma]\ 
\*SubscriptBox[\(\[Alpha]\), \(i\)]\)]\),\[ScriptCapitalA]^p_.:>E^(p \[Gamma] \[Alpha])}; 
l2U={E^(c_. Subscript[b, i_]+d_.):>\!\(
\*SubsuperscriptBox[\(B\), \(i\), \(\(-c\)/\((\[HBar]\ \[Gamma])\)\)] 
\*SuperscriptBox[\(E\), \(d\)]\),E^(c_. b+d_.):>B^(-c/(\[HBar] \[Gamma])) E^d,
E^(c_. Subscript[t, i_]+d_.):>\!\(
\*SubsuperscriptBox[\(T\), \(i\), \(\(-c\)/\[HBar]\)] 
\*SuperscriptBox[\(E\), \(d\)]\),E^(c_. t+d_.):>T^(-c/\[HBar]) E^d,
E^(c_. Subscript[\[Alpha], i_]+d_.):>\!\(
\*SubsuperscriptBox[\(\[ScriptCapitalA]\), \(i\), \(c/\[Gamma]\)] 
\*SuperscriptBox[\(E\), \(d\)]\),E^(c_. \[Alpha]+d_.):>\[ScriptCapitalA]^(c/\[Gamma]) E^d,
E^\[ScriptCapitalE]_:>E^Expand@\[ScriptCapitalE]};


(* ::Input::Initialization:: *)
Subscript[D, b][f_]:=\!\(
\*SubscriptBox[\(\[PartialD]\), \(b\)]f\)-\[HBar] \[Gamma] B \!\(
\*SubscriptBox[\(\[PartialD]\), \(B\)]f\); Subscript[D, Subscript[b, i_]][f_]:=\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(b\), \(i\)]]f\)-\[HBar] \[Gamma] Subscript[B, i]\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(B\), \(i\)]]f\);
Subscript[D, t][f_]:=\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]f\)-\[HBar] T \!\(
\*SubscriptBox[\(\[PartialD]\), \(T\)]f\); Subscript[D, Subscript[t, i_]][f_]:=\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(t\), \(i\)]]f\)-\[HBar] Subscript[T, i]\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(T\), \(i\)]]f\); 
Subscript[D, \[Alpha]][f_]:=\!\(
\*SubscriptBox[\(\[PartialD]\), \(\[Alpha]\)]f\)+\[Gamma] \[ScriptCapitalA] \!\(
\*SubscriptBox[\(\[PartialD]\), \(\[ScriptCapitalA]\)]f\); Subscript[D, Subscript[\[Alpha], i_]][f_]:=\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(\[Alpha]\), \(i\)]]f\)+\[Gamma] Subscript[\[ScriptCapitalA], i] \!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(\[ScriptCapitalA]\), \(i\)]]f\);
Subscript[D, v_][f_]:=\!\(
\*SubscriptBox[\(\[PartialD]\), \(v\)]f\); \!\(\*SubscriptBox[\(D\), \({v_, 0}\)]\)[f_]:=f; \!\(\*SubscriptBox[\(D\), \({}\)]\)[f_]:=f; \!\(\*SubscriptBox[\(D\), \({v_, n_Integer}\)]\)[f_]:=Subscript[D, v][\!\(\*SubscriptBox[\(D\), \({v, n - 1}\)]\)[f]];
\!\(\*SubscriptBox[\(D\), \({l_List, ls___}\)]\)[f_]:=\!\(\*SubscriptBox[\(D\), \({ls}\)]\)[Subscript[D, l][f]];


(* ::Input::Initialization:: *)
collect[sd_SeriesData, \[Zeta]_] := MapAt[collect[#,\[Zeta]]&,sd,3];
collect[\[ScriptCapitalE]_,\[Zeta]_] := Subscript[PP, Collect]@Collect[\[ScriptCapitalE],\[Zeta]];
\!\(\*SubscriptBox[\(Zip\), \({}\)]\)[P_]:=P;
Subscript[Zip, \[Zeta]s_][Ps_List]:=Subscript[Zip, \[Zeta]s]/@Ps;
\!\(\*SubscriptBox[\(Zip\), \({\[Zeta]_, \[Zeta]s___}\)]\)[P_] := Subscript[PP, Zip][
(collect[P//\!\(\*SubscriptBox[\(Zip\), \({\[Zeta]s}\)]\),\[Zeta]] /. f_. \[Zeta]^d_.:>(\!\(\*SubscriptBox[\(D\), \({
\*SuperscriptBox[\(\[Zeta]\), \(*\)], d}\)]\)[f]))/.SuperStar[\[Zeta]]->0/.((SuperStar[\[Zeta]]/.{b->B,t->T,\[Alpha]->\[ScriptCapitalA]})->1)]


(* ::Input::Initialization:: *)
Subscript[QZip, \[Zeta]s_List]@\[DoubleStruckCapitalE][L_,Q_,P_] := Subscript[PP, QZip]@Module[{\[Zeta],z,zs,c,ys,\[Eta]s,qt,zrule,\[Zeta]rule,out},
zs=Table[SuperStar[\[Zeta]],{\[Zeta],\[Zeta]s}];
c=CF[Q/.Alternatives@@(\[Zeta]s\[Union]zs)->0];
ys=CF@Table[\!\(
\*SubscriptBox[\(\[PartialD]\), \(\[Zeta]\)]\((Q /. Alternatives @@ zs -> 0)\)\),{\[Zeta],\[Zeta]s}];
\[Eta]s=CF@Table[\!\(
\*SubscriptBox[\(\[PartialD]\), \(z\)]\((Q /. Alternatives @@ \[Zeta]s -> 0)\)\),{z,zs}];
qt=CF@Inverse@Table[Subscript[K\[Delta], z,SuperStar[\[Zeta]]]-\!\(
\*SubscriptBox[\(\[PartialD]\), \(z, \[Zeta]\)]Q\),{\[Zeta],\[Zeta]s},{z,zs}];
zrule=Thread[zs->CF[qt.(zs+ys)]];
\[Zeta]rule=Thread[\[Zeta]s->\[Zeta]s+\[Eta]s.qt];
CF /@ \[DoubleStruckCapitalE][L,c+\[Eta]s.qt.ys,Det[qt]Subscript[Zip, \[Zeta]s][P/.(zrule\[Union]\[Zeta]rule)]] ];


(* ::Input::Initialization:: *)
Subscript[LZip, \[Zeta]s_List]@\[DoubleStruckCapitalE][L_,Q_,P_] := Subscript[PP, LZip]@Module[{\[Zeta],z,zs,Zs,c,ys,\[Eta]s,lt,zrule,Zrule,\[Zeta]rule,Q1,EEQ,EQ},
zs=Table[SuperStar[\[Zeta]],{\[Zeta],\[Zeta]s}];
Zs=zs/.{b->B,t->T,\[Alpha]->\[ScriptCapitalA]};
c=L/.Alternatives@@(\[Zeta]s\[Union]zs)->0/.Alternatives@@Zs->1;
ys=Table[\!\(
\*SubscriptBox[\(\[PartialD]\), \(\[Zeta]\)]\((L /. Alternatives @@ zs -> 0)\)\),{\[Zeta],\[Zeta]s}];
\[Eta]s=Table[\!\(
\*SubscriptBox[\(\[PartialD]\), \(z\)]\((L /. Alternatives @@ \[Zeta]s -> 0)\)\),{z,zs}];
lt=Inverse@Table[Subscript[K\[Delta], z,SuperStar[\[Zeta]]]-\!\(
\*SubscriptBox[\(\[PartialD]\), \(z, \[Zeta]\)]L\),{\[Zeta],\[Zeta]s},{z,zs}];
zrule=Thread[zs->lt.(zs+ys)];
Zrule=Join[zrule,zrule/.r_Rule:>((U=r[[1]]/.{b->B,t->T,\[Alpha]->\[ScriptCapitalA]})->(U/.U2l/.r//.l2U))];
\[Zeta]rule=Thread[\[Zeta]s->\[Zeta]s+\[Eta]s.lt];
Q1=Q/.(Zrule\[Union]\[Zeta]rule);
EEQ[ps___]:=EEQ[ps]=\!\(\*SubscriptBox[\(PP\), \("\<EEQ\>"\)]\)@(CF[E^-Q1 Subscript[D, Thread[{zs,{ps}}]][E^Q1]]/.{Alternatives@@zs->0,Alternatives@@Zs->1});
CF@\[DoubleStruckCapitalE][c+\[Eta]s.lt.ys,Q1/.{Alternatives@@zs->0,Alternatives@@Zs->1},
Det[lt](Subscript[Zip, \[Zeta]s][(EQ@@zs)(P/.(Zrule\[Union]\[Zeta]rule))] /. \!\(\*
TagBox[
StyleBox[
RowBox[{
RowBox[{
RowBox[{"Derivative", "[", "ps___", "]"}], "[", "EQ", "]"}], "[", "___", "]"}],
ShowSpecialCharacters->False,
ShowStringCharacters->True,
NumberMarks->True],
FullForm]\) :> EEQ[ps] /. _EQ->1)  ] ];


(* ::Input::Initialization:: *)
\!\(\*SubscriptBox[\(B\), \({}\)]\)[L_,R_]:=L R;
\!\(\*SubscriptBox[\(B\), \({is__}\)]\)[L_\[DoubleStruckCapitalE],R_\[DoubleStruckCapitalE]] := Subscript[PP, B]@Module[{n},
Times[
L/.Table[Subscript[(v:b|B|t|T|w|a|x|y), i]->Subscript[v, n@i],{i,{is}}],
R/.Table[Subscript[(v:\[Beta]|\[Tau]|\[Omega]|\[Alpha]|\[ScriptCapitalA]|\[Xi]|\[Eta]), i]->Subscript[v, n@i],{i,{is}}]
] // Subscript[LZip, Join@@Table[{Subscript[\[Beta], n@i],Subscript[\[Tau], n@i],Subscript[w, n@i],Subscript[a, n@i]},{i,{is}}]] // Subscript[QZip, Join@@Table[{Subscript[\[Xi], n@i],Subscript[y, n@i]},{i,{is}}]] ];
Subscript[B, is___][L_,R_]:=\!\(\*SubscriptBox[\(B\), \({is}\)]\)[L,R];


(* ::Input::Initialization:: *)
Subscript[B, is_List][Subscript[\[DoubleStruckCapitalE], d1_->r1_][L1_,Q1_,P1_],Subscript[\[DoubleStruckCapitalE], d2_->r2_][L2_,Q2_,P2_]]:=Subscript[\[DoubleStruckCapitalE], (d1\[Union]Complement[d2,is])->(r2\[Union]Complement[r1,is])]@@Subscript[B, is][\[DoubleStruckCapitalE][L1,Q1,P1],\[DoubleStruckCapitalE][L2,Q2,P2]];
Subscript[\[DoubleStruckCapitalE], d1_->r1_][L1_,Q1_,P1_]//Subscript[\[DoubleStruckCapitalE], d2_->r2_][L2_,Q2_,P2_] := Subscript[B, r1\[Intersection]d2][Subscript[\[DoubleStruckCapitalE], d1->r1][L1,Q1,P1],Subscript[\[DoubleStruckCapitalE], d2->r2][L2,Q2,P2]];
Subscript[\[DoubleStruckCapitalE], d1_->r1_][L1_,Q1_,P1_]\[Congruent]Subscript[\[DoubleStruckCapitalE], d2_->r2_][L2_,Q2_,P2_] ^:= (d1==d2)\[And](r1==r2)\[And](\[DoubleStruckCapitalE][L1,Q1,P1]\[Congruent]\[DoubleStruckCapitalE][L2,Q2,P2]);
Subscript[\[DoubleStruckCapitalE], d1_->r1_][L1_,Q1_,P1_]Subscript[\[DoubleStruckCapitalE], d2_->r2_][L2_,Q2_,P2_] ^:= Subscript[\[DoubleStruckCapitalE], (d1\[Union]d2)->(r1\[Union]r2)]@@(\[DoubleStruckCapitalE][L1,Q1,P1]\[DoubleStruckCapitalE][L2,Q2,P2]);
Subscript[Subscript[\[DoubleStruckCapitalE], dr_][L_,Q_,P_], $k_]:=Subscript[\[DoubleStruckCapitalE], dr]@@Subscript[\[DoubleStruckCapitalE][L,Q,P], $k];
Subscript[\[DoubleStruckCapitalE], _][\[ScriptCapitalE]___][i_]:={\[ScriptCapitalE]}[[i]];


(* ::Input::Initialization:: *)
Subscript[\[DoubleStruckCapitalE], dr_][\[CapitalLambda]_]:=CF@Module[{L,\[CapitalLambda]0=Limit[\[CapitalLambda],\[Epsilon]->0]},Subscript[Subscript[\[DoubleStruckCapitalE], dr][L=\[CapitalLambda]0 /. Subscript[(\[Eta]|y|\[Xi]|x), _]->0,\[CapitalLambda]0-L,E^(\[CapitalLambda]-\[CapitalLambda]0)], $k]/.l2U]


(* ::Input::Initialization:: *)
(* Bug: The first line is valid only if \[DoubleStruckCapitalO](\[ExponentialE]^Subscript[P, 0])\[Equal](\[ExponentialE]^(\[DoubleStruckCapitalO](Subscript[P, 0]))). *)
Subscript[Exp, m_,i_,0][P_]:=Module[{LQ=Normal@P /. \[Epsilon]->0},
\[DoubleStruckCapitalE][LQ/.Subscript[(x|y), i]->0, LQ/.Subscript[(b|a|t), i]->0,1] ];


(* ::Input::Initialization:: *)
Subscript[Exp, m_,i_,k_][P_]:=Block[{$k=k},
Module[{P0,\[Lambda],\[CurlyPhi],\[CurlyPhi]s,F,j,rhs,eqn,pows,at0,at\[Lambda]},
P0=Normal@P /. \[Epsilon]->0;
F=Normal@Last@Subscript[Exp, m,i,k-1][\[Lambda] P];
While[
rhs=Subscript[m, i,j->i][Subscript[\!\(\*SubscriptBox[\(\[DoubleStruckCapitalE]\), \({} \[Rule] {i}\)]\)[\[Lambda] P0/.Subscript[(x|y), i]->0,\[Lambda] P0/.Subscript[(b|a|t), i]->0, F], k]Subscript[s\[Sigma], i->j]@Subscript[\!\(\*SubscriptBox[\(\[DoubleStruckCapitalE]\), \({} \[Rule] {i}\)]\)[0,0,P], k]]//Last//Normal;
eqn=CF[(\!\(
\*SubscriptBox[\(\[PartialD]\), \(\[Lambda]\)]F\))+P0 F-rhs];
eqn=!=0,(*do*)
pows=First/@CoefficientRules[eqn,{Subscript[y, i],Subscript[b, i],Subscript[a, i],Subscript[x, i]}];
F+=Sum[\[Epsilon]^k Subscript[\[CurlyPhi], js][\[Lambda]]Times@@({Subscript[y, i],Subscript[b, i],Subscript[a, i],Subscript[x, i]}^js),{js,pows}];
rhs=Subscript[m, i,j->i][Subscript[\!\(\*SubscriptBox[\(\[DoubleStruckCapitalE]\), \({} \[Rule] {i}\)]\)[\[Lambda] P0/.Subscript[(x|y), i]->0,\[Lambda] P0/.Subscript[(b|a|t), i]->0, F], k]Subscript[s\[Sigma], i->j]@Subscript[\!\(\*SubscriptBox[\(\[DoubleStruckCapitalE]\), \({} \[Rule] {i}\)]\)[0,0,P], k]]//Last//Normal;
eqn=CF[(\!\(
\*SubscriptBox[\(\[PartialD]\), \(\[Lambda]\)]F\))+P0 F-rhs];
\[CurlyPhi]s=Table[Subscript[\[CurlyPhi], js][\[Lambda]],{js,pows}];
at0=Table[Subscript[\[CurlyPhi], js][0]==0,{js,pows}];
at\[Lambda]=(#==0)&/@(pows/.CoefficientRules[eqn,{Subscript[y, i],Subscript[b, i],Subscript[a, i],Subscript[x, i]}]);
F=F/. DSolve[And@@(at0\[Union]at\[Lambda]),\[CurlyPhi]s,\[Lambda]][[1]]
];
\!\(\*SubscriptBox[\(\[DoubleStruckCapitalE]\), \({} \[Rule] {i}\)]\)[P0/.Subscript[(x|y), i]->0,P0/.Subscript[(b|a|t), i]->0, F+O[\[Epsilon]]^(k+1)/.\[Lambda]->1]] ]


(* ::Input::Initialization:: *)
SetAttributes[Define, HoldAll];
Define[def_,defs__] := (Define[def]; Define[defs];);
Define[Subscript[op_, is__]=\[ScriptCapitalE]_] := Module[{SD,ii,jj,kk,isp,nis,nisp,sis},Block[{i,j,k},
ReleaseHold[Hold[
SD[Subscript[op, nisp,$k_Integer],Subscript[PP, Boot]@Block[{i,j,k},Subscript[op, isp,$k]=\[ScriptCapitalE];Subscript[op, nis,$k]]];
SD[Subscript[op, isp],\!\(\*SubscriptBox[\(op\), \({is}, $k\)]\)]; SD[Subscript[op, sis__],\!\(\*SubscriptBox[\(op\), \({sis}\)]\)];
]/. {SD->SetDelayed,
isp->{is}/.{i->i_,j->j_,k->k_},
nis->{is}/.{i->ii,j->jj,k->kk},
nisp->{is}/.{i->ii_,j->jj_,k->kk_}
}]  ]]
