(* ::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-01"];
<< FreeLie.m;
IntegrateLieSeries[ls_LieSeries, {s_, s0_, s1_}] := IntegrateLieSeries[ls, {s, s0, s1}] = Module[{ser},
ser=Unique[IntegrateLieSeries];
ser[]=Hold[IntegrateLieSeries[ls, {s, s0, s1}]];
ser[d_Integer] := ser[d] = Expand[Integrate[ls[d], {s,s0,s1}]];
LieSeries[ser]
];
LieSeries /: Integrate[ls_LieSeries, {s_, s0_, s1_}] := IntegrateLieSeries[ls, {s,s0,s1}];


LieMorphism /: Inverse[mor_LieMorphism] := InvertLieMorphism[mor];
InvertLieMorphism[mor_LieMorphism] := InvertLieMorphism[mor] =Module[{uimg},
LieMorphism[Table[
ReleaseHold[Hold[
uimg[]=Hold[Inverse[mor][u]];
uimg[1] = u;
uimg[d_Integer] /; d>1 := uimg[d] = -\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 1\), \(d - 1\)]\((\(mor[uimg[k]]\)[d])\)\);
u -> LieSeries[uimg]
] /. uimg->Unique[InverseLieMorphismOnGenerator]],
{u,mor[Support]}
]]
];


tm[u_,v_,w_] := LieMorphism[\[LeftAngleBracket]u\[RightAngleBracket]->\[LeftAngleBracket]w\[RightAngleBracket], \[LeftAngleBracket]v\[RightAngleBracket]->\[LeftAngleBracket]w\[RightAngleBracket]];
CC[us:{___}, \[Gamma]s:{_LieSeries...}] := LieMorphism[MapThread[Function[{u,\[Gamma]},u -> Ad[\[Gamma]][u]],{us,\[Gamma]s}]];
CC[u_, \[Gamma]_LieSeries] := CC[{u},{\[Gamma]}];
Subscript[CC, u_][\[Gamma]_] := CC[u,\[Gamma]];
RC[us:{___}, \[Gamma]s:{_LieSeries...}] := Inverse[CC[us, -\[Gamma]s]];
RC[u_, \[Gamma]_LieSeries] := RC[{u},{\[Gamma]}];
Subscript[RC, u_][\[Gamma]_] := RC[u,\[Gamma]];
ad[us:{___}, \[Gamma]s:{_LieSeries...}] := LieDerivation[MapThread[Function[{u,\[Gamma]},u -> b[\[Gamma],u]],{us,\[Gamma]s}]];
ad[u_, \[Gamma]_LieSeries] := ad[{u},{\[Gamma]}];
Subscript[ad, u_][\[Gamma]_] := ad[u,\[Gamma]];
(* ad[u_, \[Gamma]_LieSeries] := LieDerivation[u \[Rule] b[\[Gamma], u]];
Subscript[ad, u_][\[Gamma]_] := ad[u,\[Gamma]]; *)
\[Epsilon] /: \[Epsilon]^2=0;
Print /@ {{t=\[LeftAngleBracket]"t"\[RightAngleBracket], u=\[LeftAngleBracket]"u"\[RightAngleBracket], v=\[LeftAngleBracket]"v"\[RightAngleBracket], w=\[LeftAngleBracket]"w"\[RightAngleBracket]},
\[Alpha] = RandomLieSeries[{t,u,v}], \[Delta]\[Alpha] = RandomLieSeries[{t,u,v}],
\[Beta] = RandomLieSeries[{t,u,v}], \[Delta]\[Beta] = RandomLieSeries[{t,u,v}],
\[Gamma] = RandomLieSeries[{t,u,v}], \[Delta]\[Gamma] = RandomLieSeries[{t,u,v}]
};
$SeriesShowDegree=3; $SeriesCompareDegree = 6;


J[u_, \[Gamma]_] := J[u,\[Gamma]] = Module[{s},\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(1\)]\(\((\(\(\[Gamma]\  // \ 
\(\*SubscriptBox[\(RC\), \(u\)]\)[s\ \[Gamma]]\)\  // \ 
\*SubscriptBox[\(div\), \(u\)]\)\  // \ 
\(\*SubscriptBox[\(CC\), \(u\)]\)[\(-s\)\ \[Gamma]])\) \[DifferentialD]s\)\)];
Subscript[J, u_][\[Gamma]_] := J[u,\[Gamma]];


\[CapitalGamma][-1, ___] = MakeLieSeries[0];
\[CapitalGamma][n_, u_LW, \[Gamma]_LieSeries, ss_] := \[CapitalGamma][n,u,\[Gamma],ss] = Module[{s, \[Beta]0},
\[Beta]0=\[CapitalGamma][n-1,u,\[Gamma],s];
\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(ss\)]\(\((\(\[Gamma]\  // \ DerivationExp[
\(\*SubscriptBox[\(ad\), \(u\)]\)[s\ \[Gamma]]]\)\  // \ adSeries[
\*FractionBox[\(ad\), \(
\*SuperscriptBox[\(E\), \(ad\)] - 1\)], \ \[Beta]0])\) \[DifferentialD]s\)\)
];
\[CapitalGamma][u_LW, \[Gamma]_LieSeries, s_] := \[CapitalGamma][u,\[Gamma], s] = Module[{ser},
ser=Unique[\[CapitalGamma]];
ser[]=Hold[\[CapitalGamma][u,\[Gamma]]];
ser[d_Integer] := ser[d] = \[CapitalGamma][d-1, u, \[Gamma], s][d];
LieSeries[ser]
];
\[CapitalGamma][u_LW, \[Gamma]_LieSeries] := \[CapitalGamma][u,\[Gamma]] = Module[{ser,s},
ser=Unique[\[CapitalGamma]];
ser[]=Hold[\[Gamma][u,\[Gamma]]];
ser[d_Integer] := ser[d] = \[CapitalGamma][d-1, u, \[Gamma], s][d] /. s->1;
LieSeries[ser]
];


\[CapitalGamma][-1, ___] = MakeLieSeries[0];
\[CapitalGamma][n_, u_LW, us_List,\[Gamma]s:{_LieSeries...}, ss_] := \[CapitalGamma][n,u,us,\[Gamma]s,ss] = Module[{s,\[Gamma],\[CapitalGamma]0},
\[Gamma]=u /. Thread[us -> \[Gamma]s];
\[CapitalGamma]0=\[CapitalGamma][n-1,u,us,\[Gamma]s,s];
\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(ss\)]\(\((\(\[Gamma]\  // \ DerivationExp[
\*UnderoverscriptBox[\(\[Sum]\), \(i = 1\), \(Length[us]\)]
\(\*SubscriptBox[\(ad\), \(us[[i]]\)]\)[s\ \[Gamma]s[[i]]]]\)\  // \ adSeries[
\*FractionBox[\(ad\), \(
\*SuperscriptBox[\(E\), \(ad\)] - 1\)], \ \[CapitalGamma]0])\) \[DifferentialD]s\)\)
];
\[CapitalGamma][u_LW, us_List, \[Gamma]s:{_LieSeries...}, s_] := \[CapitalGamma][u,us,\[Gamma]s,s] = Module[{ser},
ser=Unique[\[CapitalGamma]];
ser[]=Hold[\[CapitalGamma][u,us,\[Gamma]s]];
ser[d_Integer] := ser[d] = \[CapitalGamma][d-1, u, us, \[Gamma]s, s][d];
LieSeries[ser]
];
\[CapitalGamma][u_LW, us_List, \[Gamma]s:{_LieSeries...}] := \[CapitalGamma][u,us, \[Gamma]s] = Module[{ser,s},
ser=Unique[\[CapitalGamma]];
ser[]=Hold[\[Gamma][u,us, \[Gamma]s]];
ser[d_Integer] := ser[d] = \[CapitalGamma][d-1, u, us, \[Gamma]s, s][d] /. s->1;
LieSeries[ser]
];



