home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e032 / 3.ddi / FILES / INTEGRAT.PAK / MAINALGO.M < prev    next >
Encoding:
Text File  |  1992-07-29  |  47.7 KB  |  1,264 lines

  1.  
  2. (****************************************************************************
  3. *
  4. *                       Victor Adamchik
  5. *                Package for Evaluation Integrals
  6. *
  7. *               
  8. *****************************************************************************) 
  9.  
  10.  
  11.  IntegrateG[f_,{x_,xmin_,xmax_}] :=  
  12.   Block[ {r,inter,z,positivearg=positivetrigarg={},trigintegral=False,
  13.       $IntegrateAssumptions=sumintegrals=True,dummy=var},
  14.     r = PowerExpand[f,{x}]//.{E^(d_.+Complex[c_,a_] b_.) :> 
  15.                                E^(c b+d) Cos[a b]+I E^(c b+d) Sin[a b]}//.
  16.         {(n_ z_)^k_ :> n^k z^k/; NumberQ[N[n]]};
  17.     inter = (Numerator[r]/Factor[Denominator[r]])/.InputHard; 
  18.     If[ FreeQ[inter, MeijerG[__]],
  19.     inter = Dispatcher[1,r,x,xmin,xmax],
  20.     inter = Dispatcher[1,inter,x,xmin,xmax];
  21.     If[ !FreeQ[inter,FailInt], inter = Dispatcher[1,r,x,xmin,xmax] ]
  22.     ];
  23.     If[ !FreeQ[inter,FailInt],
  24.         If[ PolynomialQ[Numerator[r],x] && PolynomialQ[Denominator[r],x],
  25.             inter = Dispatcher[1,Apart[r,x],x,xmin,xmax]
  26.         ];
  27.         If[ !FreeQ[inter,FailInt] && xmin=!=0 && FreeQ[xmin,DirectedInfinity],
  28.             inter = Dispatcher[1,f/.x->z+xmin,z,0,
  29.                        If[ !FreeQ[xmax,DirectedInfinity],xmax,xmax-xmin] ]
  30.         ]
  31.     ];    
  32.     inter = TransfAnswer[inter/.SimpGfunction]; 
  33.     $IntegrateAssumptions=$IntegrateAssumptions//SimpLogic;
  34.     If[ trigintegral,
  35.         If@@{$IntegrateAssumptions, inter, ComplexInfinity}, 
  36.     inter
  37.     ]/; SimpLogic[$IntegrateAssumptions]=!=False && And@@(FreeQ[inter,#]&/@{
  38.         Indeterminate,FailInt,MeijerG,KellyIntegrate,FailIntDiv})
  39.   ] /; FreeQ[{xmin, xmax}, Complex] &&  
  40.   And@@(FreeQ[Hold[{f,xmin,xmax}],#]&/@{Blank,Integrate,IntegrateG}) &&
  41.   Convergent[f,{x,xmin,xmax}]  
  42.  
  43.  Attributes[ IntegrateG ] = { HoldFirst, ReadProtected }
  44.  
  45. (* ======================================================================== *)
  46.  
  47.  Dispatcher[done_,c_,x_,xmin_,xmax_] := FailInt/;Not[FreeQ[{done,c},FailInt]]
  48.  
  49.  Dispatcher[done_,0,x_,xmin_,xmax_] := 0
  50.  
  51.  Dispatcher[1,c_,x_,xmin_,xmax_] := c (xmax-xmin)/;FreeQ[c,x]
  52.  
  53.  Dispatcher[done_,c_,x_,xmin_,xmax_] := 
  54.    c Dispatcher[done,1,x,xmin,xmax]/;FreeQ[c,x] && c=!=1
  55.  
  56.  Dispatcher[done_,c_ f_,x_,xmin_,xmax_] := 
  57.     c Dispatcher[done,f,x,xmin,xmax]/;FreeQ[c,x]
  58.  
  59.  Dispatcher[done_,f_,x_,xmin_,xmax_] := 
  60.     -If[ xmax<0, 
  61.         Module[ {z},
  62.            Dispatcher[done/.x->-z,PowerExpand[f/.x->-z,{z}],z,-xmin,-xmax] ],      
  63.         Dispatcher[done,f,x,xmax,xmin]
  64.      ]/;
  65.  NumberQ[xmin] && NumberQ[xmax] && xmin > xmax
  66.  
  67.  Dispatcher[done_,f_,x_,-Infinity,Infinity] := 
  68.   Module[ {z,answer},
  69.    If[ Expand[f/.x->-z] === Expand[f/.x->z],
  70.        2 Dispatcher[done,f,x,0,Infinity],
  71.        answer = 
  72.            Dispatcher[done,ExpandDenominator[Together[
  73.                    (f/.x->z) + PowerExpand[(f/.x->-z), {z}] ]],z,0,Infinity];
  74.        If[ FreeQ[answer,FailInt],
  75.            answer,
  76.            Dispatcher[done,f,x,0,Infinity] +
  77.            Dispatcher[done,PowerExpand[(f/.x->-z)/.z->x,{x}],x,0,Infinity]                  
  78.     ]
  79.      ]
  80.   ]
  81.  
  82.  Dispatcher[done_,f_,x_,-Infinity,xmax_/; xmax=!=Infinity] := 
  83.   Module[ {z},
  84.     Dispatcher[done/.x->-z,PowerExpand[f/.x->-z,{z}],z,-xmax,Infinity]
  85.   ] 
  86.  
  87.  Dispatcher[done_,f_,x_,0,xmax_] := 
  88.     Dispatcher[done,Together[f/.HBfun],x,0,xmax]/;
  89.   Not[FreeQ[f,Csch[_]]] || Not[FreeQ[f,Sech[_]]]
  90.  
  91.  Dispatcher[done_,f_,x_,0,xmax_] := 
  92.     Dispatcher[done,Factor[Expand[f/.HBfun]],x,0,xmax] /;
  93.  Not[FreeQ[f,Sinh[_]]] || Not[FreeQ[f,Cosh[_]]]
  94.     
  95.  Dispatcher[done_,f_/;Not[FreeQ[f,E]],x_,0,xmax_/; xmax=!=Infinity] :=
  96.     AnalysExp1[done,f,x,0,xmax]
  97.         
  98.  Dispatcher[done_,f_,x_,xmin_,xmax_] :=
  99.     Module[ {inter},
  100.       inter = f/.ExpandIntoTrig/.{
  101.                Sin[z_. Complex[a_,b_]] :>
  102.                  Sin[z a] Cos[z b I] + Cos[z a] Sin[z b I]};
  103.       Dispatcher[done,Expand[inter], x,xmin,xmax] /; inter =!= f
  104.     ] /;
  105.  (!FreeQ[f,Sin[_]] || !FreeQ[f,Cos[_]]) && !FreeQ[f,Complex]
  106.  
  107.  Dispatcher[1,f1_[w1_]^n_. f2_[w2_]^m_.,x_,0,xmax_/;xmax=!=Infinity] :=
  108.     AnalysTrig[1,f1[w1]^n,f2[w2]^m,x,xmax]/;
  109.  Complement[{f1,f2},{Sin,Cos,Sec,Csc,Tan,Cot}]==={}
  110.  
  111.  Dispatcher[1,x_ f_[w_]^n_.,x_,0,xmax_/;xmax=!=Infinity] :=
  112.     AnalysTrig1[1,f[w]^n,x,x,xmax]/;
  113.  Complement[{f},{Sin,Cos,Sec,Csc,Tan,Cot}]==={}
  114.  
  115.  Dispatcher[1,f_[w_]^n_.,x_,0,xmax_/;xmax=!=Infinity] :=
  116.     AnalysTrig1[1,f[w]^n,1,x,xmax]/;
  117.  Complement[{f},{Sin,Cos,Sec,Csc,Tan,Cot}]==={}
  118.     
  119.  Dispatcher[done_,f_/;!FreeQ[f,Log[_]],x_,xmin_,xmax_] :=
  120.     AnalysLog[done,f,x,xmin,xmax]
  121.  
  122.  Dispatcher[1,(b_+a_ x_^dg_.)^n_Integer?Positive f_.,     
  123.           x_,0,xmax_/;xmax=!=Infinity]:=
  124.     KellyIntegrate[f (b+a x^dg)^n,{x,0,xmax}] 
  125.  
  126.  Dispatcher[done_,(b_ + a_ x_^dg_.)^n_ f_.,x_,0,xmax_/;xmax=!=Infinity] :=
  127.     AnalysAlg[done,b,1,a x^dg,n,f,x,{0,xmax}] /;
  128.  FreeQ[b,x] && FreeQ[a,x] && Znak[a] && Expand[b+a xmax^dg]=!=0
  129.  
  130.  Dispatcher[done_,(f1_ + f2_)^n_ f_.,x_,xmin_,xmax_] :=
  131.     AnalysAlg[done,f1,1,Expand[f2],n,f,x,{xmin,xmax}] /;
  132.  FreeQ[f1,x] && Not[FreeQ[f2,x]] 
  133.  
  134.  Dispatcher[done_,(f1_ + f2_)^n_ f_.,x_,xmin_,xmax_] :=
  135.     AnalysAlg[done,1,1,Simplify[f2/f1],n,f f1^n,x,{xmin,xmax}] /;
  136.  Not[FreeQ[f1,x]] && Not[FreeQ[f2,x]] 
  137.  
  138.  Dispatcher[1,f_,x_,a_/;a=!=0&&a=!=-Infinity,b_/;b=!=0&&b=!=Infinity] := 
  139.     Block[ {z, HyperInteg},
  140.      positiveList[a]; positiveList[b];
  141.      Dispatcher[1,MeijerG[{},{1},{0},{},{1,z/b}] (f/.x->z) -
  142.                   If[ NumberQ[a] && Im[a]==0 && a<0,
  143.                       -MeijerG[{},{1},{0},{},{1,-z/a}] (f/.x->-z),
  144.                       MeijerG[{},{1},{0},{},{1,z/a}] (f/.x->z)
  145.           ],
  146.                 z,0,Infinity] 
  147.    ] 
  148.    
  149.  Dispatcher[1,f_/;Head[Expand[f]]==Plus,x_,xmin_,xmax_] := 
  150.     Block[ {IntFF,inter},
  151.       sumintegrals=False;
  152.       inter = Dispatcher[1,#,x,xmin,xmax]&/@Expand[f]; 
  153.       IntFF[1,Together[inter/.IntFF[a_,b_,c_] :> a b],x]
  154.     ]
  155.  
  156.  Dispatcher[done_,f_,x_,xmin_/;xmin=!=0 && xmin=!=-Infinity,Infinity] := 
  157.     If[ done=!=1,
  158.         Dispatcher[done,f,x,0,Infinity],
  159.         If[ !NumberQ[N[xmin]] || Positive[xmin],
  160.             $IntegrateAssumptions = $IntegrateAssumptions && Positive[xmin];
  161.         Dispatcher[MeijerG[{1},{},{},{0},{1,x/xmin}],f,x,0,Infinity],
  162.         Module[ { z },
  163.            Dispatcher[1,(f/.x->-z)/.z->x,x,0,-xmin] +
  164.            Dispatcher[1,f,x,0,Infinity] ]
  165.         ]
  166.     ]        
  167.  
  168.  Dispatcher[done_,f_,x_,0,xmax_/;xmax=!=Infinity] :=
  169.     If[ done=!=1,
  170.         Dispatcher[done,f,x,0,Infinity],
  171.         If[ !NumberQ[N[xmax]] || Positive[xmax],
  172.             $IntegrateAssumptions = $IntegrateAssumptions && Positive[xmax];
  173.         Dispatcher[MeijerG[{},{1},{0},{},{1,x/xmax}],f,x,0,Infinity],
  174.         Module[ { z }, -Dispatcher[1,(f/.x->-z)/.z->x,x,0,-xmax] ]
  175.         ]
  176.     ]        
  177.  
  178.  Dispatcher[done_, a_^(b_. x_^dg_.) f_.,x_,0,Infinity] :=
  179.     Dispatcher[done Release[
  180.       InputElem[Hold[E^(-(-b) x^dg Log[a])],x]], f,x,0,Infinity]/;
  181.   Not[SameQ[a,E]] && FreeQ[a,x] && FreeQ[b,x] && FreeQ[dg,x] 
  182.     
  183.  Dispatcher[done_,f_/;!FreeQ[f,Exp[_]],x_,0,Infinity] :=
  184.     AnalysExp2[done,f,x,0,Infinity] 
  185.  
  186.  Dispatcher[done_,MeijerG[par__] f_/;FreeQ[f,MeijerG[__]],x_,0,Infinity] := 
  187.     Dispatcher[done MeijerG[par],f,x,0,Infinity]/; !MatchQ[f,x^_.]
  188.  
  189.  Dispatcher[done_,f_,x_,0,Infinity] := IntFF[ done,f,x]
  190.  
  191.  Dispatcher[done_,f_,x_,xmin_,xmax_] := f FailInt
  192.  
  193. (*****************************************************************************
  194. *                     Search Logarithmic Expression
  195. *
  196. *****************************************************************************)
  197.  
  198.  AnalysLog[1,Log[w_. x_^dg_.]^n_. f_.,x_,0,Infinity] := 
  199.   (-1)^n AnalysLog[1,Log[w^(-1) x^(-dg)]^n f,x,0,Infinity]/;
  200.  IntegerQ[n] && n>0 && IntegerQ[dg] && dg<0
  201.  
  202.  AnalysLog[1,Log[w_. x_^dg_.]^n_. f_.,x_,0,Infinity] := 
  203.   Module[ {z,var,answer},
  204.     answer = Dispatcher[1,PowerExpand[(f/.x->w^(-1/dg) z^(1/dg))*
  205.                z^(1/dg-1+var),{z}],z,0,Infinity];
  206.     If[ Not[FreeQ[answer,FailInt]], FailInt,
  207.     If[Not[NumberQ[dg]] , 1, Sign[dg]] dg^(-1) w^(-1/dg) n!*
  208.     Coefficient[Expand[Normal[Series[answer,
  209.                                     {var,0,n}] ]],var,n]]
  210.   ]/;IntegerQ[n] && n>0
  211.  
  212.  AnalysLog[done_,Log[w_. x_^dg_.]^n_. f_.,x_,xmin_/;xmin=!=0,Infinity] := 
  213.     If[ SameQ[w xmin^dg,1] && FreeQ[{dg,w},x] && !Znak[w],
  214.         Dispatcher[ done*
  215.           If[ Not[NumberQ[dg]] || dg > 0, Log[w x^dg]^n/.LogRule1,
  216.               (-1)^n Log[w^(-1) x^(-dg)]^n/.LogRule1 ],f,x,xmin,Infinity],
  217.     FailInt ] /;IntegerQ[n] && n>0
  218.  
  219.  AnalysLog[done_,Log[w_. x_^dg_.]^n_. f_.,x_,0,xmax_/;xmax=!=Infinity] :=
  220.     If[ SameQ[w xmax^dg,1] && FreeQ[{dg,w},x] && !Znak[w], 
  221.         Dispatcher[ done *
  222.           If[ Not[NumberQ[dg]] || dg > 0 ,Log[w x^dg]^n/.LogRule2,
  223.               (-1)^n Log[w^(-1) x^(-dg)]^n/.LogRule2 ],f,x,0,xmax],
  224.     FailInt ] /;IntegerQ[n] && n>0
  225.  
  226.  AnalysLog[done_,Log[w_. x_^dg_.]^n_. f_.,x_,xmin_/;xmin=!=0,Infinity] := 
  227.   Module[ {z},
  228.     If[ SameQ[w xmin^dg,1] && FreeQ[w,x] && Not[Znak[w]],
  229.     If[ done===1 && (Not[NumberQ[dg]] || dg > 0),
  230.         Dispatcher[ done,z^n* 
  231.        PowerExpand[E^(z/dg) f//.x->(1/w)^(1/dg) E^(z/dg), {z,E}],
  232.                     z,0,Infinity] (1/w)^(1/dg)/dg,
  233.         (-1)^(-n) AnalysLog[done,Log[w^(-1) x^(-dg)]^n f,x,xmin,Infinity] ],
  234.      FailInt ] ] 
  235.  
  236.  AnalysLog[done_,Log[w_. x_^dg_.]^n_. f_.,x_,0,xmax_/;xmax=!=Infinity] := 
  237.   Module[ {z},
  238.     If[ SameQ[w xmax^dg,1] && FreeQ[w,x] && Not[Znak[w]],
  239.     If[ done===1 && (Not[NumberQ[dg]] || dg < 0),
  240.         -Dispatcher[ done,z^n *
  241.         PowerExpand[E^(z/dg) f//.x->(1/w)^(1/dg) E^(z/dg), {z,E}],
  242.              z,0,Infinity] (1/w)^(1/dg)/dg,
  243.         (-1)^(-n) AnalysLog[done,Log[w^(-1) x^(-dg)]^n f,x,0,xmax] ],
  244.     FailInt ] ] 
  245.  
  246.  AnalysLog[1,Log[g_[a_. x_]]^n_. f_.,x_,0,xmax_] := 
  247.   Module[ {z},
  248.     Which[
  249.      g===Tan && xmax=== Pi/(4 a),
  250.     Dispatcher[1,Log[z]^n (1+z^2)^(-1) (f//.x->ArcTan[z]/a)//.LogTrig,
  251.                z,0,1]/a,
  252.      g===Tan && xmax=== Pi/(2 a),
  253.     Dispatcher[1,Log[z]^n (1+z^2)^(-1) (f//.x->ArcTan[z]/a)//.LogTrig,
  254.                z,0,Infinity]/a,
  255.      g===Sin && xmax=== Pi/(2 a),
  256.     Dispatcher[1,Log[z]^n (1-z^2)^(-1/2)* 
  257.             (f/.x->ArcSin[z]/a)//.LogTrig,z,0,1]/a,
  258.      g===Csc && xmax=== Pi/(2 a),
  259.     Dispatcher[1,Log[1/z]^n (1-z^2)^(-1/2) (f//.x->ArcSin[z]/a)//.LogTrig,
  260.                z,0,1]/a,
  261.      g===Cos && xmax=== Pi/(2 a),
  262.     Dispatcher[1,Log[z]^n (1-z^2)^(-1/2) (f//.x->ArcCos[z]/a)//.LogTrig,
  263.                z,0,1]/a, 
  264.      g===Sec && xmax=== Pi/(2 a),
  265.     Dispatcher[1,Log[1/z]^n (1-z^2)^(-1/2) (f//.x->ArcCos[z]/a)//.LogTrig,
  266.                z,0,1]/a, 
  267.      g===Sin && xmax=== Pi/a,
  268.     Dispatcher[1,Log[z]^n (1-z^2)^(-1/2) (f//.x->ArcSin[z]/a)//.LogTrig,
  269.               z,0,1]/a + 
  270.     AnalysLog[1,Log[Cos[a z]]^n (f//.x->z+Pi/(2 a))/.ExpandIntoTrig,
  271.               z,0,Pi/(2 a)],
  272.      True, FailInt
  273.     ]]/; FreeQ[a,x] && Complement[{g},{Sin,Cos,Sec,Csc,Tan}]==={}
  274.  
  275.  AnalysLog[1,h_[a_. Log[x_]]^n_. f_.,x_,0,1] := 
  276.    Module[ {z},
  277.       If[ h===Sin,-1,1] *
  278.       Dispatcher[1,h[a z] PowerExpand[E^(-z) f/.x->E^(-z),{z,E}],z,0,Infinity]
  279.    ]/;FreeQ[a,x] && Complement[{h},{Sin,Cos}]==={}
  280.  
  281.  AnalysLog[1,Log[a_+b_] f_.,x_,0,xmax_] := 
  282.    Module[ {inter},
  283.     inter = Log[a]//.{
  284.             Log[q_ w_] :> Log[q] + Log[w]/;!FreeQ[q w, x],
  285.         Log[q_^n_] :> n Log[q]/;!FreeQ[q w, x]};
  286.     If[ Head[inter]===Plus,
  287.         Map[ Dispatcher[1,f #,x,0,xmax]&,inter ],
  288.         Dispatcher[1,inter f,x,0,xmax]
  289.       ] + 
  290.      AnalysLog[1,Log[1+Expand[b/a]] f,x,0,xmax]
  291.    ]/;
  292.    Not[FreeQ[b,x]] && Not[FreeQ[a,x]] && Not[Znak[a]] && Not[Znak[b]]  
  293.  
  294.  AnalysLog[done_,Log[1 + a_ x_^p_.]^n_. f_.,x_,0,xmax_] := 
  295.   Module[ {z},
  296.     If[ Not[Znak[p]],
  297.        p^(-1) Dispatcher[(done//.x->z^(1/p)),InputElem[Log[1+a z]^n,z] *
  298.                PowerExpand[(f//.x->z^(1/p)) z^(1/p-1),{z}],z,0, xmax^p  ],
  299.        (-p)^(-1) Dispatcher[(done//.x->z^(-1/p)),InputElem[Log[1+a/z]^n,z]*
  300.                PowerExpand[(f//.x->z^(-1/p)) z^(-1/p-1),{z}],z,0,xmax^(-p)] ]
  301.   ]/;xmax=!=Infinity && FreeQ[{a,p},x] && 
  302.      Expand[1+a xmax^p]===0 && IntegerQ[n] 
  303.  
  304.  AnalysLog[done_,Log[1 + a_. x_^p_.]^n_. f_.,x_,0,xmax_] := 
  305.   Module[ {z},
  306.     If[ Not[Znak[p]],
  307.        p^(-1) Dispatcher[done//.x->z^(1/p),InputElem[Log[1+a z]^n,z] *
  308.                PowerExpand[(f//.x->z^(1/p)) z^(1/p-1),{z}],z,0,
  309.          If[xmax===Infinity,Infinity,xmax^p] ],
  310.        (-p)^(-1) Dispatcher[done//.x->z^(-1/p), InputElem[Log[1+a/z]^n,z] *
  311.                PowerExpand[(f//.x->z^(-1/p)) z^(-1/p-1),{z}],z,0,
  312.          If[xmax===Infinity,Infinity,xmax^(-p)]] ]
  313.   ]/;FreeQ[{a,p},x] && IntegerQ[n]
  314.  
  315.  AnalysLog[done_,Log[1 + a_. x_^p_.]^n_. f_.,x_,xmin_,Infinity] := 
  316.   Module[ {z},
  317.     If[ Not[Znak[p]],
  318.        p^(-1) Dispatcher[done//.x->z^(1/p),InputElem[Log[1+a z]^n,z] *
  319.          PowerExpand[(f//.x->z^(1/p)) z^(1/p-1),{z}],z,xmin^p,Infinity],
  320.        (-p)^(-1) Dispatcher[done//.x->z^(-1/p),InputElem[Log[1+a/z]^n,z] *
  321.          PowerExpand[(f//.x->z^(-1/p)) z^(-1/p-1),{z}],z,xmin^(-p),Infinity] ]
  322.   ]/;FreeQ[a,x] && FreeQ[p,x] && IntegerQ[n]
  323.  
  324.  AnalysLog[1,Log[1 + a_. E^(b_. x_)]^n_. f_.,x_,0,Infinity] := 
  325.   Module[ {z},
  326.    If[ Not[Znak[b]],
  327.    b^(-1) Dispatcher[1,Log[1+a z]^n (f//.x->1/b Log[z])/z,z,1,Infinity],
  328.    -b^(-1) Dispatcher[1,Log[1+a z]^n (f//.x->1/b Log[z])/z,z,0,1] ]
  329.     ]/; FreeQ[b,x] && FreeQ[a,x]
  330.  
  331.  AnalysLog[1,Log[1+b_. f_[a_. x_]^m_.]^n_. g_[w_]^m_.,x_,0,xmax_] := 
  332.   Module[ {int},
  333.     int = Integrate[g[w]^m,x];
  334.     (int Log[1+b f[a x]^m]^n/.{x->xmax}) - 
  335.     (int Log[1+b f[a x]^m]^n/.{x->0}) +
  336.     b m Map[ Dispatcher[1,#/(1+b f[a x]^m),x,0,xmax]&,
  337.              Expand[int f[a x]^(m-1) D[f[a x],x], Trig->True] ] 
  338.     ]/; FreeQ[a,x] && xmax=== Pi/(2 a) && IntegerQ[n] &&
  339.   Complement[{f,g},{Sin,Cos}]==={}
  340.  
  341.  AnalysLog[1,Log[1+b_. Sin[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] := 
  342.   Module[ {z},
  343.     Dispatcher[1,Log[1+b z^m]^n (1-z^2)^(-1/2) (f//.x->ArcSin[z]/a)//.LogTrig,
  344.                z,0,1]/a
  345.     ]/; FreeQ[a,x] && xmax=== Pi/(2 a) && IntegerQ[n]
  346.  
  347.  AnalysLog[1,Log[1+b_. Cos[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] := 
  348.   Module[ {z},
  349.     Dispatcher[1,Log[1+b z^m]^n (1-z^2)^(-1/2) (f//.x->ArcCos[z]/a)//.LogTrig,
  350.                z,0,1]/a 
  351.     ]/; FreeQ[a,x] && xmax=== Pi/(2 a) && IntegerQ[n]
  352.  
  353.  AnalysLog[1,Log[1+b_. Tan[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] := 
  354.   Module[ {z},
  355.     Dispatcher[1,Log[1+b z^m]^n (1+z^2)^(-1) (f//.x->ArcTan[z]/a)//.LogTrig,
  356.                z,0,Infinity]/a 
  357.     ]/; FreeQ[a,x] && xmax=== Pi/(2 a) && IntegerQ[n]
  358.  
  359.  AnalysLog[1,Log[1+b_. Cot[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] := 
  360.   Module[ {z},
  361.     Dispatcher[1,Log[1+b z^(-m)]^n (1+z^2)^(-1) *
  362.         (f//.x->ArcTan[z]/a)//.LogTrig,z,0,Infinity]/a 
  363.     ]/; FreeQ[a,x] && xmax=== Pi/(2 a) && IntegerQ[n]
  364.  
  365.  AnalysLog[1,Log[1+b_. Sin[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] := 
  366.   Block[ {zn,HyperInteg},Factor[Expand[
  367.     AnalysLog[1,Log[1+b Sin[a zn]^m]^n (f//.x->zn),zn,0,Pi/(2 a)]/a + 
  368.     AnalysLog[1,Log[1+b Cos[a zn]^m]^n (f//.x->zn+Pi/(2 a))/.ExpandIntoTrig,
  369.               zn,0,Pi/(2 a)]]]
  370.     ]/; FreeQ[a,x] && xmax=== Pi/a && IntegerQ[n]
  371.  
  372.  AnalysLog[1,Log[1+b_. Cos[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] := 
  373.   Block[ {zn,HyperInteg},Factor[Expand[
  374.     AnalysLog[1,Log[1+b Cos[a zn]^m]^n (f//.x->zn),zn,0,Pi/(2 a)]/a + 
  375.     AnalysLog[1,Log[1-b Sin[a zn]^m]^n (f//.x->zn+Pi/(2 a))/.
  376.               ExpandIntoTrig,zn,0,Pi/(2 a)]]]
  377.     ]/; FreeQ[a,x] && xmax=== Pi/a && IntegerQ[n]
  378.  
  379.  AnalysLog[1,Log[1+b_. Sin[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] := 
  380.   Block[ {z,HyperInteg},Expand[
  381.     AnalysLog[1,Log[1+b Sin[a z]^m]^n (f//.x->z+Pi/a)/.ExpandIntoTrig,
  382.               z,0,Pi/a] + 
  383.     AnalysLog[1,Log[1+(-1)^m b Sin[a z]^m]^n (f//.x->z+Pi/a)/.
  384.               ExpandIntoTrig,z,0,Pi/a]]
  385.     ]/; FreeQ[a,x] && xmax=== 2 Pi/a && IntegerQ[n]
  386.  
  387.  AnalysLog[1,Log[1+b_. Cos[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] := 
  388.   Block[ {z,HyperInteg},Expand[
  389.     AnalysLog[1,Log[1+b Cos[a z]^m]^n (f//.x->z+Pi/a)/.ExpandIntoTrig,
  390.               z,0,Pi/a] + 
  391.     AnalysLog[1,Log[1+(-1)^m b Cos[a z]^m]^n (f//.x->z+Pi/a)/.
  392.               ExpandIntoTrig,z,0,Pi/a]]
  393.     ]/; FreeQ[a,x] && xmax=== 2 Pi/a && IntegerQ[n]
  394.  
  395.  AnalysLog[done_,Log[Abs[1+a_ x_^n_.]] f_.,x_,0,Infinity] :=
  396.     Dispatcher[done,InputElem[Log[Abs[1+a x^n]],x] f,x,0,Infinity]
  397.  
  398.  AnalysLog[done_,Log[(1+ x_)/(1-x_)] f_.,x_,0,xmax_] :=
  399.     Module[ {inter},
  400.       inter = InputElem[Log[(1+x)/(1-x)],x];
  401.        If[ FreeQ[inter,MeijerG], FailInt,
  402.            Dispatcher[done,inter f,x,0,xmax]]
  403.     ]
  404.  
  405.  AnalysLog[done_,Log[(1+x_)/(x_-1)] f_.,x_,1,xmax_] :=
  406.     Module[ {inter},
  407.       inter = InputElem[Log[(1+x)/(x-1)],x];
  408.        If[ FreeQ[inter,MeijerG], FailInt,
  409.            Dispatcher[done,inter f,x,1,xmax]]
  410.     ]
  411.  
  412.  AnalysLog[1,Log[a_Plus] f_.,x_,0,xmax_] := 
  413.    Module[ {add},
  414.     add = ComPlus[a,x];
  415.     If[ add===0 || add===1, FailInt,
  416.         Log[add] Dispatcher[1,f,x,0,xmax] + 
  417.         AnalysLog[1,Log[1+Expand[(a-add)/add]] f,x,0,xmax]
  418.     ]]
  419.  
  420.  AnalysLog[1,Log[Abs[a_Plus]] f_.,x_,0,xmax_] := 
  421.    Module[ {add},
  422.     add = ComPlus[a,x];
  423.     If[ add===0 || add===1, FailInt,
  424.         Log[Abs[add]] Dispatcher[1,f,x,0,xmax] + 
  425.         AnalysLog[1,Log[Abs[1+Expand[(a-add)/add]]] f,x,0,xmax]
  426.     ]]
  427.  
  428.  AnalysLog[ __ ] := Module[ {w}, w FailInt ]
  429.  
  430. (**************************************************************************
  431. *                      Search Algebraic Expression
  432. *
  433. ***************************************************************************)
  434.  
  435.  AnalysAlg[done_,s_,m_,s1_+s2_,n_,f_,x_,lim_] := 
  436.     AnalysAlg[done,s+s1,m,s2,n,f,x,lim]/;
  437.   FreeQ[s1,x]
  438.  
  439.  AnalysAlg[done_,s_,m_,m1_ m2_,n_,f_,x_,lim_] := 
  440.     AnalysAlg[done,s,m m1,m2,n,f,x,lim]/;
  441.   FreeQ[m1,x]
  442.  
  443.  AnalysAlg[done_,p_,m_,x_^dg_.,n_,f_,x_,{xmin_,xmax_}] := 
  444.  (-1)^n AnalysAlg[done,-xmin,-m,x^dg,n,f,x,{xmin,xmax}]/;
  445.  Expand[p-xmin]===0 && Znak[p m]
  446.  
  447.  AnalysAlg[done_,p_,m_,x_^dg_.,n_,f_,x_,{xmin_,xmax_}] := 
  448.  (-1)^n AnalysAlg[done,-p,-m,x^dg,n,f,x,{xmin,xmax}]/;
  449.  Expand[p+xmax]===0 && Znak[p m]
  450.  
  451.  AnalysAlg[done_,s_,m_,x_^dg_/; !NumberQ[N[dg]],n_,f_,x_,{xmin_,xmax_}] := 
  452.   Module[ {z},
  453.     $IntegrateAssumptions=$IntegrateAssumptions&&Im[dg]==0;
  454.     dg^(-1) SearchRule[done/.x->z^(1/dg)/.z->x,s,m,1,n,PowerExpand[Simplify[
  455.               (f/.x->z^(1/dg)/.z->x) x^(1/dg-1)],{x}],
  456.               x,{If[xmin===-Infinity,-Infinity,
  457.                     If[xmin===0,0,xmin^dg]],
  458.                  If[xmax===Infinity, Infinity, 
  459.                     If[xmax===0,0,xmax^dg]]}]
  460.    ]/;sumintegrals
  461.  
  462.  AnalysAlg[done_,s_,m_,x_^dg_.,n_,f_,x_,lim_] := 
  463.     SearchRule[done,s,m,dg,n,f,x,lim]
  464.  
  465.  AnalysAlg[1,s_,m_,Exp[a_. x_^dg_?Negative+const_.],n_,f_,x_,{0,Infinity}] :=
  466.     Module[ {var},
  467.       AnalysAlg[1,s,m,Exp[a var^(-dg)+const/.x->1/var]/.var->x,n,
  468.        (f/.x->1/var/.var->x) x^(-2),x,{0,Infinity}] ]/;
  469.   FreeQ[a,x] 
  470.  
  471.  AnalysAlg[1,s_,m_,Exp[a_. x_^dg_.+ const_/;FreeQ[const,x]],
  472.     n_,f_,x_,interv_] :=
  473.    E^(const n) AnalysAlg[1,s E^(-const),m,E^(a x^dg),n,f,x,interv] 
  474.  
  475.  AnalysAlg[1,s_,m_,Exp[a_ x_^dg_.],n_?Negative,x_^k_. f_.,x_,{0,Infinity}] :=
  476.   Block[{z,var,var1,var2,HyperInteg},
  477.     var1 = s/m;
  478.     $IntegrateAssumptions = $IntegrateAssumptions && Positive[-a];
  479.     If[ Znak[var1],var=-var2;var1=-s/m,var=var2];
  480.     m^n (-1/a)^(1/dg) dg^(-1) Dispatcher[1,Gamma[-n]^(-1)*
  481.            MeijerG[ {n+1},{},{0},{},{1,var x^dg} ]*
  482.         Log[x]^(1/dg-1) *
  483.     PowerExpand[x^k f/.x->(-1/a)^(1/dg) Log[z]^(1/dg)/.z->x,{x}]/
  484.          x^(n+1),x,1,Infinity]/.{var2->var1} 
  485.     ]/; 
  486.   FreeQ[a,x] && Znak[a] && Positive[N[dg]] 
  487.  
  488.  AnalysAlg[1,s_,m_,Exp[a_. x_^dg_.],n_?Negative,x_^k_. f_.,x_,{0,Infinity}] :=
  489.   Block[{z,var,var1,var2,HyperInteg},
  490.     var1 = m/s;
  491.     $IntegrateAssumptions = $IntegrateAssumptions && Positive[a];
  492.     If[ Znak[var1],var=-var2;var1=-m/s,var=var2];
  493.     s^n (1/a)^(1/dg)/dg Dispatcher[1,Gamma[-n]^(-1)*
  494.           MeijerG[ {n+1},{},{0},{},{1,var x^dg} ]*
  495.          Log[x]^(1/dg-1) x^(-1) * 
  496.          Expand[x^k f/.x->(1/a)^(1/dg) Log[z]^(1/dg)/.z->x]/.{E^(r1_+r2_) :>
  497.       (E^r1) (E^r2)},x,1,Infinity]/.{var2->var1}  
  498.     ]/;
  499.   FreeQ[a,x] && Not[Znak[a]] && Positive[dg]
  500.  
  501.  AnalysAlg[1,s_,m_,Exp[a_. x_^dg_.],n_?Negative,f_,x_,{0,Infinity}] :=
  502.   Block[{z,var,var1,var2,HyperInteg},
  503.     var1 = m/s;
  504.     If[ Znak[var1],var=-var2;var1=-m/s,var=var2];
  505.     s^n (1/a)^(1/dg)/dg Dispatcher[1,Gamma[-n]^(-1)*
  506.           MeijerG[ {n+1},{},{0},{},{1,var x^dg} ]*
  507.          Log[x]^(1/dg-1) x^(-1) * 
  508.          Expand[f//.x->(1/a)^(1/dg) Log[z]^(1/dg)/.z->x]/.{E^(r1_+r2_) :>
  509.       (E^r1) (E^r2)},x,1,Infinity]/.{var2->var1}  
  510.     ]/;
  511.   Not[Znak[s/m]] && FreeQ[a,x] && Not[Znak[a]] && Positive[dg] 
  512.  
  513.  AnalysAlg[done_,s_,m_,trigf_[a_. x_]^dg_.,n_,f_,x_,lim_] :=
  514.     AnalysAlgTrig[done,s,m,trigf[a x]^dg,n,f,x,lim]/; 
  515.   FreeQ[a,x] && Complement[{trigf},{Sin,Cos,Tan,Cot}]==={}
  516.  
  517.  AnalysAlg[ __ ] := Module[ {w}, w FailInt ]
  518.  
  519.  SearchRule[done_,num1_?Negative s_,num2_?Negative m_,dg_,n_,f_,x_,lim_] :=
  520.   E^(I Pi n) SearchRule[done,Abs[num1] s,Abs[num2] m,dg,n,f,x,lim]
  521.  
  522.  SearchRule[done_,num_?Negative s_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
  523.     SearchRuleGen2[done,num,s,m,dg,n,f,x,{xmin,xmax}]
  524.  
  525.  SearchRule[done_,Complex[0,num_?Negative],m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
  526.     SearchRuleGen2[done,num I,1,m,dg,n,f,x,{xmin,xmax}]
  527.  
  528.  SearchRule[done_,num_?Negative,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
  529.     SearchRuleGen2[done,num,1,m,dg,n,f,x,{xmin,xmax}]
  530.  
  531.  SearchRuleGen2[done_,num_,s_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
  532.     If[ N[n]<-1,FailInt,
  533.         (s num)^n Pi Dispatcher[ done, 
  534.         MeijerG[ {0},{1/2},{0},{1/2},{1,-m x^dg/(s num)} ] f,
  535.         x,xmin,xmax ]]/;xmax=!=Infinity &&xmin<N[(-s num/m)^(1/dg)]<xmax&&
  536.  (And@@(NumberQ[#]&/@N[{s,num,m,dg,xmin,xmax}]))&&N[n]<=-1
  537.  
  538.  SearchRuleGen2[done_,num_,s_,m_,dg_,n_,x_^k_. f_.,x_,{xmin_,xmax_}] :=
  539.   Module[ {z,lim1,lim2,function},
  540.   lim1 = xmin;  lim2 = xmax;
  541.   function =  
  542.   If[ n === -1 && (xmin==0&&xmax===Infinity||done=!=1||!FreeQ[f,Power]
  543.       || !FreeQ[f,Log] || !FreeQ[f,ArcCos] || !FreeQ[f,ArcSin]), 
  544.       Pi MeijerG[ {0},{1/2},{0},{1/2},{1,m x^dg/(-num s)}]/(num s),
  545.   If[ !n === -1,
  546.     If[ xmax===Infinity && xmin =!=-Infinity && 
  547.         Expand[m xmin^dg+num s] === 0 ||
  548.         xmax===Infinity && xmin===0 && done=!=1, lim1 = 0;
  549.         (-num s)^n *
  550.         If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
  551.         MeijerG[ {n+1},{},{},{0},{1,m x^dg/(-num s)} ] ,
  552.     If[ EvenQ[dg] &&xmin ===-Infinity&&Expand[m xmax^dg+num s]===0 &&
  553.             Expand[x^k f//.x->-z] === Expand[x^k f//.x->z],
  554.         lim1 = 0; lim2 = Infinity;
  555.         (-num s)^n *
  556.         If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
  557.         MeijerG[ {n+1},{},{},{0},{1,m x^dg/(-num s)} ],
  558.         FailInt ]], 
  559.    FailInt ]]; 
  560.    Dispatcher[ done function,x^k f,x,lim1,lim2 ]
  561.    ]
  562.  
  563.  SearchRuleGen2[done_,num_,s_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
  564.   Module[ {z,lim1,lim2,function},
  565.   lim1 = xmin;  lim2 = xmax;
  566.   function =  
  567.   If[ n === -1 && (xmin==0&&xmax===Infinity||done=!=1||!FreeQ[f,Power]
  568.       || !FreeQ[f,Log] || !FreeQ[f,ArcCos] || !FreeQ[f,ArcSin]), 
  569.       Pi MeijerG[ {0},{1/2},{0},{1/2},{1,m x^dg/(-num s)}]/(num s),
  570.   If[ !n === -1,
  571.     If[ xmax===Infinity && xmin =!=-Infinity && 
  572.         Expand[m xmin^dg+num s] === 0 ||
  573.         xmax===Infinity && xmin===0 && done=!=1, lim1 = 0;
  574.         (-num s)^n*
  575.         If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
  576.         MeijerG[ {n+1},{},{},{0},{1,m x^dg/(-num s)} ] ,
  577.     If[ EvenQ[dg] &&xmin ===-Infinity&&Expand[m xmax^dg+num s]===0 &&
  578.             Expand[f//.x->-z] === Expand[f//.x->z],
  579.         lim1 = 0; lim2 = Infinity;
  580.         (-num s)^n*
  581.         If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
  582.         MeijerG[ {n+1},{},{},{0},{1,m x^dg/(-num s)} ],
  583.         FailInt ]], 
  584.    FailInt ]]; 
  585.    Dispatcher[ done function,f,x,lim1,lim2 ]
  586.    ]
  587.  
  588.  SearchRule[done_,s_,num_ m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
  589.     SearchRuleGen1[done,s,num,m,dg,n,f,x,{xmin,xmax}]/;
  590.  NumberQ[num] && Im[num]==0 && num<0
  591.  
  592.  SearchRule[done_,s_,num_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
  593.     SearchRuleGen1[done,s,num,1,dg,n,f,x,{xmin,xmax}]/;
  594.  NumberQ[num] && Im[num]==0 && num<0
  595.  
  596.  SearchRuleGen1[done_,s_,num_,m_,dg_,n_/;N[n]<=-1,f_,x_,{xmin_,xmax_}] :=
  597.     If[ N[n]<-1,FailInt,
  598.         s^n Pi Dispatcher[ done, 
  599.         MeijerG[ {0},{1/2},{0},{1/2},{1,-m num x^dg/s} ] f,x,
  600.         xmin,xmax]]/;xmax=!=Infinity&&xmin<N[(-s/(num m))^(1/dg)]<xmax&&
  601.  (And@@(NumberQ[#]&/@N[{s,num,m,dg,n,xmin,xmax}]))
  602.  
  603.  SearchRuleGen1[done_,s_,num_,m_,dg_,n_,x_^k_. f_.,x_,{xmin_,xmax_}] :=
  604.   Block[ {z,lim1,lim2,function, Dispatcher},
  605.   lim1 = xmin;  lim2 = xmax;
  606.   If[ xmax=!=Infinity && Expand[m num xmax^dg+s] =!= 0 &&
  607.       Expand[m num xmin^dg+s] =!= 0,
  608.       positiveList[exp[Pi I]]; positiveList[m num/s];
  609.     Return[
  610.       s^n Gamma[-n]^(-1)*
  611.     Dispatcher[ done, 
  612.                 MeijerG[ {n+1},{},{0},{},{1,-m num x^dg/s exp[Pi I]} ] x^k f,
  613.                 x,lim1,lim2 ] ],
  614.   function = 
  615.   If[ n === -1 && (xmin===0&&xmax===Infinity||done=!=1||
  616.       Or@@(Not[FreeQ[f,#]]&/@{Power[_,_],Log[_],ArcCos[_],
  617.       ArcSin[_],PolyLog[_,_]})),  
  618.       s^n Pi MeijerG[ {0},{1/2},{0},{1/2},{1,-m num x^dg/s} ],
  619.   If[ !n === -1,
  620.     If[ xmax=!=Infinity && Expand[m num xmax^dg+s] === 0 &&
  621.         Expand[m num xmin^dg+s] =!= 0 && xmin=!=0, 
  622.         Dispatcher[done,(s+num*m*x^dg)^n f x^k,x,0,xmax] -
  623.         Dispatcher[done,(s+num*m*x^dg)^n f x^k,x,0,xmin], 
  624.     If[ xmax=!=Infinity && Expand[m num xmax^dg+s] === 0 &&
  625.         Expand[m num xmin^dg+s] =!= 0 ||
  626.         xmax===Infinity && done=!=1, lim2 = Infinity;
  627.         s^n * 
  628.         If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
  629.         MeijerG[ {},{n+1},{0},{},{1,-num m x^dg/s} ],
  630.     If[ Expand[m num xmin^dg+s] === 0 && xmax === 0 && EvenQ[dg] &&
  631.           Expand[x^k f//.x->-z] === (x^k f//.x->z),
  632.         lim1 = 0; lim2 = -xmin;
  633.         s^n *
  634.         If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
  635.         MeijerG[ {},{n+1},{0},{},{1,-num m x^dg/s} ],
  636.     If[ Expand[m num xmin^dg+s] === 0 && Expand[m num xmax^dg+s] === 0 &&   
  637.           EvenQ[dg] && Expand[x^k f//.x->-z] === (x^k f//.x->z),
  638.         lim1 = 0; lim2 = Infinity;
  639.         2 s^n *
  640.         If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
  641.         MeijerG[ {},{n+1},{0},{},{1,-num m x^dg/s} ],
  642.         FailInt ]]]],
  643.     FailInt ]]];
  644.     If[ FreeQ[function, Dispatcher],
  645.     Dispatcher[ done function,x^k f,x,lim1,lim2 ],
  646.     function]
  647.   ]
  648.  
  649.  SearchRuleGen1[done_,s_,num_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
  650.   Block[ {z, lim1, lim2, function, Dispatcher},
  651.   lim1 = xmin;  lim2 = xmax;
  652.   If[ xmax=!=Infinity && Expand[m num xmax^dg+s] =!= 0 &&
  653.       Expand[m num xmin^dg+s] =!= 0,
  654.       positiveList[exp[Pi I]]; positiveList[m num/s];
  655.     Return[
  656.       s^n Gamma[-n]^(-1)*
  657.     Dispatcher[ done, 
  658.                 MeijerG[ {n+1},{},{0},{},{1,-m num x^dg/s exp[Pi I]} ] f,
  659.                 x,lim1,lim2 ] ]
  660.   ,
  661.   function = 
  662.   If[ n === -1 && (xmin===0&&xmax===Infinity||done=!=1||
  663.       Or@@(Not[FreeQ[f,#]]&/@{Power[_,_],Log[_],ArcCos[_],
  664.       ArcSin[_],PolyLog[_,_]})),  
  665.       s^n Pi MeijerG[ {0},{1/2},{0},{1/2},{1,-m num x^dg/s} ],
  666.   If[ !n === -1,
  667.     If[ xmax=!=Infinity && Expand[m num xmax^dg+s] === 0 &&
  668.         Expand[m num xmin^dg+s] =!= 0 && xmin=!=0 &&
  669.     !CondForIntegrate[f, {x,xmin,z}], 
  670.         Dispatcher[done,(s+num*m*x^dg)^n f,x,0,xmax] -
  671.         Dispatcher[done,(s+num*m*x^dg)^n f,x,0,xmin], 
  672.     If[ xmax=!=Infinity && Expand[m num xmax^dg+s] =!= 0 &&
  673.         Expand[m num xmin^dg+s] =!= 0 && xmin===0,
  674.         s^n Dispatcher[done,
  675.         If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
  676.         MeijerG[ {},{n+1},{0},{},{1,-num m x^dg/s} ] f,x,0,xmax],    
  677.     If[ xmax=!=Infinity && Expand[m num xmax^dg+s] === 0 &&
  678.         Expand[m num xmin^dg+s] =!= 0 ||xmax===Infinity && done=!=1, 
  679.     lim2 = Infinity;
  680.         s^n *
  681.         If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
  682.         MeijerG[ {},{n+1},{0},{},{1,-num m x^dg/s} ],
  683.     If[ Expand[m num xmin^dg+s] === 0 && xmax === 0 && EvenQ[dg] &&
  684.           Expand[f//.x->-z] === (f//.x->z),
  685.         lim1 = 0; lim2 = -xmin;
  686.         s^n *
  687.         If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
  688.         MeijerG[ {},{n+1},{0},{},{1,-num m x^dg/s} ],
  689.     If[ Expand[m num xmin^dg+s] === 0 && Expand[m num xmax^dg+s] === 0 &&   
  690.         xmin*xmax =!= 0 ,
  691.       If[ Expand[(f//.x->-z) + (f//.x->z)]===0,0, 
  692.         If[ Expand[f//.x->-z] === (f//.x->z),
  693.             lim1 = 0; lim2 = Infinity;
  694.             2 s^n *
  695.             If[ NumberQ[n] && Im[n]==0 && n<-1,
  696.                 FailInt,
  697.                 Gamma[Expand[n+1]]
  698.               ] *
  699.             MeijerG[ {},{n+1},{0},{},{1,-num m x^dg/s} ]
  700.         ,
  701.             Dispatcher[done,(s+num*m*x^dg)^n f,x,0,xmax] +
  702.             Dispatcher[done,(s+num*m*z^dg*(-1)^dg)^n (f/.x->-z),z,0,-xmin] 
  703.      ]
  704.        ]
  705.        ,
  706.        FailInt
  707.        ]]]]],
  708.     FailInt ]]];
  709.     If[ function===0,0,
  710.         If[ FreeQ[function, Dispatcher],
  711.         Dispatcher[ done function,f,x,lim1,lim2 ],
  712.         function]
  713.       ]
  714.     ]
  715.  
  716.  SearchRule[done_,s_,m_,dg_,n_Integer?Positive,f_,x_,{0,xmax_}] :=
  717.    s^n Dispatcher[done (1+x^dg)^n,f,x,0,xmax]
  718.  
  719.  SearchRule[done_,s_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
  720.   Module[ {lim1,lim2,function,z},
  721.   lim1 = xmin;  lim2 = xmax;
  722.   function =
  723.     If[ xmin === -Infinity && xmax === Infinity &&EvenQ[dg] && 
  724.         Expand[f//.x->-z] === (f//.x->z),
  725.         lim1 = 0; lim2 = Infinity; 
  726.         positiveList[m]; positiveList[s];
  727.         2 s^n*
  728.         If[NumberQ[n] && Im[n]==0 && n>0,FailInt,Gamma[Expand[-n]]^(-1) ]*
  729.         MeijerG[ {n+1},{},{0},{},{1,m x^dg/s} ],
  730.         positiveList[m]; positiveList[s];
  731.         s^n *
  732.         If[NumberQ[n] && Im[n]==0 && n>0,FailInt,Gamma[Expand[-n]]^(-1) ]*
  733.         MeijerG[ {n+1},{},{0},{},{1,m x^dg/s} ]
  734.       ];
  735.   Dispatcher[ done,function f,x,lim1,lim2 ]
  736.   ] 
  737.  
  738. (****************************************************************************
  739. *           Trigonometric Functions into Algebraic Functions     
  740. *
  741. *****************************************************************************)
  742.  
  743.  AnalysAlgTrig[1,s_,m_,h_[a_. x_]^dg_.,n_,f_,x_,{0,xmax_}] :=
  744.   Module[{z,r},
  745.     r = Expand[((f/.x->InverseFunction[h][z]/a)/.TrigMultArg//.LogTrig)*
  746.                (1-z^2)^(-1/2)]/.z->x;
  747.     a^(-1)*
  748.     If[Head[r]===Plus,
  749.        Map[Dispatcher[1, (s+m x^dg)^n #,x,0,1]&,r],
  750.        Dispatcher[1, (s+m x^dg)^n r,x,0,1]]
  751.     ]/; xmax=== Pi/(2 a) && (h==Sin || h==Cos) 
  752.  
  753.  AnalysAlgTrig[1,s_,m_,h_[a_. x_]^dg_.,n_,f_,x_,{0,xmax_}] :=
  754.   Module[{z},
  755.       a^(-1) Dispatcher[1,(1+z^2)^(-1) (s+m z^dg)^n *
  756.        Expand[f/.x->InverseFunction[h][z]/a]//.LogTrig,z,0,Infinity]
  757.     ]/; xmax=== Pi/(2 a) && (h==Tan || h==Cot)
  758.  
  759.  AnalysAlgTrig[done_,s_,m_,trigf_[a_. x_]^dg_.,n_,f_,x_,{0,xmax_}] :=
  760.   Block[ {z,answer,HyperInteg},
  761.    answer = AnalysAlg[done/.x->z,s,m,trigf[a z]^dg,n,f/.x->z,z,{0,Pi/(2 a)}]; 
  762.    If[ FreeQ[answer,FailInt], 
  763.        Expand[answer +
  764.        AnalysAlg[done,s,m,trigf[a z+Pi/2]^dg,n,
  765.                 (f/.x->z+Pi/(2 a))/.ExpandIntoTrig,
  766.                  z,{0,Pi/(2 a)}]]
  767.        ,
  768.        FailInt]
  769.    ]/; xmax=== Pi/a
  770.  
  771.  AnalysAlgTrig[done_,s_,m_,trigf_[a_. x_]^dg_.,n_,f_,x_,{0,xmax_}] :=
  772.   Block[ {z,answer,HyperInteg},
  773.    answer = AnalysAlg[done//.x->z,s,m,trigf[a z]^dg,n,f//.x->z,z,{0,Pi/a}]; 
  774.    If[ FreeQ[answer,FailInt], Expand[answer +
  775.     AnalysAlg[done,s,m,trigf[a z+Pi]^dg,n,
  776.        (f//.x->z+Pi/a)/.ExpandIntoTrig,z,{0,Pi/a}]],
  777.     FailInt]
  778.    ]/; xmax=== 2 Pi/a
  779.  
  780.  AnalysAlgTrig[ __ ] := Module[ {var}, var FailInt] 
  781.  
  782. (*****************************************************************************
  783. *                  Search Trigonometric Functions
  784. *
  785. *****************************************************************************)
  786.  
  787.  AnalysTrig[done_,f1_,f2_Plus,x_,xmax_] :=
  788.    Map[AnalysTrig[done,f1,#,x,xmax]&,f2]
  789.  
  790.  AnalysTrig[done_,f1_,const_ f2_,x_,xmax_] :=
  791.    const AnalysTrig[done,f1,f2,x,xmax]/;FreeQ[const,x] 
  792.  
  793.  AnalysTrig[done_,const_ f1_,f2_,x_,xmax_] :=
  794.    const AnalysTrig[done,f1,f2,x,xmax]/;FreeQ[const,x] 
  795.  
  796.  AnalysTrig[done_,f1_[a_. x_]^n1_.,f2_[b_. x_]^n2_.,x_,xmax_] :=
  797.   If[ a xmax=!=Pi/2 ,AnalysTrig[done,f2[b x]^n2,f1[a x]^n1,x,xmax],
  798.       a^(-1) Dispatcher[done 2,((f1[ArcCos[x]]^n1 f2[b/a ArcCos[x]]^n2*
  799.               (1-x^2)^(-1/2))//.LogTrig)//.InputInvTrig,x,0,1]/2]/;    
  800.   a xmax===Pi/2 || b xmax===Pi/2
  801.  
  802.  AnalysTrig[done_,Sin[x_]^n_.,f2_[b_. x_],x_,Pi] :=
  803.   2^(n+1) Dispatcher[done,x^n (1-x^2)^(n/2-1/2) *
  804.       f2[2 b ArcCos[x]]/.InputInvTrig,x,0,1]
  805.  
  806.  AnalysTrig[done_,f1_[x_]^n_.,f2_[b_. x_],x_,Pi] :=
  807.   Block[ {answer,HyperInteg},
  808.    answer = AnalysTrig[done,f1[x]^n,f2[b x],x,Pi/2];
  809.    If[ FreeQ[answer,FailInt], Expand[answer +
  810.    AnalysTrig[done,PowerExpand[f1[x + Pi/2]^n,{x}],
  811.           f2[b x+b Pi/2],x,Pi/2]],
  812.     FailInt] ]
  813.  
  814.  AnalysTrig[done_,f1_[a_. x_]^n_,f2_[b_. x_]^m_.,x_,xmax_] :=
  815.     a^(-1) AnalysTrig[done,f1[x]^n,f2[b x/a],x,Pi]/;
  816.   a xmax===Pi && m==1
  817.  
  818.  AnalysTrig[done_,f1_[a_. x_]^n_.,f2_[b_. x_]^m_,x_,xmax_] :=
  819.     b^(-1) AnalysTrig[done,f2[x]^m,f1[a x/b],x,Pi]/;
  820.   b xmax===Pi && n==1
  821.   
  822.  AnalysTrig[ __ ] := Module[ {var}, var FailInt]
  823.  
  824.  AnalysTrig1[1,f_[a_. x_]^n_.,1,x_,xmax_] :=
  825.   Module[ {answer},
  826.    answer = Integrate[f[a x]^n,x];
  827.    (answer/.x->xmax) - (answer/.x->0)
  828.     ]/;Complement[{f},{Sin,Cos}]==={} && IntegerQ[n]
  829.  
  830.  AnalysTrig1[done_,f_[a_. x_]^n_.,w_,x_,xmax_] :=
  831.    a^(-1) Dispatcher[done,(f[ArcCos[x]]^n If[w===1,1,ArcCos[x]/a] *
  832.               (1-x^2)^(-1/2)//.LogTrig)//.InputInvTrig,x,0,1]/;    
  833.   a xmax===Pi/2 
  834.  
  835.  AnalysTrig1[done_,Sin[a_. x_]^n_.,w_,x_,xmax_] :=
  836.    a^(-1) If[w===1,2,Pi/a] AnalysTrig1[done,Sin[x]^n,1,x,Pi/2]/;    
  837.   a xmax===Pi 
  838.  
  839.  AnalysTrig1[done_,const_ Sin[a_. x_]^n_.,w_,x_,xmax_] :=
  840.    a^(-1) If[w===1,2,Pi/a] Dispatcher[done,(1-x^2)^(n/2-1/2)*
  841.           If[w===1,1,ArcCos[x]],x,0,1] const/;    
  842.   a xmax===Pi && FreeQ[const,x]
  843.   
  844.  AnalysTrig1[ __ ] := Module[ {var}, var FailInt]
  845.  
  846.  
  847. (*****************************************************************************
  848. *                    Search Exp Functions
  849. *
  850. *****************************************************************************)
  851.  
  852.  AnalysExp1[done_,f_,x_,0,xmax_] := 
  853.    AnalysExp11[done, f/.{
  854.      E^z_ :> Module[ {inter},
  855.           inter = Together[Expand[z]];
  856.           E^(Collect[Numerator[inter],x]/
  857.              Collect[Denominator[inter],x])
  858.           ] /;!FreeQ[z,x] && PolynomialQ[z,x]
  859.      },x,0,xmax] 
  860.  
  861.  AnalysExp11[done_,E^(a_. x_^dg_. + c_.) f_.,x_,0,xmax_] := 
  862.     If[ done===1 && f===1 && Negative[dg], FailInt, 
  863.         E^c Dispatcher[done,If[ Znak[a],InputElem[E^(a x^dg),x],
  864.            E^(a x^dg)/.InputExp ] f,x,0,xmax]
  865.     ]/;
  866.   FreeQ[a,x] && FreeQ[c,x]
  867.  
  868.  AnalysExp11[done_,E^(a_. x_^dg1_. + b_. x_^dg2_. + c_.) f_.,x_,0,xmax_] :=  
  869.     E^c Dispatcher[done,(E^(a x^dg1)/.InputExp) (E^(b x^dg2)/.InputExp) f,
  870.     x,0,xmax]/;FreeQ[a,x] && FreeQ[b,x] && FreeQ[c,x] 
  871.  
  872.  AnalysExp11[ __ ] := Module[ {var}, var FailInt]
  873.  
  874.  AnalysExp2[done_,E^c_. f_.,x_,0,Infinity] := 
  875.    E^c AnalysExp21[done, f/.{
  876.        E^z_ :> E^Collect[z,x]/;!FreeQ[z,x] && PolynomialQ[z,x]},
  877.          x,0,Infinity]/;FreeQ[c,x]
  878.  
  879.  AnalysExp2[done_,f_,x_,0,Infinity] := 
  880.    AnalysExp21[done, Expand[f]/.{
  881.        E^z_ :> E^Collect[z,x]/;!FreeQ[z,x] && PolynomialQ[z,x]},x,0,Infinity]
  882.  
  883.  AnalysExp21[done_,f_,x_,0,Infinity] := 
  884.    IntFF[done,
  885.      f/.{
  886.          d_ - d_. E^(a_. x^dg_.+c_.) :> 
  887.            (
  888.            positiveList[-a]; 
  889.        $IntegrateAssumptions=$IntegrateAssumptions && Positive[-a];
  890.            d InputElem[1- E^(a x^dg),x] E^c
  891.            )/;FreeQ[d,E] && FreeQ[a,x] && FreeQ[c,x],
  892.          d_. E^(a_. x^dg_.+c_.) - d_ :> 
  893.            (
  894.            positiveList[-a]; 
  895.        $IntegrateAssumptions=$IntegrateAssumptions && Positive[-a];
  896.            -d InputElem[1- E^(a x^dg),x] E^c
  897.            )/;FreeQ[d,E] && FreeQ[a,x] && FreeQ[c,x],
  898.          E^(a_. x^dg_.+c_.) :> FailInt/;
  899.                 NumberQ[a] && Im[a]==0 &&a>0 && FreeQ[c,x],
  900.          E^(a_. x^dg_.+c_.) :> 
  901.            (
  902.            positiveList[-a]; 
  903.        $IntegrateAssumptions=$IntegrateAssumptions && Positive[-a];
  904.            InputElem[ E^(a x^dg),x] E^c
  905.            )/;FreeQ[a,x] && FreeQ[c,x],
  906.          E^(a_. Abs[x]^dg_.+c_.) :> 
  907.            (
  908.            positiveList[-a]; 
  909.        $IntegrateAssumptions=$IntegrateAssumptions && Positive[-a];
  910.            InputElem[ E^(a x^dg),x] E^c
  911.            )/;FreeQ[a,x] && FreeQ[c,x],
  912.          E^(a_. x^dg1_. + b_. x^dg2_.+c_.) :>
  913.            If[ NumberQ[N[dg1]] && NumberQ[N[dg2]],
  914.                positiveList[-a]; positiveList[-b];
  915.            If[ N[dg1-dg2] > 0, 
  916.                $IntegrateAssumptions=$IntegrateAssumptions && Positive[-a],
  917.                $IntegrateAssumptions=$IntegrateAssumptions &&Positive[-b]];
  918.                InputElem[E^(If[Znak[a],a,positiveList[exp[I Pi]];-a exp[Pi I]]*     
  919.               x^dg1),x] *
  920.                InputElem[E^(If[Znak[b],b,positiveList[exp[I Pi]];-b exp[Pi I]]*          
  921.               x^dg2),x] E^c
  922.            ]/;FreeQ[a,x] && FreeQ[b,x] && FreeQ[c,x] 
  923.       },x]
  924.  
  925.  AnalysExp21[ done_,f_,x_,xmin_,xmax_ ] := f FailInt
  926.  
  927. (*****************************************************************************
  928. *                   Search Other Functions
  929. *
  930. *****************************************************************************)
  931.  
  932.  IntFF[w__] := Module[ {var}, var FailInt ]/;!FreeQ[{w}, FailInt]
  933.  
  934.  IntFF[done_,MeijerG[par__] f_.,x_] := IntFF[done MeijerG[par],f,x]
  935.  
  936.  IntFF[done_,x_^dg_.,x_] := IntGG[dg+1,done,x] /; FreeQ[dg,x]
  937.  
  938.  IntFF[done_,const_ f_,x_] := const IntFF[done,f,x]/;FreeQ[const,x]
  939.  
  940.  IntFF[done_,const_,x_] := const IntGG[1,done,x]/;FreeQ[const,x]
  941.  
  942.  IntFF[done_,x_^deg_. f_,x_] := 
  943.     FindIntegrand[ deg+1,done,f,x ] /;FreeQ[deg,x]
  944.  
  945.  IntFF[done_,f_,x_] := FindIntegrand[ 1,done,f,x ] 
  946.  
  947.  FindIntegrand[alfa_,1,pol1_. f_[w_]^n_.+pol2_.,x_] :=
  948.   Module[ {answer},
  949.     answer = SingleGfunction[
  950.              alfa,CollectSC[Expand[Expand[
  951.              pol1 f[w]^n+pol2,Trig->True]/.ColTerm]],
  952.              pol1 f[w]^n+pol2,x];
  953.     answer/;FreeQ[answer,FailInt]
  954.    ] /;
  955.   Complement[{f},{Sin,Cos}]==={} && PolynomialQ[pol1,x] &&
  956.   PolynomialQ[pol2,x]
  957.  
  958.  FindIntegrand[alfa_,1,f1_[w1_]^n_. f2_[w2_]^m_.+pol_.,x_] :=
  959.   Module[ {answer},
  960.     answer =  SingleGfunction[
  961.               alfa,CollectSC[Expand[Expand[
  962.               f1[w1]^n f2[w2]^m+pol,Trig->True]/.ColTerm]],
  963.               f1[w1]^n f2[w2]^m+pol,x];
  964.     answer/;FreeQ[answer,FailInt]
  965.    ] /;
  966.   Complement[{f1,f2},{Sin,Cos}]==={} && PolynomialQ[pol,x]
  967.  
  968.  FindIntegrand[alfa_,1,pol1_. f1_[w1_]^n_.+pol2_. f2_[w2_]^m_.+pol3_.,x_] :=
  969.   Module[ {answer},
  970.     answer =  SingleGfunction[
  971.               alfa,CollectSC[Expand[Expand[ pol1 f1[w1]^n +
  972.               pol2 f2[w2]^m+pol3,Trig->True]/.ColTerm]],
  973.               pol1 f1[w1]^n + pol2 f2[w2]^m+pol3,x];
  974.     answer/;FreeQ[answer,FailInt]
  975.    ] /;
  976.   Complement[{f1,f2},{Sin,Cos}]==={} && 
  977.   (And@@(PolynomialQ[#,x]&/@{pol1,pol2,pol3}))
  978.  
  979.  FindIntegrand[alfa_,done_,f_,x_] := 
  980.    GGfunctions[alfa,done,CollectSC[Expand[
  981.           Expand[f,Trig->True]/.ColTerm]]//.{
  982.       Sin[w_+v_] :>
  983.         Sin[w] Cos[v] + Cos[w] Sin[v]/;Not[FreeQ[v,x]] && Not[FreeQ[w,x]],
  984.       Cos[w_+v_] :> 
  985.         Cos[w] Cos[v] - Sin[w] Sin[v]/;Not[FreeQ[v,x]] && Not[FreeQ[w,x]],
  986.       Sin[w_Plus] :> 
  987.        Module[ {add = ComPlus[w,x]},
  988.           Sin[add] Cos[w-add] + Cos[add] Sin[w-add]
  989.        ],
  990.       Cos[w_Plus] :> 
  991.        Module[ {add = ComPlus[w,x]},
  992.           Cos[add] Cos[w-add] - Sin[add] Sin[w-add]
  993.        ]
  994.       },x]/;
  995.      Not[FreeQ[f,Sin[_]]] || Not[FreeQ[f,Cos[_]]]
  996.  
  997.  FindIntegrand[alfa_,done_,f_,x_] := GGfunctions[alfa,done,f,x]
  998.  
  999.  SingleGfunction[alfa_,f_,oldf_,x_] := 
  1000.     TaylorSeriesTrig[alfa,CondTrigDegree[f,x],f,oldf,x]/;
  1001.   CondTrig[f,x]
  1002.  
  1003.  SingleGfunction[alfa_,f_,oldf_,x_] := GGfunctions[alfa,1,oldf,x]
  1004.  
  1005.  TaylorSeriesTrig[ alfa_,{dg_?Negative,True},f_,oldf_,x_ ] :=
  1006.     Module[ {var},      
  1007.      -1/dg *
  1008.      TaylorSeriesTrig[ alfa/dg,{1,True},f/.x->var^(1/dg),oldf,var]
  1009.     ] 
  1010.  
  1011.  GGfunctions[ alfa_,done_,f_,x_ ] := f IntGG[alfa,done,x] /; FreeQ[f,x]
  1012.  
  1013.  GGfunctions[ alfa_,done_,f_,x_ ] :=  
  1014.     IntGG[alfa,FindGfunction[done,f,x]//Expand,x] 
  1015.  
  1016.  FindGfunction[done_,f_,x_] := 
  1017.    Which[
  1018.         Apply[Or,Not[FreeQ[f,#]]&/@ListBessel],
  1019.               FindGfunction[done,f/.InputBessel,x],
  1020.     Apply[Or,Not[FreeQ[f,#]]&/@ListOther],
  1021.               FindGfunction[done,f/.InputOther,x],
  1022.     Apply[Or,Not[FreeQ[f,#]]&/@ListHypergeometric],
  1023.               FindGfunction[done,f/.InputHypergeometric,x],
  1024.     Apply[Or,Not[FreeQ[f,#]]&/@ListElem],
  1025.         FindGfunction1[done,InputElem[f,x],x],
  1026.     True,f done    
  1027.    ]/; !FreeQ[f,x]
  1028.  
  1029.  FindGfunction1[ done_,f_Plus,x_] := Map[FindGfunction1[done,#,x]&,f]
  1030.  
  1031.  FindGfunction1[done_,f_,x_] := done f
  1032.  
  1033. (*************************************************************************
  1034. *                     Convergent
  1035. *
  1036. **************************************************************************)
  1037.  
  1038.  Convergent[ b_. f_[a_.x_^r_. + c_.],{x_,xmin_,Infinity} ] := 
  1039.    If[ NumberQ[r] && Re[r]<=1, False, True ] /;
  1040.  (f===Sin || f===Cos) && FreeQ[{a,b,r,c},x]
  1041.  
  1042.  Convergent[ f_,{x_,xmin_/;xmin=!=0,Infinity} ] :=
  1043.   Module[ 
  1044.    {answer =
  1045.      Module[ {test},
  1046.        Off[General::indet,Infinity::indet,Power::infy,General::dbyz];
  1047.        test = {PowerExpand[x f//.{
  1048.           a_ + b_. x^n_. :> b x^n /; Re[n]>0 && FreeQ[{a,b},x],
  1049.           a_. x^n1_. + b_. x^n2_. :> b x^Max[n1,n2] /; Im[n1]==0 &&
  1050.           Im[n2]==0 && FreeQ[{a,b},x] }
  1051.               ]/.x->Infinity, f/.x->Infinity};    
  1052.        On[General::indet,Infinity::indet,Power::infy,General::dbyz]; 
  1053.        test
  1054.      ]},
  1055.     If[ FreeQ[x f,x] || 
  1056.         answer[[1]] === DirectedInfinity[-1] ||
  1057.         answer[[1]] === DirectedInfinity[1]  ||
  1058.         answer[[2]] === RealInterval[{-Infinity, Infinity}] ||
  1059.         (FreeQ[answer[[1]],x] && answer[[1]]=!=0 && answer[[2]]=!=0 && 
  1060.          And@@(FreeQ[answer,#]&/@{ComplexInfinity,Indeterminate,
  1061.                             DirectedInfinity,RealInterval})),        
  1062.         False,
  1063.         True
  1064.       ]
  1065.    ] /; FreeQ[xmin,DirectedInfinity]
  1066.  
  1067.  Convergent[ f_,{x_,0,xmax_/;FreeQ[xmax,DirectedInfinity]} ] :=
  1068.    Module[ {z},
  1069.     Convergent[Together[PowerExpand[f/.x->1/z]/z^2],{z,1/xmax,Infinity}]
  1070.    ]
  1071.  
  1072.  Convergent[ f_,{x_,0,Infinity} ] :=
  1073.    Convergent[f,{x,0,1}] && Convergent[f,{x,1,Infinity}]
  1074.  
  1075.  Convergent[ f_,{x_,-Infinity,xmax_} ] :=
  1076.    Convergent[f,{x,0,Infinity}] && If[xmax===0, True, Convergent[f,{x,0,xmax}]]
  1077.  
  1078.  Convergent[ f_,{x_,xmin_/;NumberQ[N[xmin]],xmax_/;NumberQ[N[xmax]]} ] := 
  1079.    Module[ { z },
  1080.      Convergent[ f/.x->xmin+z, {z,0,xmax-xmin}]      
  1081.    ]
  1082.    
  1083.  Convergent[ f_,{x_,xmin_,xmax_} ] := True       
  1084.  
  1085. (***************************************************************************
  1086. *                     Supplement
  1087. *
  1088. ***************************************************************************)
  1089.  
  1090.  LogarithmCase[ {___,v_,___,u_,___} ] := True /;
  1091.     IntegerQ[Expand[u-v]]
  1092.  
  1093.  LogarithmCase[ {___} ] := False
  1094.   
  1095.  Delta[k_,x_] :=
  1096.   Expand[Flatten[ Map[ Table[ (#+i)/Floor[k],{i,0,Floor[k]-1} ] &,x]]] /;
  1097.  NumberQ[k] && NonNegative[k] && (k-Floor[k])==0
  1098.   
  1099.  Delta[k_,x_] := {}
  1100.  
  1101.  ReducePar[{w1___,u_,w2___},{w3___,v_,w4___}] :=
  1102.       ReducePar[{w1,w2},{w3,w4}]/;u===v
  1103.  
  1104.  ReducePar[w1_,w2_] := {w1,w2}
  1105.  
  1106.  MultGamma[a_] :=
  1107.   Apply[ Times, Map[ Gamma, Expand[a] ] ]
  1108.  
  1109.  MultPochham[a_,k_] :=
  1110.   Apply[ Times, Map[ Pochhammer[ #,k] &, a] ]
  1111.  
  1112.  Znak[n_?Negative] := True
  1113.  Znak[n_?Negative a_] := True
  1114.  Znak[Complex[0,n_?Negative] a_.] := True
  1115.  Znak[_] := False
  1116.  
  1117.  CondTrig[f_,x_] := Apply[ And,Map[ TrigMon[#,x]&,Cases[f,z_]]]
  1118.  
  1119.  TrigMon[u_. Sin[c_. x_^n_.],x_] := True/;PolynomialQ[Expand[u],x]
  1120.  
  1121.  TrigMon[u_. Cos[c_. x_^n_.],x_] := True/;PolynomialQ[Expand[u],x]
  1122.  
  1123.  TrigMon[u_,x_] := True/;PolynomialQ[Expand[u],x]
  1124.  
  1125.  CollectSC[v_] :=
  1126.     Fold[ Collect[#1,#2[[2]]]&,
  1127.           v,
  1128.           Cases[Apply[Plus,
  1129.             Cases[v,Sin[_] | Cos[_],2]],a_ b_] ]
  1130.  ColTerm = {
  1131.   Sin[a_] :> Sin[Simplify[a]],
  1132.   Cos[a_] :> Cos[Simplify[a]]
  1133.        }
  1134.  CondTrigDegree[Sin[a_. x_^n_.],x_] := {n,True}/;FreeQ[a,x]
  1135.  
  1136.  CondTrigDegree[Cos[a_. x_^n_.],x_] := {n,True}/;FreeQ[a,x]
  1137.  
  1138.  CondTrigDegree[f_Plus,x_] := CondTrigDegree1[
  1139.      Cases[ Cases[f,Sin[_] | Cos[_],2],a_. x^_.,2 ],x]
  1140.  
  1141.  CondTrigDegree[f_,x_] := CondTrigDegree1[
  1142.      Cases[ Cases[f,Sin[_] | Cos[_]],a_. x^_.,2],x]
  1143.  
  1144.  CondTrigDegree1[{u_. x_^n_.},x_] := {n,True}/;FreeQ[u,x] 
  1145.  
  1146.  CondTrigDegree1[{___,u_. x_^n_.,___,v_. x_^m_.,___},x_] :=
  1147.      {n,True} /; n===m && FreeQ[u,x] && FreeQ[v,x]
  1148.  
  1149.  ComMult[b_ f_,x_] := b ComMult[f,x]/;FreeQ[b,x]
  1150.  
  1151.  ComMult[f_,x_] := 1
  1152.  
  1153.  ComPlus[b_ + f_,x_] := b + ComPlus[f,x]/;FreeQ[b,x]
  1154.  
  1155.  ComPlus[f_,x_] := 0
  1156.  
  1157.  positiveList[ v_ n_/;NumberQ[n] ] := 
  1158.      ( positivearg = Join[ positivearg, {v n}, positiveList[v] ] )
  1159.  
  1160.  positiveList[ n_ ] := {} /; NumberQ[n]
  1161.  
  1162.  positiveList[ v_^n_/;NumberQ[n] ] := 
  1163.      ( positivearg = Join[ positivearg, {v^n,v^(-n)} ]);   
  1164.  
  1165.  positiveList[v_] := (positivearg = Join[ positivearg,{v} ])
  1166.  
  1167.  SimpGfunction = {
  1168.    MeijerG[{0},{},{0},{0,1/2},{a_,z_}] :> Cos[2 Sqrt[z]]/Sqrt[Pi],
  1169.    MeijerG[{1/2},{},{1/2},{1/2,0},{a_,z_}] :> 
  1170.                   Sin[2 Sqrt[z]]/Sqrt[Pi] 
  1171.    }
  1172.  
  1173.  TransfAnswer[v_. If[c_,t_,f_]] := 
  1174.    Apply[ If,{c, TransfAnswer[v t], TransfAnswer[v f] }]
  1175.      
  1176.  TransfAnswer[ v_ ] := 
  1177.   Block[ { Hypergeometric2F1, HypergeometricPFQ, answer },
  1178.     answer = Expand[v//.LogTrig];
  1179.     answer = PowerExpand[ answer, Union[positivearg] ]/.exp->Exp/.sum->Sum;
  1180.     If[ Not[FreeQ[v,PolyGamma]], 
  1181.         answer = SimplifyPolyGamma[answer]//.SimpTrigSum];
  1182.     If[ Not[FreeQ[v,Gamma]], 
  1183.         answer = SimplifyGamma[answer] ];     
  1184.     If[ !FreeQ[answer,Log[_]],answer = SimpLogFun[answer] ];
  1185.     If[ Depth[answer]<8 && Length[answer]<8,
  1186.         Simplify[answer],
  1187.     answer]
  1188.    ]/;FreeQ[v,Which[_,__]]
  1189.  
  1190.  TransfAnswer[ v_ ] := 
  1191.  (PowerExpand[ v, Union[positivearg] ]/.exp->Exp/.sum->Sum)/.
  1192.      Which[w_,p__] :> Which@@Expand[{w,p}]
  1193.  
  1194.  PowerExpand2[ expr_, {} ]:= expr
  1195.  PowerExpand2[ expr_, {a_} ]:= 
  1196.         expr//.{(w_ a^k_.)^m_ :> w^m Abs[a]^(k m) (Sign[a]^k)^m}//.
  1197.            {(a^k_)^m_ :> Abs[a]^(k m) (Sign[a]^k)^m}
  1198.  PowerExpand2[ expr_, {a_,r__} ]:= 
  1199.      PowerExpand2[ PowerExpand2[ expr,{a}], {r}]
  1200.  
  1201.  SimpLogFun[ expr_Plus ] :=
  1202.    Module[ {exprN = Expand[expr//.
  1203.            {Log[n_?Positive w_] :> Log[n] + Log[w],
  1204.          Log[Rational[p_,k_]] :> Log[p]-Log[k],
  1205.             Log[(n_?Positive)^p_] :> p Log[n]/;NumberQ[p]} ],
  1206.            list,div,pos = {},i=0 },
  1207.      list = Union[Cases[exprN,w_. Log[n_Integer]/;FreeQ[w,Log]]/.
  1208.                       w_. Log[n_] :> n];
  1209.      div = GCD@@list;
  1210.      If[ Length[list]>1 && div!=1, 
  1211.          list = Complement[list,{div}];
  1212.          SimpLogFun[exprN//.BuildRule[
  1213.          Log[#]&/@list ,Log[div]+Log[#]&/@(list/div) ]]
  1214.      ,
  1215.          If[ Length[list]==1 || Length[list]==2,
  1216.              exprN,
  1217.              While[Length[pos]==0 && Length[list]>1, 
  1218.               i = i+ 1;
  1219.               listN = {list[[1]],#}&/@Rest[list];
  1220.               list = Rest[list];
  1221.               pos = Position[ (GCD@@#)&/@listN,a_/; a != 1 ]
  1222.              ];
  1223.              If[ Length[pos]!=0,
  1224.                  list = Take[listN,pos[[1]]][[1]];
  1225.                  div = GCD@@list; 
  1226.                  SimpLogFun[exprN//.BuildRule[Log[#]&/@list ,      
  1227.                          Log[div]+Log[#]&/@(list/div) ]],
  1228.                  expr
  1229.                ]
  1230.            ]
  1231.        ]
  1232.    ]     
  1233.  
  1234.  SimpLogFun[ expr_ ] := expr
  1235.  
  1236.  BuildRule[{l_,lR___},{r_,rR___}] :=
  1237.   Join[{l :> r},BuildRule[{lR},{rR}]]
  1238.  
  1239.  BuildRule[{},{}] := {}
  1240.  
  1241.  SimpTrigSum = {
  1242.   a_. Tan[x_] + b_. Cot[x_] +c_.:> c + 2 a Csc[2 x]/;a===b,
  1243.   a_. Tanh[x_] + n_?Negative b_. Coth[x_] +c_.:> c-2 a Csch[2 x]/;
  1244.       a+b n===0&&Not[Znak[a]],
  1245.   n_?Negative a_. Tanh[x_] + b_. Coth[x_] +c_.:> c+2 a Csch[2 x]/;
  1246.       a n+b===0&&Not[Znak[b]]
  1247.   }
  1248.  
  1249.  SimpLogic[ And[w1___,Negative[k_],w2___,Positive[k_],w3___] ] := False
  1250.  
  1251.  SimpLogic[ expr_ ] := 
  1252.  And@@Union[ If[ Head[expr] === And, 
  1253.                  expr/.And->List,
  1254.          {expr} ]/.{
  1255.  Positive[ n_ a_] :> If[ Positive[n], Positive[a], Negative[a] ]/;
  1256.               NumberQ[n] && Im[n]==0,
  1257.  Negative[ n_ a_] :> If[ Positive[n], Negative[a], Positive[a] ]/;
  1258.               NumberQ[n] && Im[n]==0}]
  1259.  
  1260. (* ======================================================================== *)
  1261.     
  1262.     
  1263.     
  1264.