(* ::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\\2023-12"];
Once[
<< KnotTheory`;
<< "../Talks/Oaxaca-2210/Rot.m"
]


(* ::Input::Initialization:: *)
K1=EPD[Subscript[X, 1,2]];
K3=EPD[Subscript[X, 1,4],Subscript[X, 5,2],Subscript[X, 3,6]];
K8=Knot[8,17];
K10=Knot[10,165];


(* ::Input::Initialization:: *)
mat[K_,flip_]:=Module[{},
{Cs,\[CurlyPhi]}=Rot[K]/.{s_Integer,i_,j_}/;flip:>{s,j,i};
n=Length[Cs]; bridges=tunnels={}; bn=tn=0; (* completed features *)
cfb=\[Not]flip; (* current feautre is bridge *); cfs=0; (* current feature start *)
t\[Nu]ut=0;(* Total \[Nu] at up transitions *) t\[Nu]dt=0;(* Total \[Nu] at down transitions *)
 \[Nu]={l\[Nu]=0}; \[Phi]={}; Q=0;
For[k=1,k<=2n,++k,
Cs/.{
{s_,k,j_}:>(
AppendTo[\[Phi],bn+1];
If[\[Not]cfb,AppendTo[tunnels,{cfs,k}]; ++tn;cfb=True;cfs=k; t\[Nu]ut+=l\[Nu]; Q+=T^l\[Nu] (T-1)Subscript[\[Beta], bn+1] Subscript[\[Tau], tn]];
AppendTo[\[Nu],l\[Nu]+=s];
),
{s_,i_,k}:>(
AppendTo[\[Phi],tn+1];
If[cfb,AppendTo[bridges,{cfs,k}]; ++bn;cfb=False;cfs=k; t\[Nu]dt+=l\[Nu]; Q+=T^l\[Nu] (1-T)Subscript[\[Beta], bn] Subscript[\[Tau], tn+1] ];
AppendTo[\[Nu],l\[Nu]-=s];
)
};
If[k==1,ffb=cfb];
Cs/.{
{s_,k,j_}/;k>j:>(Q+=T^\[Nu][[k]] (T-1)(T^s-1)Subscript[\[Beta], \[Phi][[k]]] Subscript[\[Tau], \[Phi][[j]]]),
{s_,i_,k}/;k>i:>(Q+=T^\[Nu][[i]] (T-1)(T^s-1)Subscript[\[Beta], \[Phi][[i]]] Subscript[\[Tau], \[Phi][[k]]])
}
];
Factor@Table[\!\(
\*SubscriptBox[\(\[PartialD]\), \(
\*SubscriptBox[\(\[Beta]\), \(i\)], 
\*SubscriptBox[\(\[Tau]\), \(j\)]\)]Q\)/(T-1),{i,Max[bn,tn]},{j,Max[bn,tn]}]
];
mat[K_]:=mat[K,False];
mat[Flip@K_]:=mat[K,True];



