(* ::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]_] := ExpandDenominator@ExpandNumerator@Together[\[ScriptCapitalE]];
CCF[\[ScriptCapitalE]_] := Factor[\[ScriptCapitalE]];
CF[\[Omega]_. \[ScriptCapitalE]_\[DoubleStruckCapitalE]]:=CF[\[Omega]]CF/@\[ScriptCapitalE];
CF[\[ScriptCapitalE]_List]:=CF/@\[ScriptCapitalE];
CF[\[ScriptCapitalE]_] := Module[{vs=Cases[\[ScriptCapitalE],Subscript[(x|p), __],\[Infinity]]\[Union]{x,p,\[Epsilon]},ps,c},
Total[CoefficientRules[Expand[\[ScriptCapitalE]], vs] /. (ps_->c_) :> CCF[c](Times@@(vs^ps))] ];


(* ::Input::Initialization:: *)
\[ScriptCapitalS]={x,Subscript[x, _],y,z};
Subscript[q, x_,y_][f_]:=(\!\(
\*SubscriptBox[\(\[PartialD]\), \(x, y\)]f\))/.Thread[\[ScriptCapitalS]->0];
Subscript[\[Theta], x_,y_]:=x y;
f_\[Congruent]0:=f===0;
Subscript[Ev, vs_List->0][f_]:=CF[f/.Thread[vs->0]]


(* ::Input::Initialization:: *)
\[ScriptCapitalS]={x,y,z,\[Phi],Subscript[x, _],Subscript[p, _],Subscript[\!\(\*UnderscriptBox[\(x\), \(_\)]\), _],Subscript[\!\(\*UnderscriptBox[\(p\), \(_\)]\), _]};Subscript[q, x_,y_][ser_\[Epsilon]Series]:=(\!\(
\*SubscriptBox[\(\[PartialD]\), \(x, y\)]\(ser[\([\)\(1\)\(]\)]\)\))/.Thread[\[ScriptCapitalS]->0];
Subscript[\[Theta], x_,y_]:=x y;
\[Epsilon]Series/:D[ser_\[Epsilon]Series,vs___]:=D[#,vs]&/@ser;
\[Epsilon]Series/:s1_\[Epsilon]Series+s2_\[Epsilon]Series:=\[Epsilon]Series@@Table[s1[[kk]]+s2[[kk]],{kk,Min[Length@s1,Length@s2]}];
\[Epsilon]Series/:t_+ser_\[Epsilon]Series:=MapAt[(#+t)&,ser,1];
\[Epsilon]Series/:s1_\[Epsilon]Series*s2_\[Epsilon]Series:=\[Epsilon]Series@@Table[Sum[s1[[ii+1]]s2[[kk-ii+1]],{ii,0,kk}],{kk,0,Min[Length@s1,Length@s2]-1}];
\[Epsilon]Series/:c_*ser_\[Epsilon]Series:=(c #)&/@ser;
ser_\[Epsilon]Series \[Congruent] 0 := And@@((#===0)&/@ser);
\[Epsilon]Series/:Integrate[ser_\[Epsilon]Series,pars__]:=\[Epsilon]Series@@(Integrate[#,pars]&/@ser);
\[Epsilon]Series/:Subscript[Ev, vs_List->0][ser_\[Epsilon]Series]:=ser/.Thread[vs->0];
CF[ser_\[Epsilon]Series]:=CF/@ser;


(* ::Input::Initialization:: *)
\[DoubleStruckCapitalE]/:\[DoubleStruckCapitalE][A_]\[DoubleStruckCapitalE][B_]:=\[DoubleStruckCapitalE][A+B]


(* ::Input::Initialization:: *)
\[DoubleStruckCapitalE][sd_SeriesData]/;(List@@sd)[[{1,2,4,6}]]==={\[Epsilon],0,0,1}:=\[DoubleStruckCapitalE][\[Epsilon]Series@@PadRight[sd[[3]],sd[[5]],0]]


(* ::Input::Initialization:: *)
Unprotect[Integrate];
Integrate::sing="How dare you ask me to integrate a singular Gaussian!";
\[Integral]\[Omega]_. \[DoubleStruckCapitalE][L_]\[DifferentialD](vs_List):=Module[{n,Q,\[CapitalDelta],G,Z,e,\[Lambda],a,b},
n=Length@vs;
Q=Table[Subscript[q, vs[[a]],vs[[b]]][L],{a,n},{b,n}];
If[(\[CapitalDelta]=CF@Det[-Q])==0,Message[Integrate::sing]; Return[]];
Z=CF[L-Sum[Q[[a,b]]Subscript[\[Theta], vs[[a]],vs[[b]]],{a,n},{b,n}]/2];
G=Inverse[Q]/2;
While[e=D[Z,\[Lambda]];Do[e+=G[[a,b]](D[Z,vs[[a]],vs[[b]]]+D[Z,vs[[a]]]D[Z,vs[[b]]]),{a,n},{b,n}];
e=CF[e];
!(e\[Congruent]0),Z=CF[Z-\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(\[Lambda]\)]\(e\ \[DifferentialD]\[Lambda]\)\)]
];
PowerExpand@Factor[\[Omega] (\[CapitalDelta] (2\[Pi])^n)^(-1/2)]\[DoubleStruckCapitalE][CF[Subscript[Ev, vs->0][Z]/.\[Lambda]->1]]
];
Protect[Integrate];



