(* ::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:: *)
SetDirectory["C:\\drorbn\\AcademicPensieve\\Talks\\GWU-1612"];


(* ::Input::Initialization:: *)
CF[\[ScriptCapitalE]_] := Module[{vars=Union@Cases[\[ScriptCapitalE],Subscript[e, _]|Subscript[l, _]|Subscript[f, _],\[Infinity]]},
If[vars==={}, Factor[\[ScriptCapitalE]],
Total[CoefficientRules[\[ScriptCapitalE], vars]/. (p_->c_):>Factor[c]Times@@(vars^p)] ]];
CF[\[ScriptCapitalE]_\[DoubleStruckCapitalE]] :=CF/@\[ScriptCapitalE];


(* ::Input::Initialization:: *)
\[DoubleStruckCapitalE][i_,j_,s_] := \[DoubleStruckCapitalE][1,(-1)^s Subscript[l, j], (-t)^s Subscript[e, i] Subscript[f, j], t^s Subscript[e, i] Subscript[l, (1+s)i-s j] Subscript[f, j]+(-1)^s Subscript[l, i] Subscript[l, j]+(-t^2)^s \!\(\*SubsuperscriptBox[\(e\), \(i\), \(2\)]\)\!\(
\*SubsuperscriptBox[\(f\), \(j\), \(2\)]/4\)];
\[DoubleStruckCapitalE][i_,s_] := \[DoubleStruckCapitalE][1,0,0,s Subscript[l, i]];
\[DoubleStruckCapitalE]/:\[DoubleStruckCapitalE][1,L1_,Q1_,P1_]\[DoubleStruckCapitalE][1,L2_,Q2_,P2_]:=\[DoubleStruckCapitalE][1,L1+L2, Q1+ Q2,P1+P2];


(* ::Input::Initialization:: *)
Subscript[DP, x_->Subscript[D, \[Alpha]_],y_->Subscript[D, \[Beta]_]][P_][f_]:=
Total[CoefficientRules[P,{x,y}]/.({m_,n_}->c_):>c D[f,{\[Alpha],m},{\[Beta],n}]]


(* ::Input::Initialization:: *)
Subscript[S, Subscript[l, j_] Subscript[(x:e|f), i_]->k_][\[DoubleStruckCapitalE][\[Omega]_,L_,Q_,P_]]:=With[{\[Lambda]=\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(l\), \(j\)]]L\),\[Alpha]=\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(x\), \(i\)]]Q\),q=E^\[Gamma] \[Beta] Subscript[x, k]+\[Gamma] Subscript[l, k]},CF[
\[DoubleStruckCapitalE][\[Omega],L/.Subscript[l, j]->Subscript[l, k],t^\[Lambda] \[Alpha] Subscript[x, k]+(Q/.Subscript[x, i]->0),E^-q Subscript[DP, Subscript[l, j]->Subscript[D, \[Gamma]],Subscript[x, i]->Subscript[D, \[Beta]]][P][E^q]/.{\[Beta]->\[Alpha]/\[Omega],\[Gamma]->\[Lambda] Log[t]}] ]];


(* ::Input::Initialization:: *)
\[CapitalLambda][k_]:= ((t-1)(2(\[Alpha] \[Beta]+\[Delta] \[Mu])^2-\[Alpha]^2 \[Beta]^2)-4Subscript[e, k] Subscript[l, k] Subscript[f, k] \[Delta]^2 \[Mu]^2-
\[Delta](1+\[Mu])(\!\(
\*SubsuperscriptBox[\(f\), \(k\), \(2\)] 
\*SuperscriptBox[\(\[Alpha]\), \(2\)]\)+\!\(
\*SubsuperscriptBox[\(e\), \(k\), \(2\)] 
\*SuperscriptBox[\(\[Beta]\), \(2\)]\))-\!\(
\*SubsuperscriptBox[\(e\), \(k\), \(2\)] 
\*SubsuperscriptBox[\(f\), \(k\), \(2\)] 
\*SuperscriptBox[\(\[Delta]\), \(3\)] \((1 + 3  \[Mu])\)\)-2(\[Alpha] \[Beta]+2\[Delta] \[Mu]+Subscript[e, k] Subscript[f, k] \[Delta]^2 (1+2\[Mu])+2Subscript[l, k]\[Delta] \[Mu]^2)(Subscript[f, k]\[Alpha]+Subscript[e, k]\[Beta])-4(Subscript[l, k] \[Mu]^2+Subscript[e, k] Subscript[f, k]\[Delta](1+\[Mu]))(\[Alpha] \[Beta]+\[Delta] \[Mu]))(1+t)/4;


(* ::Input::Initialization:: *)
Subscript[S, Subscript[f, i_] Subscript[e, j_]->k_][\[DoubleStruckCapitalE][\[Omega]_,L_,Q_,P_]]:=With[{q=((1-t)\[Alpha] \[Beta]+\[Beta] Subscript[e, k]+\[Alpha] Subscript[f, k]+\[Delta] Subscript[e, k] Subscript[f, k])/\[Mu]},CF[
\[DoubleStruckCapitalE][\[Mu] \[Omega],L,\[Mu] \[Omega] q+\[Mu](Q/.Subscript[f, i]|Subscript[e, j]->0),\[Mu]^4 E^-q Subscript[DP, Subscript[f, i]->Subscript[D, \[Alpha]],Subscript[e, j]->Subscript[D, \[Beta]]][P][E^q]+\[Omega]^4 \[CapitalLambda][k]]/.\[Mu]->1+(t-1)\[Delta]/.{\[Alpha]->\[Omega]^-1 (\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(f\), \(i\)]]Q\)/.Subscript[e, j]->0),\[Beta]->\[Omega]^-1 (\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(e\), \(j\)]]Q\)/.Subscript[f, i]->0),\[Delta]->\[Omega]^-1 \!\(
\*SubscriptBox[\(\[PartialD]\), \(
\*SubscriptBox[\(f\), \(i\)], 
\*SubscriptBox[\(e\), \(j\)]\)]Q\)}]];


(* ::Input::Initialization:: *)
Subscript[m, i_,j_->k_][Z_\[DoubleStruckCapitalE]]:=Module[{x,z},
CF[(Z//Subscript[S, Subscript[f, i] Subscript[e, j]->x]//Subscript[S, Subscript[l, i] Subscript[e, x]->x]//Subscript[S, Subscript[f, x] Subscript[l, j]->x])/.Subscript[z_, i|j|x]->Subscript[z, k]]]


(* ::Input::Initialization:: *)
Subscript[\[Rho], 1][\[DoubleStruckCapitalE][\[Omega]_,_,_,P_]] := CF[(t((P/.Subscript[e, _]|Subscript[l, _]|Subscript[f, _]->0)-t \[Omega]^3 (\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\[Omega]\))))/((t-1)^2 \[Omega]^2)]


(* ::Input::Initialization:: *)
ConditionalExport[fname_String, rest___] := Module[{temp, exists},
temp="ConditionalExportTemporary"<>"."<>FileExtension[fname];
exists=FileExistsQ[fname];
Export[temp, rest];
If[exists && FileByteCount[fname]===FileByteCount[temp],
DeleteFile[temp],
(* else *) Print["Exporting "<>fname<>"..."];
If[exists, DeleteFile[fname]];
RenameFile[temp, fname]
];
fname
]

SetOptions[$FrontEndSession,PrintingStyleEnvironment->"Working"];
TagProperties[_] := {};
TagProperties["131"] = {PageWidth ->3.2/0.66};
Options[CellExport] = {
PageWidth -> 4/0.66, CellFilter -> Identity, ExportDirectory -> "Snips", ExportBaseFilename -> Automatic, ExportFormat -> ".pdf", ExportOptions -> {}, Split -> False
};
CellExport[tag_String, opts___Rule] := CellExport[
NotebookGet[EvaluationNotebook[]],
tag, opts
];
CellExport[nb_Notebook, tag_String] := CellExport[nb, tag, TagProperties[tag]];
CellExport[nb_Notebook, tag_String, OptionsPattern[]] := Module[
{cells, cell, filename, format},
filename = FileNameJoin[{
OptionValue[ExportDirectory] /. Automatic -> Directory[],
OptionValue[ExportBaseFilename] /. Automatic -> tag
}];
format=OptionValue[ExportFormat];
cells=OptionValue[CellFilter][Cases[
nb, c_Cell /; FreeQ[List@@c, Cell] && !FreeQ[c, CellTags->tag],
Infinity
]];
If[!OptionValue[Split],
If[Length[cells]>=1,
If[Length[cells]==1,
cells=Join[First[cells], Cell[PageWidth ->1.2 72OptionValue[PageWidth], Background->{White, Opacity[0]}]],
cells=Cell[CellGroup[cells], PageWidth -> 72OptionValue[PageWidth]]
];
ConditionalExport[
filename<>format,cells,
ImageResolution -> 300,
OptionValue[ExportOptions]
]
],
k=0;
Table[
++k;
ConditionalExport[
filename<>"-"<>ToString[k]<>format,
Append[cell, PageWidth -> 72OptionValue[PageWidth]],
ImageResolution -> 300,
OptionValue[ExportOptions]
],
{cell, cells}
]
]
];

ExportCells:=(
nb=NotebookGet[EvaluationNotebook[]];
tags=Cases[nb, (CellTags->tag_String) :> tag, Infinity ] // Union;
Print[tags];
CellExport /@ tags;
Print["Done."]
);



