(* ::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.                                                         *)
(************************************************************************)



SetDirectory["C:/drorbn/AcademicPensieve/2014-07/GoodFormulas/"]


<< KnotTheory`


\[CapitalGamma]Collect[\[CapitalGamma][\[Omega]_, \[Lambda]_]] := \[CapitalGamma][Factor[\[Omega]],
Collect[\[Lambda], Subscript[h, _], Collect[#,Subscript[t, _], Factor]&]];
Format[\[CapitalGamma][\[Omega]_,\[Lambda]_]] := Module[{S, M},
S = Union@Cases[\[CapitalGamma][\[Omega],\[Lambda]], Subscript[(h|t), a_] :> a, \[Infinity]];
M = Outer[Factor[\!\(
\*SubscriptBox[\(\[PartialD]\), \(
\*SubscriptBox[\(h\), \(#1\)]\[InvisibleComma]
\*SubscriptBox[\(t\), \(#2\)]\)]\[Lambda]\)]&, S, S];
M = Prepend[M, Subscript[t, #]& /@ S] // Transpose;
M = Prepend[M, Prepend[Subscript[h, #]& /@ S, \[Omega]]];
M // MatrixForm];


\[CapitalGamma] /: \[CapitalGamma][\[Omega]1_, \[Lambda]1_]\[CapitalGamma][\[Omega]2_, \[Lambda]2_] := \[CapitalGamma][\[Omega]1*\[Omega]2, \[Lambda]1+\[Lambda]2];
Subscript[m, a_\[InvisibleComma]b_->c_][\[CapitalGamma][\[Omega]_, \[Lambda]_]] := Module[{\[Alpha],\[Beta],\[Gamma],\[Delta],\[Theta],\[Epsilon],\[Phi],\[Psi],\[CapitalXi],\[Mu]},
({
 {\[Alpha], \[Beta], \[Theta]},
 {\[Gamma], \[Delta], \[Epsilon]},
 {\[Phi], \[Psi], \[CapitalXi]}
})=({
 {\!\(
  \*SubscriptBox[\(\[PartialD]\), \(
   \*SubscriptBox[\(t\), \(a\)], 
   \*SubscriptBox[\(h\), \(a\)]\)]\[Lambda]\), \!\(
  \*SubscriptBox[\(\[PartialD]\), \(
   \*SubscriptBox[\(t\), \(a\)], 
   \*SubscriptBox[\(h\), \(b\)]\)]\[Lambda]\), \!\(
  \*SubscriptBox[\(\[PartialD]\), 
   SubscriptBox[\(t\), \(a\)]]\[Lambda]\)},
 {\!\(
  \*SubscriptBox[\(\[PartialD]\), \(
   \*SubscriptBox[\(t\), \(b\)], 
   \*SubscriptBox[\(h\), \(a\)]\)]\[Lambda]\), \!\(
  \*SubscriptBox[\(\[PartialD]\), \(
   \*SubscriptBox[\(t\), \(b\)], 
   \*SubscriptBox[\(h\), \(b\)]\)]\[Lambda]\), \!\(
  \*SubscriptBox[\(\[PartialD]\), 
   SubscriptBox[\(t\), \(b\)]]\[Lambda]\)},
 {\!\(
  \*SubscriptBox[\(\[PartialD]\), 
   SubscriptBox[\(h\), \(a\)]]\[Lambda]\), \!\(
  \*SubscriptBox[\(\[PartialD]\), 
   SubscriptBox[\(h\), \(b\)]]\[Lambda]\), \[Lambda]}
})/.Subscript[(t|h), a|b]->0;
\[CapitalGamma][(\[Mu]=1-\[Beta])\[Omega], {Subscript[t, c],1}.\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{
RowBox[{"\[Gamma]", "+", 
RowBox[{"\[Alpha]", " ", 
RowBox[{"\[Delta]", "/", "\[Mu]"}]}]}], 
RowBox[{"\[Epsilon]", "+", 
RowBox[{"\[Delta]", " ", 
RowBox[{"\[Theta]", "/", "\[Mu]"}]}]}]},
{
RowBox[{"\[Phi]", "+", 
RowBox[{"\[Alpha]", " ", 
RowBox[{"\[Psi]", "/", "\[Mu]"}]}]}], 
RowBox[{"\[CapitalXi]", "+", 
RowBox[{"\[Psi]", " ", 
RowBox[{"\[Theta]", "/", "\[Mu]"}]}]}]}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}, "Items" -> {}, "ItemsIndexed" -> {}}], "", ")"}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\).{Subscript[h, c],1}]
/. {Subscript[T, a]->Subscript[T, c], Subscript[T, b]->Subscript[T, c]} // \[CapitalGamma]Collect];
Subscript[Rp, a_\[InvisibleComma]b_] := \[CapitalGamma][1, {Subscript[t, a],Subscript[t, b]}.({
 {1, 1-Subscript[T, a]},
 {0, Subscript[T, a]}
}).{Subscript[h, a],Subscript[h, b]}];
Subscript[Rm, a_\[InvisibleComma]b_] := Subscript[Rp, a\[InvisibleComma]b] /. Subscript[T, a]->1/Subscript[T, a];


\[CapitalGamma]Z[L_] := Module[{s, Z, c, k},
s=Skeleton[L];
Z=Times@@PD[L] /. X[i_,j_,k_,l_] :> If[PositiveQ[X[i,j,k,l]], Subscript[Rp, l\[InvisibleComma]i], Subscript[Rm, j\[InvisibleComma]i]];
Do[Z = Z // Subscript[m, s[[c,1]],s[[c,k]] -> s[[c,1]]], {c, Length[s]},{k, 2, Length[s[[c]]]}];
Z];
\[CapitalGamma]A[K_] := \[CapitalGamma]Z[K][[1]] /. Subscript[T, _]:>T;
\[CapitalGamma]MVA[L_Link] := Module[{Hs,\[Omega],\[Mu],A},
{\[Omega],\[Mu]} = List @@ \[CapitalGamma]Z[L];
Hs = Rest[Subscript[h, #]& /@ (First /@ Skeleton[L])];
A=Outer[Coefficient[\[Mu], #1*#2]&,Hs, Hs /. Subscript[h, a_] :> Subscript[t, a]];
Factor[(\[Omega] Det[A-IdentityMatrix@Length@Hs])/(1-Subscript[T, Skeleton[L][[1,1]]])]
]



