Pensieve header: The ugly recovery formulas; continues “k=2 Analysis in QU V5.nb” in pensieve://Projects/SL2Portfolio/.

SetDirectory["C:\\drorbn\\AcademicPensieve\\Talks\\HUJI-1912"];
<< KnotTheory`
$k=2;

(Subscript[𝔼[L_,Q_,P_], $k_]):=𝔼[L,Q,Series[Normal@P,{ϵ,0,$k}]];
(Subscript[(Subscript[𝔼, d_->r_])[L_,Q_,P_], $k_]):=(Subscript[𝔼, d->r])@@(Subscript[𝔼[L,Q,P], $k]);

𝔼3@𝔼[ω_,L_,Q_,Ps_]:=Simplify/@(Subscript[𝔼[L,(ω^(-1)) Q,(ω^(-1))((((ω^(-4))ϵ))^(-1+Range@Length@Ps)).Ps], $k]);
𝔼3@(Subscript[𝔼, sp___])[as___]:=𝔼3@𝔼[as]/.𝔼->(Subscript[𝔼, sp]);

Clear[QP,ω];
QP[Knot[n_,k_]] := QP[Knot[n,k]]=Module[{fname},
fname="../../Projects/SL2Invariant/k=2/Data/"<>ToString[n]<>"_"<>ToString[k]<>".m";
Collect[𝔼3[Get[fname][[2,2]]][[3]] // Normal, ϵ, Simplify]
];
ω[K_Knot]:=ω[K]=Factor[(((QP@K/.ϵ->0))^(-1))];
(Subscript[c, k_,d_])[K_Knot]:=Factor[SeriesCoefficient[QP[K],{y,0,0}, {ϵ,0,k},{a,0,d}]((ω[K])^(1+2k-d))]

p1[K_Knot]:=p1[K]=Factor[((T(-(Subscript[c, 1,0])[K]+ω[K]T(∂_T)ω[K]))/(((T-1))^2))];

p2[K_Knot]:=p2[K]=Expand[-2(Subscript[c, 2,0])[K]+ω[K](Subscript[c, 2,1])[K]];

p2[Knot[8,21]]

MyCollect[ℰ_,vs_List]:=MyCollect[ℰ,vs,Identity];
MyCollect[ℰ_,vs_List,simp_]:=Total[CoefficientRules[ℰ,vs]/.((ps_->c_):>simp[c]Times@@((vs^ps)))];
MyCollect[ℰs_List,vs_List] := MyCollect[#,vs]&/@ℰs;
MyCollect[ℰs_List,vs_List,simp_] := MyCollect[#,vs,simp]&/@ℰs;
MyCollect[sd_SeriesData,vs_List] := MapAt[MyCollect[#,vs]&, sd, 3];
MyCollect[sd_SeriesData,vs_List,simp_] := MapAt[MyCollect[#,vs,simp]&, sd, 3];

RecoveryFormula=(ω^(-1))+(((-2T ω dω)/((T-1)))x y+2T ω dω a +(ω T dω-((((T-1))^2)/T)p1))(ϵ/(ω^3))+(2 T (ω^2)(2 ((dω)^2) T-dω ω-ddω T ω)(a^2)+(((2 (-1+T) p1 ((1+T) ω-3 (-1+T) T dω))/T)+2 ω ((((-1+T))^2)dp1+2 (T^2) (((dω))^2)-T ω(dω+T ddω)))ω a+((T (ω^2)(4 ((dω)^2) (-1+T) T-dω (-3+T) ω-2 ddω (-1+T) T ω))/((((-1+T))^3) ))(x^2)(y^2)-((2 ω(-3 dω p1 (-1+T) T+dp1 (-1+T) T ω+p1 (1+T) ω))/(T ))x y+((4 T (ω^2)(2 ((dω)^2) (1-T) T-dω ω-ddω (1-T) T ω))/((((-1+T))^2) ))a x y-((p2/2)+ω (3 dω p1 (((-1+T))^2)-(((p1 (-1+(T^2))+T (dp1 (((-1+T))^2)+2 ((dω)^2) (T^2))) ω)/T)+T (dω+ddω T) (ω^2))))((ϵ^2)/(ω^5));

Monitor[Union@Table[
Simplify[r=-QP[K]+RecoveryFormula/. {ω->ω[K],dω->(∂_T)ω[K],ddω->(∂_(T,T))ω[K],p1->p1[K],dp1->(∂_T)p1[K],p2->p2[K]}],
{K,AllKnots[{3,10}]}],K]

MyCollect[Log[(ω RecoveryFormula/.ϵ->(ω^2)ϵ)+((O[ϵ])^3)], {a,x,y},FullSimplify]

mencode={dω->A,ddω->B,p1->(Subscript[p, 1]),dp1->D, p2->(Subscript[p, 2])};
tencode={"A"->"\\dot{\\omega}", "B"->"\\ddot{\\omega}", "D"->"\\dot{p}_1"};

(Subscript[C, kij]) is the coefficient of (ϵ^k)(((a^i)(xy))^j) in Log[(ω RecoveryFormula/.ϵ->(ω^2)ϵ)+((O[ϵ])^3)]; (Subscript[T, kij]) is its TeXForm:

(Subscript[T, 100])=ToString@TeXForm[((Subscript[C, 100])=HoldForm[T ω dω -((p1 (((T-1))^2))/T)])/. mencode];
(Subscript[T, 110])=ToString@TeXForm[((Subscript[C, 110])=HoldForm[2T ω dω])/. mencode];
(Subscript[T, 101])=ToString@TeXForm[((Subscript[C, 101])=HoldForm[((2T ω dω )/(1-T))])/. mencode];
If[
Simplify[SeriesCoefficient[Log[(ω RecoveryFormula/.ϵ->(ω^2)ϵ)+((O[ϵ])^3)],1]==ReleaseHold[(Subscript[C, 100])]+ReleaseHold[(Subscript[C, 110])]a+ReleaseHold[(Subscript[C, 101])]x y],
tex=ToString@StringReplace["\\[
  P^{(1)} =
    \\left(T100 \\right)
    + T110 a
    + T101 xy,
\\]
",
{"T100"->(Subscript[T, 100]), "T110"->(Subscript[T, 110]),"T101"->(Subscript[T, 101])}];
tex=StringReplace[tex, tencode];
DeleteFile["P1.tex"];
WriteString["P1.tex", tex];
Close["P1.tex"];
tex
]

(Subscript[T, 200])=ToString@TeXForm[((Subscript[C, 200])=HoldForm[(1/(2(T^2)))((T^2) ((ω^2) (2 dp1 (((T-1))^2)+T (3 ((dω)^2) T-2 (dω+ddω T) ω))-p2)-(p1^2) (((T-1))^4)-2 p1 (T-1) T ω (2 dω (T-1) T-(1+T) ω))])/. mencode];
(Subscript[T, 210])=ToString@TeXForm[((Subscript[C, 210])=HoldForm[((2ω(p1 ((T^2)-1) ω-2 dω p1 (((T-1))^2) T+T (dp1 (((T-1))^2)+((dω)^2) (T^2)) ω-(T^2) (dω+ddω T) (ω^2)))/T)])/. mencode];
(Subscript[T, 220])=ToString@TeXForm[((Subscript[C, 220])=HoldForm[2 T (ω^2) (((dω)^2) T-dω ω-ddω T ω)])/. mencode];
(Subscript[T, 201])=ToString@TeXForm[((Subscript[C, 201])=HoldForm[2 ω (2 dω p1 (T-1)+((((dω)^2) (T^2) ω)/(T-1))-(((dp1 (T-1) T+p1 (1+T)) ω)/T))])/. mencode];
(Subscript[T, 211])=ToString@TeXForm[((Subscript[C, 211])=HoldForm[((4 T  (ω^2) (ddω (T-1) T ω-((dω)^2) (T-1) T-dω ω))/(((T-1))^2))])/. mencode];
(Subscript[T, 202])=ToString@TeXForm[((Subscript[C, 202])=HoldForm[((T (ω^2) (2 ((dω)^2) (T-1) T-dω (T-3) ω-2 ddω (T-1) T ω))/(((T-1))^3))])/. mencode];
If[
Simplify[SeriesCoefficient[Log[(ω RecoveryFormula/.ϵ->(ω^2)ϵ)+((O[ϵ])^3)],2]==ReleaseHold[(Subscript[C, 200])]+ReleaseHold[(Subscript[C, 210])]a+ReleaseHold[(Subscript[C, 220])](a^2)+ReleaseHold[(Subscript[C, 201])]x y+ReleaseHold[(Subscript[C, 211])]a x y+ReleaseHold[(Subscript[C, 202])](x^2)(y^2)],
tex=ToString@StringReplace["\\begin{multline*} \\scriptstyle
  P^{(2)} =
    T200 \\\\ \\scriptstyle
    + T210 a \\\\ \\scriptstyle
    + T220 a^2
    + T201 x y \\\\ \\scriptstyle
    + T211 a x y
    + T202 x^2y^2.
\\end{multline*}",
{"T200"->(Subscript[T, 200]), "T210"->(Subscript[T, 210]),"T220"->(Subscript[T, 220]),"T201"->(Subscript[T, 201]),"T211"->(Subscript[T, 211]),"T202"->(Subscript[T, 202])}];
tex=StringReplace[tex, tencode];
DeleteFile["P2.tex"];
WriteString["P2.tex", tex];
Close["P2.tex"];
tex
]