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


AutoAd[B_, x_][y_] := Module[{pows, states, i, s, seq,sh=5, dseq, sf1, sf2, sf, t1, n},
pows = NestList[B[x,#]&, y, 20];
states = Union[Cases[pows, s_\[Beta]|s_\[Delta]\[Beta]|s_a|s_c|s_ao|s_ca|s_aao :> ReplacePart[s, 1->_], \[Infinity]]];
UU@Sum[
seq=Cases[{#},states[[i]], \[Infinity]]& /@ pows;
seq=Replace[seq,{{_[f_,___]}:>f, {}->0}, {1}];
dseq=Drop[seq, sh];
If[Union[Length[MonomialList[#]]& /@ dseq]==={1}\[And]Union[Length[FactorTermsList[#]]& /@ dseq]==={2},
sf1 = FindSequenceFunction[FactorTermsList[#][[1]]& /@ dseq];
sf2 = FindSequenceFunction[FactorTermsList[#][[2]]& /@ dseq];
sf = (sf1[#]sf2[#]&),
(*Else*) sf=FindSequenceFunction[dseq, FunctionSpace->{"ConstantRecursive","HolonomicSequence", "Polynomial", "RationalFunction","HypergeometricTerm"}]];
ReplacePart[states[[i]], 1 ->FullSimplify[ \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(n = 0\), \(sh - 1\)]
\*FractionBox[\(seq[[n + 1]]\), \(n!\)]\)+ \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(n = sh\), \(\[Infinity]\)]
\*FractionBox[\(sf[n + 1 - sh]\), \(n!\)]\)]],
{i,Length@states}] ];



