(* ::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\\Projects\\OneCo-1604"];
<< Local.m


\[Sigma][\[Gamma]_TSD0] := Keys@@\[Gamma];
Subscript[TSD0[\[Lambda]_], j_] := Lookup[\[Lambda],j,UU@a[1,j,h\[Infinity]]];
UU[u_] // \[Gamma]_TSD0 := CF[u /. \[Lambda]_a :> \[Gamma]@\[Lambda]];
TSD0 /: (\[Gamma]_TSD0)^-1 := Module[{S=\[Sigma]@\[Gamma],m,i,j},
m=Table[Coefficient[Subscript[\[Gamma], i ], a[j,h\[Infinity]]],{i,S}, {j,S}] // Inverse;
TSD0@<|Table[S[[\[Alpha]]]->
CF@UU@Sum[a[m[[\[Alpha],\[Beta]]],S[[\[Beta]]],h\[Infinity]], {\[Beta],Length@S}],
{\[Alpha], Length@S}]|>  ];
a[f_,j_,k_] // \[Gamma]_TSD0 := Module[{S=Keys@@\[Gamma], \[Gamma]i,i},
Switch[{MemberQ[S,j], MemberQ[S,k]},
{False,False}, UU@a[f,j,k],
{True,False}, Subscript[\[Gamma], j] /. a[g_,i_,h\[Infinity]] :> a[f g,i,k],
{False, True}, (\[Gamma]i=\[Gamma]^-1;
CF@Sum[
\[Gamma][bb[S\[Union]{j}][Subscript[\[Gamma]i, i], UU@a[f,j,k]] /. _\[Delta]\[Beta]|_\[Delta]a|_\[Delta]aa -> 0] /. {
a[_,i,h\[Infinity]] :> 0, a[g_,l_,h\[Infinity]] :> a[g/Subscript[b, i],l,i]},
{i,S}]),
{True,True}, ct[h\[Infinity],t\[Infinity]][\[Gamma]@a[f,j,h\[Infinity]], \[Gamma]@a[1,t\[Infinity],k]]  ]];


TSD[\[Lambda]_List]:=TSD[Association@@\[Lambda]];
\[Sigma][\[Gamma]_TSD] := Keys@@\[Gamma];
Subscript[TSD[\[Lambda]_], j_] := Lookup[\[Lambda],j,UU@a[1,j,h\[Infinity]]];
UU[u_] // \[Gamma]_TSD := CF[u /. \[Lambda]_\[Beta]|\[Lambda]_a |\[Lambda]_\[Delta]a|\[Lambda]_\[Delta]aa :> \[Gamma]@\[Lambda]];
TSD0[\[Gamma]_TSD] := Module[{k},
TSD0[Table[k->CF[Subscript[\[Gamma], k]/._\[Delta]\[Beta]|_\[Delta]a|_\[Delta]aa -> 0],{k,\[Sigma]@\[Gamma]}]]];
TSD/:(\[Gamma]1_TSD)**(\[Gamma]2_TSD):=Module[{k},
TSD[Table[k->\[Gamma]2[Subscript[\[Gamma]1, k]],{k,\[Sigma][\[Gamma]1]\[Union]\[Sigma][\[Gamma]2]}]]];


\[Beta][f_]//\[Gamma]_TSD:= Module[{k},
UU[\[Beta][f]]+Sum[ (* desingned to work only if "sum of each column" is 1 *)
ct[h\[Infinity],t\[Infinity]][Subscript[\[Gamma], k]/._a->0, UU[\[Beta][Subscript[b, t\[Infinity]]\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(b\), \(k\)]]f\)]]],
{k,\[Sigma]@\[Gamma]}]];
a[f_,j_,h\[Infinity]] // \[Gamma]_TSD := (\[Beta][f]//\[Gamma])**Subscript[\[Gamma], j];
\[Delta]a[f_,\[CCedilla],k_] // \[Gamma]_TSD := ct[h\[Infinity],t\[Infinity]][UU@\[Delta]a[1,\[CCedilla],h\[Infinity]],TSD0[\[Gamma]][a[f,t\[Infinity],k]]];
\[Delta]a[f_,j_,k_] // \[Gamma]_TSD := UU[\[Delta]\[Beta][1]]**CF[a[f,j,k]//TSD0[\[Gamma]]];
\[Delta]aa[f_,i_,j_,k_,h\[Infinity]]//\[Gamma]_TSD:=(\[Delta]a[f,i,j]//\[Gamma])**Subscript[TSD0[\[Gamma]], k]+Subscript[K\[Delta], j\[InvisibleComma]k]\[Gamma][UU@\[Delta]hb[f,i,j,h\[Infinity]]]; 
\[Delta]aa[f_,k_,h\[Infinity],i_,j_]//\[Gamma]_TSD:=\[Delta]aa[f,i,j,k,h\[Infinity]]//\[Gamma];


Subscript[\[Phi], k_][x_]:=x^-k (E^x-Sum[x^\[Alpha]/\[Alpha]!,{\[Alpha],0,k-1}]);
Ea[t_,j_,k_]:=TSD[{
j->UU[a[1,j,h\[Infinity]]+\[Delta]aa[t,\[CCedilla],h\[Infinity],j,k]+\[Delta]aa[-t Subscript[\[Phi], 1][-t Subscript[b, j]],\[CCedilla],k,j,h\[Infinity]]+\[Delta]aa[-t^2 Subscript[\[Phi], 2][-t Subscript[b, j]],j,k,j,h\[Infinity]]],
k->UU[a[1,k,h\[Infinity]]+hb[-t Subscript[\[Phi], 1][t Subscript[b, j]],j,k,h\[Infinity]]+\[Delta]hb[t^2 Subscript[b, k] E^(t Subscript[b, j]) Subscript[\[Phi], 2][-t Subscript[b, j]],\[CCedilla],j,h\[Infinity]]+\[Delta]aa[-t^2 Subscript[b, j] E^(t Subscript[b, j]) Subscript[\[Phi], 2][-t Subscript[b, j]],\[CCedilla],k,k,h\[Infinity]]+\[Delta]aa[t^2 E^(t Subscript[b, j]) Subscript[\[Phi], 2][-t Subscript[b, j]],j,k,k,h\[Infinity]]+\[Delta]aa[-t Subscript[\[Phi], 1][t Subscript[b, j]]-t^2 Subscript[b, k]Subscript[\[Phi], 2][t Subscript[b, j]],\[CCedilla],h\[Infinity],j,k]+\[Delta]aa[t Subscript[\[Phi], 1][-t Subscript[b, j]]+t^2 Subscript[b, k] E^(t Subscript[b, j]) Subscript[\[Phi], 2][-t Subscript[b, j]],\[CCedilla],k,j,h\[Infinity]]+\[Delta]aa[(t(Subscript[\[Phi], 1][t Subscript[b, j]]-Subscript[\[Phi], 1][-t Subscript[b, j]]))/Subscript[b, j]-((2-2 E^(t Subscript[b, j])+(1+E^(t Subscript[b, j])) t Subscript[b, j]) Subscript[b, k])/
\!\(\*SubsuperscriptBox[\(b\), \(j\), \(3\)]\),j,k,j,h\[Infinity]]]}];
Ea[j_,k_] := Ea[1,j,k];



