(* ::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\\Projects\\HigherRank"];
Once[<<KnotTheory`];
<<Rot.m


(* ::Input::Initialization:: *)
{
{Subscript[r, 0,pxx][1,i_,j_],Subscript[r, 0,pxx][-1,i_,j_]},
{Subscript[r, 1,ppx][1,i_,j_],Subscript[r, 1,ppx][-1,i_,j_]},
{Subscript[r, 1,rest][1,i_,j_],Subscript[r, 1,rest][-1,i_,j_]},
Subscript[\[Gamma], 1][\[CurlyPhi]_,k_]
}=Get["px-data.m"]


(* ::Input::Initialization:: *)
{SuperStar[p],SuperStar[x],SuperStar[\[Pi]],SuperStar[\[Xi]]}={\[Pi],\[Xi],p,x};  SuperStar[(Subscript[u_, i__])]:=Subscript[(SuperStar[u]), i];


(* ::Input::Initialization:: *)
\!\(\*SubscriptBox[\(Zip\), \({}\)]\)[\[ScriptCapitalE]_]:=\[ScriptCapitalE];
\!\(\*SubscriptBox[\(Zip\), \({\[Zeta]_, \[Zeta]s___}\)]\)[\[ScriptCapitalE]_] := (Collect[\[ScriptCapitalE]//\!\(\*SubscriptBox[\(Zip\), \({\[Zeta]s}\)]\),\[Zeta]] /. f_. \[Zeta]^d_.:>(D[f,{SuperStar[\[Zeta]],d}]))/.SuperStar[\[Zeta]]->0


(* ::Input::Initialization:: *)
px2g[\[ScriptCapitalE]_]:=Module[{ps,xs,Q},
ps=Union[Cases[\[ScriptCapitalE],Subscript[p, __],\[Infinity]]]; xs=Union[Cases[\[ScriptCapitalE],Subscript[x, __],\[Infinity]]];
Q=Sum[SuperStar[p0] SuperStar[x0] Subscript[g, p0[[2]],x0[[2]],p0[[3]],x0[[3]]],{p0,ps},{x0,xs}];
Expand[Subscript[Zip, ps\[Union]xs][\[ScriptCapitalE] E^Q]/.Subscript[g, \[Alpha]_,\[Beta]_,i_,j_]:>If[\[Alpha]===\[Beta],Subscript[g, \[Alpha],i,j],0]]
]


(* ::Input::Initialization:: *)
Subscript[R, 1][1,i_,j_]=px2g[Subscript[r, 1,rest][1,i,j]]


(* ::Input::Initialization:: *)
Subscript[R, 1][-1,i_,j_]=px2g[Subscript[r, 1,rest][-1,i,j]]


(* ::Input::Initialization:: *)
\[Theta][{1,i0_,j0_},{1,i1_,j1_}]=px2g[Subscript[r, 0,pxx][1,i0,j0]Subscript[r, 1,ppx][1,i1,j1]]
\[Theta][{1,i0_,j0_},{-1,i1_,j1_}]=px2g[Subscript[r, 0,pxx][1,i0,j0]Subscript[r, 1,ppx][-1,i1,j1]]
\[Theta][{-1,i0_,j0_},{1,i1_,j1_}]=px2g[Subscript[r, 0,pxx][-1,i0,j0]Subscript[r, 1,ppx][1,i1,j1]]
\[Theta][{-1,i0_,j0_},{-1,i1_,j1_}]=px2g[Subscript[r, 0,pxx][-1,i0,j0]Subscript[r, 1,ppx][-1,i1,j1]]


(* ::Input::Initialization:: *)
Subscript[\[CapitalGamma], 1][\[CurlyPhi]_,k_]=px2g[Subscript[\[Gamma], 1][\[CurlyPhi],k]]


(* ::Input::Initialization:: *)
Subscript[T, 3]=Subscript[T, 1] Subscript[T, 2];
CF[\[ScriptCapitalE]_]:=Factor@Together[\[ScriptCapitalE]];
\[Theta][K_]:=Module[{Cs,\[CurlyPhi],n,A,s,i,j,k,\[CapitalDelta],G,gEval,Y,yEval,c,z},
{Cs,\[CurlyPhi]}=Rot[K]; n=Length[Cs];
A=IdentityMatrix[2n+1];
Cases[Cs,{s_,i_,j_}:>(A[[{i,j},{i+1,j+1}]]+=({
 {-T^s, T^s-1},
 {0, -1}
}))];
\[CapitalDelta]=T^((-Total[\[CurlyPhi]]-Total[Cs[[All,1]]])/2) Det[A];
G=Inverse[A]; gEval[\[ScriptCapitalE]_]:=CF[\[ScriptCapitalE]/.Subscript[g, \[Nu]_,\[Alpha]_,\[Beta]_]:>(G[[\[Alpha],\[Beta]]]/.T->Subscript[T, \[Nu]])];
z=gEval[\!\(
\*SubsuperscriptBox[\(\[Sum]\), \(k1 = 1\), \(n\)]\(
\*SubsuperscriptBox[\(\[Sum]\), \(k2 = 1\), \(n\)]\[Theta][Cs[\([\)\(k1\)\(]\)], Cs[\([\)\(k2\)\(]\)]]\)\)];
z+=gEval[\!\(
\*SubsuperscriptBox[\(\[Sum]\), \(k = 1\), \(n\)]\(
\*SubscriptBox[\(R\), \(1\)] @@ Cs[[k]]\)\)];
z+=gEval[\!\(
\*SubsuperscriptBox[\(\[Sum]\), \(k = 1\), \(2  n\)]\(
\(\*SubscriptBox[\(\[CapitalGamma]\), \(1\)]\)[\[CurlyPhi][\([\)\(k\)\(]\)], k]\)\)];
{\[CapitalDelta],(\[CapitalDelta]/.T->Subscript[T, 1])(\[CapitalDelta]/.T->Subscript[T, 2])(\[CapitalDelta]/.T->Subscript[T, 3])z}//CF
];



