home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-09-19 | 56.4 KB | 1,535 lines |
-
- (****************************************************************************
- *
- * Adamchik's Package
- * for Evaluation Integrals
- *
- * ( November 1990 - March 1991 )
- *****************************************************************************)
-
- (* ======================================================================== *)
-
- Unprotect[ Integrate ]
-
- Integrate[ f_,{x_,xmin_,xmax_}] :=
- Module[ {answer},
- answer = IntegrateG[
- If[ !FreeQ[f,Hypergeometric0F1],
- f/.Hypergeometric0F1[v_,z_] :> HypergeometricPFQ[{},{v},z],
- f ],{x,xmin,xmax}];
- answer /; FreeQ[answer,IntegrateG]
- ] /; FreeQ[{f,x},Blank] && FreeQ[f,Integrate] &&
- FreeQLaplace[f] &&
- CondForIntegrate[f,{x,xmin,xmax}]
-
- CondForIntegrate[ f_,{x_,xmin_,xmax_}] := True /;
- !FreeQ[{xmin,xmax},DirectedInfinity]
-
- CondForIntegrate[ f_,{x_,xmin_,xmax_}] :=
- Module[
- {answer =
- Module[ {test},
- Off[Power::infy,Power::indet,Infinity::indet,General::indet,
- General::dbyz];
- test = {f/.x->xmin, f/.x->xmax};
- On[Power::infy,Power::indet,Infinity::indet,General::indet,
- General::dbyz];
- test
- ]},
- True /; Or@@(
- Not[FreeQ[answer,#]]&/@{DirectedInfinity,ComplexInfinity,Indeterminate})
- ]
-
- CondForIntegrate[ __ ] := False
-
- Protect[ Integrate ]
-
- SetAttributes[ Integrate,ReadProtected ]
-
- (* ======================================================================== *)
-
-
- IntegrateG[f_,{x_,xmin_,xmax_}] :=
- Module[ {r,inter,z},
- Clear[positive];
- r = If[ Convergent[f,{x,xmin,xmax}],
- inter = Dispatcher[1,f//.{
- Power[a_ b_,n_] :> a^n b^n,
- (x^a_)^b_ :> x^(a b),
- E^(Complex[c_,a_] b_.) :>
- E^(c b) Cos[a b] + I E^(c b) Sin[a b]
- },x,xmin,xmax];
- If[ !FreeQ[inter,FailInt],
- If[ PolynomialQ[Numerator[f],x] &&
- PolynomialQ[Denominator[f],x],
- inter = Dispatcher[1,Apart[f//.
- {
- Power[a_ b_,n_] :> a^n b^n,
- (x^a_)^b_ :> x^(a b),
- E^(Complex[c_,a_] b_.) :>
- E^(c b) Cos[a b] + I E^(c b) Sin[a b]
- },x],x,xmin,xmax],
- inter = FailInt
- ];
- If[ !FreeQ[inter,FailInt] && xmin=!=0 &&
- FreeQ[xmin,DirectedInfinity],
- Dispatcher[1,f/.x->z+xmin,z,0,
- If[ !FreeQ[xmax,DirectedInfinity],
- xmax,xmax-xmin] ],
- inter
- ],
- inter
- ] ,
- If[ Head[f]===Sin || Head[f]===Cos,
- Indeterminate,
- Infinity ]
- ] /. SimpGfunction;
- If[ Not[FreeQ[r,FailInt]] || Not[FreeQ[r,FailIntDiv]],
- Clear[positive] ];
- If[ Not[FreeQ[r,DirectedInfinity]] || Not[FreeQ[r,FailIntDiv]] ,
- Infinity,
- TransfAnswer[r]
- ]/; FreeQ[r,FailInt] && FreeQ[r,MeijerG] && FreeQ[r,KellyIntegrate]
- ] /; FreeQLaplace[f] &&
- And@@(FreeQ[f,#]&/@{Blank,Integrate,IntegrateG}) && FreeQ[x,Blank]
-
- (* ======================================================================== *)
-
- Dispatcher[done_,c_,x_,xmin_,xmax_] := FailInt/;
- Not[FreeQ[{done,c},FailInt]]
-
- Dispatcher[done_,0,x_,xmin_,xmax_] := 0
-
- Dispatcher[1,c_,x_,xmin_,xmax_] := c (xmax-xmin)/;FreeQ[c,x]
-
- Dispatcher[done_,c_,x_,xmin_,xmax_] :=
- c Dispatcher[done,1,x,xmin,xmax]/;FreeQ[c,x] && c=!=1
-
- Dispatcher[done_,c_ f_,x_,xmin_,xmax_] :=
- c Dispatcher[done,f,x,xmin,xmax]/;FreeQ[c,x]
-
- Dispatcher[done_,f_,x_,xmin_,xmax_] := FailInt/;!FreeQ[done,FailInt]
-
- Dispatcher[done_,f_,x_,-Infinity,Infinity] :=
- Module[ {z,answer},
- If[ Expand[f//.x->-z] === Expand[f//.x->z],
- 2 Dispatcher[done,f,x,0,Infinity],
- answer =
- Dispatcher[done,ExpandDenominator[Together[
- (f/.x->z) + (f/.x->-z) ]],z,0,Infinity];
- If[ FreeQ[answer,FailInt],
- answer,
- Expand[Dispatcher[done,f,x,0,Infinity] +
- Dispatcher[done,(f/.x->-z)/.z->x,x,0,Infinity]]
- ]
- ]
- ]
-
- Dispatcher[done_,f_,x_,-Infinity,xmax_] :=
- Module[ {z},
- Dispatcher[done//.x->-z,f//.x->-z,z,-xmax,Infinity]
- ] /; xmax=!=Infinity
-
- Dispatcher[done_,f_,x_,0,xmax_] :=
- Dispatcher[done,Together[f/.HBfun],x,0,xmax]/;
- Not[FreeQ[f,Csch]] || Not[FreeQ[f,Sech]]
-
- Dispatcher[done_,f_,x_,0,xmax_] :=
- Dispatcher[done,Factor[Expand[f/.HBfun]],x,0,xmax] /;
- Not[FreeQ[f,Sinh]] || Not[FreeQ[f,Cosh]]
-
- Dispatcher[done_,f_,x_,0,xmax_] :=
- AnalysExp1[done,f,x,0,xmax]/;Not[FreeQ[f,E]] && xmax=!=Infinity
-
- Dispatcher[done_,f_,x_,xmin_,xmax_] :=
- Module[ {inter},
- inter = f/.ExpandIntoTrig/.TrRuleE/.{
- Sin[z_. Complex[a_,b_]] :>
- Sin[z a] Cos[z b I] + Cos[z a] Sin[z b I]};
- Dispatcher[done,Expand[inter], x,min,max] /; inter =!= f
- ] /;
- (!FreeQ[f,Sin] || !FreeQ[f,Cos]) && !FreeQ[f,Complex]
-
- Dispatcher[1,f1_[w1_]^n_. f2_[w2_]^m_.,x_,0,xmax_] :=
- AnalysTrig[1,f1[w1]^n,f2[w2]^m,x,xmax]/;
- xmax=!=Infinity && Complement[{f1,f2},{Sin,Cos,Sec,Csc,Tan,Cot}]==={}
-
- Dispatcher[1,x_ f_[w_]^n_.,x_,0,xmax_] :=
- AnalysTrig1[1,f[w]^n,x,x,xmax]/;
- xmax=!=Infinity && Complement[{f},{Sin,Cos,Sec,Csc,Tan,Cot}]==={}
-
- Dispatcher[1,f_[w_]^n_.,x_,0,xmax_] :=
- AnalysTrig1[1,f[w]^n,1,x,xmax]/;
- xmax=!=Infinity && Complement[{f},{Sin,Cos,Sec,Csc,Tan,Cot}]==={}
-
- Dispatcher[done_,f_,x_,xmin_,xmax_] :=
- AnalysLog[done,f,x,xmin,xmax]/;Not[FreeQ[f,Log]]
-
- Dispatcher[1,(b_ + a_ x_^dg_.)^n_Integer?Positive f_.,x_,0,xmax_] :=
- KellyIntegrate[f (b+a x^dg)^n,{x,0,xmax}] /; xmax=!=Infinity
-
- Dispatcher[done_,(b_ + a_ x_^dg_.)^n_ f_.,x_,0,xmax_] :=
- AnalysAlg[done,b,1,a x^dg,n,f,x,{0,xmax}] /;xmax=!=Infinity&&
- FreeQ[b,x] && FreeQ[a,x] && Znak[a] && Expand[b+a xmax^dg]=!=0
-
- Dispatcher[done_,(f1_ + f2_)^n_ f_.,x_,xmin_,xmax_] :=
- AnalysAlg[done,f1,1,f2,n,f,x,{xmin,xmax}] /;
- FreeQ[f1,x] && Not[FreeQ[f2,x]]
-
- Dispatcher[done_,(f1_ + f2_)^n_ f_.,x_,xmin_,xmax_] :=
- AnalysAlg[done,1,1,Simplify[f2/f1],n,f f1^n,x,{xmin,xmax}] /;
- Not[FreeQ[f1,x]] && Not[FreeQ[f2,x]]
-
- Dispatcher[1,f_,x_,xmin_,xmax_] :=
- Module[ {z},
- positiveList[xmin]; positiveList[xmax];
- Dispatcher[1,MeijerG[{},{1},{0},{},{1,z/xmax}] (f/.x->z) -
- If[NumberQ[xmin] && Im[xmin]==0 && xmin<0,
- -MeijerG[{},{1},{0},{},{1,-z/xmin}] (f/.x->-z),
- MeijerG[{},{1},{0},{},{1,z/xmin}] (f/.x->z)],
- z,0,Infinity]
- ] /;
- xmin=!=0 && xmin=!=-Infinity && xmax=!=0 && xmax=!=Infinity
-
- Dispatcher[1,f_Plus,x_,xmin_,xmax_] :=
- Block[ {IntFF},
- inter = Dispatcher[1,#,x,xmin,xmax]&/@f;
- IntFF[1,inter/.IntFF[a_,b_,c_] :> a b,x]
- ]
-
- Dispatcher[1,f_,x_,xmin_,Infinity] :=
- (positiveList[xmin];
- Dispatcher[MeijerG[{1},{},{},{0},{1,x/xmin}],f,x,0,Infinity])/;
- xmin=!=0 && xmin=!=-Infinity
-
- Dispatcher[done_,f_,x_,xmin_,Infinity] :=
- Dispatcher[done,f,x,0,Infinity]/;
- xmin=!=0 && xmin=!=-Infinity
-
- Dispatcher[1,f_,x_,0,xmax_] :=
- (positiveList[xmax];
- Dispatcher[MeijerG[{},{1},{0},{},{1,x/xmax}],f,x,0,Infinity])/;
- xmax=!=Infinity
-
- Dispatcher[done_,f_,x_,0,xmax_] :=
- Dispatcher[done,f,x,0,Infinity]/;
- xmax=!=Infinity
-
- Dispatcher[done_, a_^(b_. x_^dg_.) f_.,x_,0,Infinity] :=
- Dispatcher[done Release[
- Hold[E^(-(-b) x^dg Log[a])]/.InputElem], f,x,0,Infinity]/;
- Not[SameQ[a,E]] && FreeQ[a,x] && FreeQ[b,x] && FreeQ[dg,x]
-
- Dispatcher[done_,f_,x_,0,Infinity] :=
- AnalysExp2[done,f,x,0,Infinity]/;Not[FreeQ[f,E]]
-
- Dispatcher[done_,f_,x_,0,Infinity] := IntFF[ done,f,x]
-
- Dispatcher[done_,f_,x_,xmin_,xmax_] := f FailInt
-
- (*****************************************************************************
- * Search Logarithmic Expression
- *
- *****************************************************************************)
-
- AnalysLog[1,Log[w_. x_^dg_.]^n_. f_.,x_,0,Infinity] :=
- (-1)^n AnalysLog[1,Log[w^(-1) x^(-dg)]^n f,x,0,Infinity]/;
- IntegerQ[n] && n>0 && IntegerQ[dg] && dg<0
-
- AnalysLog[1,Log[w_. x_^dg_.]^n_. f_.,x_,0,Infinity] :=
- Module[ {z,var,answer},
- answer = Dispatcher[1,PowerExpand[(f//.x->w^(-1/dg) z^(1/dg))*
- z^(1/dg-1+var)],z,0,Infinity]//.PolyGammaRule1;
- If[ Not[FreeQ[answer,FailInt]], FailInt,
- If[Not[NumberQ[dg]] , 1, Sign[dg]] dg^(-1) w^(-1/dg) n!*
- Coefficient[Expand[Normal[Series[answer,
- {var,0,n}] ]],var,n]]
- ]/;IntegerQ[n] && n>0
-
- AnalysLog[done_,Log[w_. x_^dg_.]^n_. f_.,x_,xmin_,Infinity] :=
- If[ SameQ[w xmin^dg,1] && FreeQ[w,x] && FreeQ[dg,x] && Not[Znak[w]],
- Dispatcher[ done*
- If[ Not[NumberQ[dg]] || dg > 0, Log[w x^dg]^n/.LogRule1,
- (-1)^n Log[w^(-1) x^(-dg)]^n/.LogRule1 ],f,x,xmin,Infinity],
- FailInt ] /;xmin=!=0 && IntegerQ[n] && n>0
-
- AnalysLog[done_,Log[w_. x_^dg_.]^n_. f_.,x_,0,xmax_] :=
- If[ SameQ[w xmax^dg,1] && FreeQ[w,x] && FreeQ[dg,x] && Not[Znak[w]],
- Dispatcher[ done *
- If[ Not[NumberQ[dg]] || dg > 0 ,Log[w x^dg]^n/.LogRule2,
- (-1)^n Log[w^(-1) x^(-dg)]^n/.LogRule2 ],f,x,0,xmax],
- FailInt ] /;xmax=!=Infinity && IntegerQ[n] && n>0
-
- AnalysLog[done_,Log[w_. x_^dg_.]^n_. f_.,x_,xmin_,Infinity] :=
- Module[ {z},
- If[ SameQ[w xmin^dg,1] && FreeQ[w,x] && Not[Znak[w]],
- If[ done===1 && (Not[NumberQ[dg]] || dg > 0),
- Dispatcher[ done,z^n Expand[PowerExpand[E^(z/dg) *
- f//.x->(1/w)^(1/dg) E^(z/dg)]],
- z,0,Infinity] (1/w)^(1/dg)/dg,
- (-1)^n AnalysLog[done,Log[w^(-1) x^(-dg)]^n f,x,xmin,Infinity] ],
- FailInt ] ]/;xmin=!=0
-
- AnalysLog[done_,Log[w_. x_^dg_.]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- If[ SameQ[w xmax^dg,1] && FreeQ[w,x] && Not[Znak[w]],
- If[ done===1 && (Not[NumberQ[dg]] || dg < 0),
- -Dispatcher[ done,z^n Expand[PowerExpand[E^(z/dg)*
- f//.x->(1/w)^(1/dg) E^(z/dg)]],
- z,0,Infinity] (1/w)^(1/dg)/dg,
- (-1)^n AnalysLog[done,Log[w^(-1) x^(-dg)]^n f,x,0,xmax] ],
- FailInt ] ]/;xmax=!=Infinity
-
- AnalysLog[1,Log[Tan[a_. x_]]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[z]^n (1+z^2)^(-1) (f//.x->ArcTan[z]/a)//.LogTrig,
- z,0,1]/a
- ]/; FreeQ[a,x] && xmax=== Pi/(4 a)
-
- AnalysLog[1,Log[Tan[a_. x_]]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[z]^n (1+z^2)^(-1) (f//.x->ArcTan[z]/a)//.LogTrig,
- z,0,Infinity]/a
- ]/; FreeQ[a,x] && xmax=== Pi/(2 a)
-
- AnalysLog[1,Log[Sin[a_. x_]]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[z]^n (1-z^2)^(-1/2) (f//.x->ArcSin[z]/a)//.LogTrig,
- z,0,1]/a
- ]/; FreeQ[a,x] && xmax=== Pi/(2 a)
-
- AnalysLog[1,Log[Csc[a_. x_]]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[1/z]^n (1-z^2)^(-1/2) (f//.x->ArcSin[z]/a)//.LogTrig,
- z,0,1]/a
- ]/; FreeQ[a,x] && xmax=== Pi/(2 a)
-
- AnalysLog[1,Log[Cos[a_. x_]]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[z]^n (1-z^2)^(-1/2) (f//.x->ArcCos[z]/a)//.LogTrig,
- z,0,1]/a
- ]/; FreeQ[a,x] && xmax=== Pi/(2 a)
-
- AnalysLog[1,Log[Sec[a_. x_]]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[1/z]^n (1-z^2)^(-1/2) (f//.x->ArcCos[z]/a)//.LogTrig,
- z,0,1]/a
- ]/; FreeQ[a,x] && xmax=== Pi/(2 a)
-
- AnalysLog[1,Log[Sin[a_. x_]]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[z]^n (1-z^2)^(-1/2) (f//.x->ArcSin[z]/a)//.LogTrig,
- z,0,1]/a +
- AnalysLog[1,Log[Cos[a z]]^n (f//.x->z+Pi/(2 a))/.ExpandIntoTrig,
- z,0,Pi/(2 a)]
- ]/; FreeQ[a,x] && xmax=== Pi/a
-
- AnalysLog[1,Sin[a_. Log[x_]]^n_. f_.,x_,0,1] :=
- Module[ {z},
- -Dispatcher[1,Sin[a z] PowerExpand[E^(-z) f//.x->E^(-z)],z,0,Infinity]
- ]/;FreeQ[a,x]
-
- AnalysLog[1,Cos[a_. Log[x_]]^n_. f_.,x_,0,1] :=
- Module[ {z},
- Dispatcher[1,Cos[a z] PowerExpand[E^(-z) f//.x->E^(-z)],z,0,Infinity]
- ]/;FreeQ[a,x]
-
- AnalysLog[1,Log[a_+b_] f_.,x_,0,xmax_] :=
- Module[ {inter},
- inter = Log[a]//.{
- Log[q_ w_] :> Log[q] + Log[w],
- Log[q_^n_] :> n Log[q]};
- positiveList[ComMult[a,x]]; positiveList[ComMult[b,x]];
- If[ Head[inter]===Plus,
- Map[ Dispatcher[1,f #,x,0,xmax]&,inter ],
- Dispatcher[1,inter f,x,0,xmax]
- ] +
- AnalysLog[1,Log[1+Expand[b/a]] f,x,0,xmax]
- ]/;
- Not[FreeQ[b,x]] && Not[FreeQ[a,x]] && Not[Znak[a]] && Not[Znak[b]]
-
- AnalysLog[done_,Log[1 + a_ x_^p_.]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- If[ Not[Znak[p]],
- p^(-1) Dispatcher[(done//.x->z^(1/p)),(Log[1+a z]^n/.InputElem) *
- PowerExpand[(f//.x->z^(1/p)) z^(1/p-1)],z,0,xmax^p ],
- (-p)^(-1) Dispatcher[(done//.x->z^(-1/p)),(Log[1+a/z]^n/.InputElem)*
- PowerExpand[(f//.x->z^(-1/p)) z^(-1/p-1)],z,0,xmax^(-p)] ]
- ]/;xmax=!=Infinity && FreeQ[a,x] && FreeQ[p,x] &&
- Expand[1+a xmax^p]===0 && IntegerQ[n]
-
- AnalysLog[done_,Log[1 + a_. x_^p_.]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- If[ Not[Znak[p]],
- p^(-1) Dispatcher[done//.x->z^(1/p),(Log[1+a z]^n/.InputElem) *
- PowerExpand[(f//.x->z^(1/p)) z^(1/p-1)],z,0,
- If[xmax===Infinity,Infinity,xmax^p] ],
- (-p)^(-1) Dispatcher[done//.x->z^(-1/p), (Log[1+a/z]^n/.InputElem) *
- PowerExpand[(f//.x->z^(-1/p)) z^(-1/p-1)],z,0,
- If[xmax===Infinity,Infinity,xmax^(-p)]] ]
- ]/;FreeQ[a,x] && FreeQ[p,x] && IntegerQ[n]
-
- AnalysLog[done_,Log[1 + a_. x_^p_.]^n_. f_.,x_,xmin_,Infinity] :=
- Module[ {z},
- If[ Not[Znak[p]],
- p^(-1) Dispatcher[done//.x->z^(1/p),(Log[1+a z]^n/.InputElem) *
- PowerExpand[(f//.x->z^(1/p)) z^(1/p-1)],z,xmin^p,Infinity],
- (-p)^(-1) Dispatcher[done//.x->z^(-1/p),(Log[1+a/z]^n/.InputElem) *
- PowerExpand[(f//.x->z^(-1/p)) z^(-1/p-1)],z,xmin^(-p),Infinity] ]
- ]/;FreeQ[a,x] && FreeQ[p,x] && IntegerQ[n]
-
- AnalysLog[1,Log[1 + a_. E^(b_. x_)]^n_. f_.,x_,0,Infinity] :=
- Module[ {z},
- If[ Not[Znak[b]],
- b^(-1) Dispatcher[1,Log[1+a z]^n (f//.x->1/b Log[z])/z,z,1,Infinity],
- -b^(-1) Dispatcher[1,Log[1+a z]^n (f//.x->1/b Log[z])/z,z,0,1] ]
- ]/; FreeQ[b,x] && FreeQ[a,x]
-
- AnalysLog[1,Log[1+b_. f_[a_. x_]^m_.]^n_. g_[w_]^m_.,x_,0,xmax_] :=
- Module[ {int},
- int = Integrate[g[w]^m,x];
- (int Log[1+b f[a x]^m]^n/.{x->xmax}) -
- (int Log[1+b f[a x]^m]^n/.{x->0}) +
- b m Map[ Dispatcher[1,#/(1+b f[a x]^m),x,0,xmax]&,
- Expand[TrigRuleConv[int f[a x]^(m-1) D[f[a x],x]]] ]
- ]/; FreeQ[a,x] && xmax=== Pi/(2 a) && IntegerQ[n] &&
- Complement[{f,g},{Sin,Cos}]==={}
-
- AnalysLog[1,Log[1+b_. Sin[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[1+b z^m]^n (1-z^2)^(-1/2) (f//.x->ArcSin[z]/a)//.LogTrig,
- z,0,1]/a
- ]/; FreeQ[a,x] && xmax=== Pi/(2 a) && IntegerQ[n]
-
- AnalysLog[1,Log[1+b_. Cos[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[1+b z^m]^n (1-z^2)^(-1/2) (f//.x->ArcCos[z]/a)//.LogTrig,
- z,0,1]/a
- ]/; FreeQ[a,x] && xmax=== Pi/(2 a) && IntegerQ[n]
-
- AnalysLog[1,Log[1+b_. Tan[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[1+b z^m]^n (1+z^2)^(-1) (f//.x->ArcTan[z]/a)//.LogTrig,
- z,0,Infinity]/a
- ]/; FreeQ[a,x] && xmax=== Pi/(2 a) && IntegerQ[n]
-
- AnalysLog[1,Log[1+b_. Cot[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] :=
- Module[ {z},
- Dispatcher[1,Log[1+b z^(-m)]^n (1+z^2)^(-1) (f//.x->ArcTan[z]/a)//.LogTrig,
- z,0,Infinity]/a
- ]/; FreeQ[a,x] && xmax=== Pi/(2 a) && IntegerQ[n]
-
- AnalysLog[1,Log[1+b_. Sin[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] :=
- Block[ {zn,HyperInteg},Factor[SimpPower[Expand[
- AnalysLog[1,Log[1+b Sin[a zn]^m]^n (f//.x->zn),zn,0,Pi/(2 a)]/a +
- AnalysLog[1,Log[1+b Cos[a zn]^m]^n (f//.x->zn+Pi/(2 a))/.ExpandIntoTrig,
- zn,0,Pi/(2 a)]]]/.{
- Arg[s_] :> Pi/;Znak[s],
- Arg[s_] :> 0/;Not[Znak[s]]}]
- ]/; FreeQ[a,x] && xmax=== Pi/a && IntegerQ[n]
-
- AnalysLog[1,Log[1+b_. Cos[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] :=
- Block[ {zn,HyperInteg},Factor[SimpPower[Expand[
- AnalysLog[1,Log[1+b Cos[a zn]^m]^n (f//.x->zn),zn,0,Pi/(2 a)]/a +
- AnalysLog[1,Log[1-b Sin[a zn]^m]^n (f//.x->zn+Pi/(2 a))/.
- ExpandIntoTrig,zn,0,Pi/(2 a)]]]/.{
- Arg[s_] :> Pi/;Znak[s],
- Arg[s_] :> 0/;Not[Znak[s]]}]
- ]/; FreeQ[a,x] && xmax=== Pi/a && IntegerQ[n]
-
- AnalysLog[1,Log[1+b_. Sin[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] :=
- Block[ {z,HyperInteg},Expand[
- AnalysLog[1,Log[1+b Sin[a z]^m]^n (f//.x->z+Pi/a)/.ExpandIntoTrig,
- z,0,Pi/a] +
- AnalysLog[1,Log[1+(-1)^m b Sin[a z]^m]^n (f//.x->z+Pi/a)/.
- ExpandIntoTrig,z,0,Pi/a]]
- ]/; FreeQ[a,x] && xmax=== 2 Pi/a && IntegerQ[n]
-
- AnalysLog[1,Log[1+b_. Cos[a_. x_]^m_.]^n_. f_.,x_,0,xmax_] :=
- Block[ {z,HyperInteg},Expand[
- AnalysLog[1,Log[1+b Cos[a z]^m]^n (f//.x->z+Pi/a)/.ExpandIntoTrig,
- z,0,Pi/a] +
- AnalysLog[1,Log[1+(-1)^m b Cos[a z]^m]^n (f//.x->z+Pi/a)/.
- ExpandIntoTrig,z,0,Pi/a]]
- ]/; FreeQ[a,x] && xmax=== 2 Pi/a && IntegerQ[n]
-
- AnalysLog[done_,Log[Abs[1+a_ x_^n_.]] f_.,x_,0,Infinity] :=
- Dispatcher[done,(Log[Abs[1+a x^n]]/.InputElem) f,x,0,Infinity]
-
- AnalysLog[done_,Log[(1+ x_)/(1-x_)] f_.,x_,0,xmax_] :=
- Module[ {inter},
- inter = Log[(1+x)/(1-x)]/.InputElem;
- If[ FreeQ[inter,MeijerG], FailInt,
- Dispatcher[done,inter f,x,0,xmax]]
- ]
-
- AnalysLog[done_,Log[(1+x_)/(x_-1)] f_.,x_,1,xmax_] :=
- Module[ {inter},
- inter = Log[(1+x)/(x-1)]/.InputElem;
- If[ FreeQ[inter,MeijerG], FailInt,
- Dispatcher[done,inter f,x,1,xmax]]
- ]
-
- AnalysLog[1,Log[a_Plus] f_.,x_,0,xmax_] :=
- Module[ {add},
- add = ComPlus[a,x];
- If[ add===0 || add===1, FailInt,
- positiveList[add];
- positiveList[ComMult[a-add,x]];
- Log[add] Dispatcher[1,f,x,0,xmax] +
- AnalysLog[1,Log[1+Expand[(a-add)/add]] f,x,0,xmax]
- ]]
-
- AnalysLog[1,Log[Abs[a_Plus]] f_.,x_,0,xmax_] :=
- Module[ {add},
- add = ComPlus[a,x];
- If[ add===0 || add===1, FailInt,
- Log[Abs[add]] Dispatcher[1,f,x,0,xmax] +
- AnalysLog[1,Log[Abs[1+Expand[(a-add)/add]]] f,x,0,xmax]
- ]]
-
- AnalysLog[ __ ] := Module[ {w}, w FailInt ]
-
- (*****************************************************************************
- * Search Algebraic Expression
- *
- *****************************************************************************)
-
- AnalysAlg[done_,s_,m_,s1_+s2_,n_,f_,x_,lim_] :=
- AnalysAlg[done,s+s1,m,s2,n,f,x,lim]/;
- FreeQ[s1,x]
-
- AnalysAlg[done_,s_,m_,m1_ m2_,n_,f_,x_,lim_] :=
- AnalysAlg[done,s,m m1,m2,n,f,x,lim]/;
- FreeQ[m1,x]
-
- AnalysAlg[done_,s_,m_,x_^dg_,n_,f_,x_,{xmin_,xmax_}] :=
- Module[ {z},
- dg^(-1) SearchRule[done//.x->z^(1/dg),s,m,1,n,PowerExpand[Simplify[
- (f//.x->z^(1/dg)) z^(1/dg-1)]],
- z,{If[xmin===-Infinity,-Infinity,
- If[xmin===0,0,xmin^dg]],
- If[xmax===Infinity, Infinity,
- If[xmax===0,0,xmax^dg]]}]
- ]/; Not[NumberQ[N[dg]]]
-
- AnalysAlg[done_,s_,m_,x_^dg_.,n_,f_,x_,lim_] :=
- SearchRule[done,s,m,dg,n,f,x,lim]
-
- AnalysAlg[1,s_,m_,Exp[a_. x_^dg_.+const_.],n_,f_,x_,{0,Infinity}] :=
- Module[ {var},
- AnalysAlg[1,s,m,Exp[a var^(-dg)+const/.x->1/var],n,
- (f/.x->1/var) var^(-2),var,{0,Infinity}] ]/;
- FreeQ[a,x] && NumberQ[dg] && Im[dg]==0 && dg<0
-
- AnalysAlg[1,s_,m_,Exp[a_. x_^dg_.+const_/;FreeQ[const,x]],n_,f_,x_,interv_] :=
- E^(const n) AnalysAlg[1,s E^(-const),m,E^(a x^dg),n,f,x,interv]
-
- AnalysAlg[1,s_,m_,Exp[a_ x_^dg_.],n_,x_^k_. f_.,x_,{0,Infinity}] :=
- Block[{z,var,var1,var2,HyperInteg},
- var1 = s/m;
- If[ Znak[var1],var=-var2;var1=-s/m,var=var2];
- m^n (-1/a)^(1/dg) dg^(-1) Dispatcher[1,Gamma[-n]^(-1)*
- MeijerG[ {n+1},{},{0},{},{1,var z^dg} ]*
- Log[z]^(1/dg-1) Expand[x^k f//.x->(-1/a)^(1/dg) Log[z]^(1/dg)]/
- z^(n+1),z,1,Infinity]/.{var2->var1}
- ]/;
- FreeQ[a,x] && Znak[a] && NumberQ[dg] && Im[dg]==0 && dg>0 &&
- NumberQ[n] && Im[n]==0 && n<0
-
- AnalysAlg[1,s_,m_,Exp[a_ x_^dg_.],n_,f_,x_,{0,Infinity}] :=
- Block[{z,var,var1,var2,HyperInteg},
- var1 = s/m;
- If[ Znak[var1],var=-var2;var1=-s/m,var=var2];
- m^n (-1/a)^(1/dg) dg^(-1) Dispatcher[1,Gamma[-n]^(-1)*
- MeijerG[ {n+1},{},{0},{},{1,var z^dg} ]*
- Log[z]^(1/dg-1) Expand[f//.x->(-1/a)^(1/dg) Log[z]^(1/dg)]/
- z^(n+1),z,1,Infinity]/.{var2->var1}
- ]/;
- Not[Znak[s/m]] && FreeQ[a,x] && Znak[a] && NumberQ[dg] &&
- Im[dg]==0 && dg>0 && NumberQ[n] && Im[n]==0 && n<0
-
- AnalysAlg[1,s_,m_,Exp[a_. x_^dg_.],n_,x_^k_. f_.,x_,{0,Infinity}] :=
- Block[{z,var,var1,var2,HyperInteg},
- If[ s+m==0 && n<-1, Return[ var Infinity ] ];
- var1 = m/s;
- If[ Znak[var1],var=-var2;var1=-m/s,var=var2];
- s^n (1/a)^(1/dg)/dg Dispatcher[1,Gamma[-n]^(-1)*
- MeijerG[ {n+1},{},{0},{},{1,var z^dg} ]*
- Log[z]^(1/dg-1) z^(-1) *
- Expand[x^k f//.x->(1/a)^(1/dg) Log[z]^(1/dg)]/.{E^(r1_+r2_) :>
- (E^r1) (E^r2)},z,1,Infinity]/.{var2->var1}
- ]/;
- FreeQ[a,x] && Not[Znak[a]] && NumberQ[dg] && Im[dg]==0 && dg>0 &&
- NumberQ[n] && Im[n]==0 && n<0
-
- AnalysAlg[1,s_,m_,Exp[a_. x_^dg_.],n_,f_,x_,{0,Infinity}] :=
- Block[{z,var,var1,var2,HyperInteg},
- var1 = m/s;
- If[ Znak[var1],var=-var2;var1=-m/s,var=var2];
- s^n (1/a)^(1/dg)/dg Dispatcher[1,Gamma[-n]^(-1)*
- MeijerG[ {n+1},{},{0},{},{1,var z^dg} ]*
- Log[z]^(1/dg-1) z^(-1) *
- Expand[f//.x->(1/a)^(1/dg) Log[z]^(1/dg)]/.{E^(r1_+r2_) :>
- (E^r1) (E^r2)},z,1,Infinity]/.{var2->var1}
- ]/;
- Not[Znak[s/m]] && FreeQ[a,x] && Not[Znak[a]] && NumberQ[dg] &&
- Im[dg]==0 && dg>0 && NumberQ[n] && Im[n]==0 && n<0
-
- AnalysAlg[done_,s_,m_,trigf_[a_. x_]^dg_.,n_,f_,x_,lim_] :=
- AnalysAlgTrig[done,s,m,trigf[a x]^dg,n,f,x,lim]/;
- FreeQ[a,x] && Complement[{trigf},{Sin,Cos,Tan,Cot}]==={}
-
- AnalysAlg[ __ ] := Module[ {w}, w FailInt ]
-
- SearchRule[done_,num1_ s_,num2_ m_,dg_,n_,f_,x_,lim_] :=
- E^(I Pi n) SearchRule[done,Abs[num1] s,Abs[num2] m,dg,n,f,x,lim]/;
- NumberQ[num1] && NumberQ[num2] && Im[num1]==0 &&
- Im[n]==0 && num1<0 && num2<0
-
- SearchRule[done_,num_ s_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
- SearchRuleGen2[done,num,s,m,dg,n,f,x,{xmin,xmax}]/;
- NumberQ[num] && Im[num]==0 && num<0
-
- SearchRule[done_,num_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
- SearchRuleGen2[done,num,1,m,dg,n,f,x,{xmin,xmax}]/;
- NumberQ[num] && Im[num]==0 && num<0
-
- SearchRuleGen2[done_,num_,s_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
- If[ N[n]<-1,FailInt,
- (s num)^n Pi Dispatcher[ done,
- MeijerG[ {0},{1/2},{0},{1/2},{1,-m x^dg/(s num)} ] f,
- x,xmin,xmax ]]/;xmax=!=Infinity &&xmin<N[(-s num/m)^(1/dg)]<xmax&&
- (And@@(NumberQ[#]&/@N[{s,num,m,dg,xmin,xmax}]))&&N[n]<=-1
-
- SearchRuleGen2[done_,num_,s_,m_,dg_,n_,x_^k_. f_.,x_,{xmin_,xmax_}] :=
- Module[ {z,lim1,lim2,function},
- lim1 = xmin; lim2 = xmax;
- function =
- If[ n === -1 && (xmin==0&&xmax===Infinity||done=!=1||!FreeQ[f,Power]
- || !FreeQ[f,Log] || !FreeQ[f,ArcCos] || !FreeQ[f,ArcSin]),
- Pi MeijerG[ {0},{1/2},{0},{1/2},{1,m x^dg/(Abs[num] s)}]/(num s),
- If[ !n === -1,
- If[ xmax===Infinity && xmin =!=-Infinity &&
- Expand[m xmin^dg+num s] === 0 ||
- xmax===Infinity && xmin===0 && done=!=1, lim1 = 0;
- (Abs[num] s)^n *
- If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
- MeijerG[ {n+1},{},{},{0},{1,m x^dg/(Abs[num] s)} ] ,
- If[ EvenQ[dg] &&xmin ===-Infinity&&Expand[m xmax^dg+num s]===0 &&
- Expand[x^k f//.x->-z] === Expand[x^k f//.x->z],
- lim1 = 0; lim2 = Infinity;
- (Abs[num] s)^n *
- If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
- MeijerG[ {n+1},{},{},{0},{1,m x^dg/(Abs[num] s)} ],
- FailInt ]],
- FailInt ]];
- Dispatcher[ done function,x^k f,x,lim1,lim2 ]
- ]
-
- SearchRuleGen2[done_,num_,s_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
- Module[ {z,lim1,lim2,function},
- lim1 = xmin; lim2 = xmax;
- function =
- If[ n === -1 && (xmin==0&&xmax===Infinity||done=!=1||!FreeQ[f,Power]
- || !FreeQ[f,Log] || !FreeQ[f,ArcCos] || !FreeQ[f,ArcSin]),
- Pi MeijerG[ {0},{1/2},{0},{1/2},{1,m x^dg/(Abs[num] s)}]/(num s),
- If[ !n === -1,
- If[ xmax===Infinity && xmin =!=-Infinity &&
- Expand[m xmin^dg+num s] === 0 ||
- xmax===Infinity && xmin===0 && done=!=1, lim1 = 0;
- (Abs[num] s)^n*
- If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
- MeijerG[ {n+1},{},{},{0},{1,m x^dg/(Abs[num] s)} ] ,
- If[ EvenQ[dg] &&xmin ===-Infinity&&Expand[m xmax^dg+num s]===0 &&
- Expand[f//.x->-z] === Expand[f//.x->z],
- lim1 = 0; lim2 = Infinity;
- (Abs[num] s)^n*
- If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
- MeijerG[ {n+1},{},{},{0},{1,m x^dg/(Abs[num] s)} ],
- FailInt ]],
- FailInt ]];
- Dispatcher[ done function,f,x,lim1,lim2 ]
- ]
-
- SearchRule[done_,s_,num_ m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
- SearchRuleGen1[done,s,num,m,dg,n,f,x,{xmin,xmax}]/;
- NumberQ[num] && Im[num]==0 && num<0
-
- SearchRule[done_,s_,num_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
- SearchRuleGen1[done,s,num,1,dg,n,f,x,{xmin,xmax}]/;
- NumberQ[num] && Im[num]==0 && num<0
-
- SearchRuleGen1[done_,s_,num_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
- If[ N[n]<-1,FailInt,
- s^n Pi Dispatcher[ done,
- MeijerG[ {0},{1/2},{0},{1/2},{1,-m num x^dg/s} ] f,x,
- xmin,xmax]]/;xmax=!=Infinity&&xmin<N[(-s/(num m))^(1/dg)]<xmax&&
- (And@@(NumberQ[#]&/@N[{s,num,m,dg,n,xmin,xmax}]))&&N[n]<=-1
-
- SearchRuleGen1[done_,s_,num_,m_,dg_,n_,x_^k_. f_.,x_,{xmin_,xmax_}] :=
- Module[ {z,lim1,lim2,function},
- lim1 = xmin; lim2 = xmax;
- If[ xmax=!=Infinity && Expand[m num xmax^dg+s] =!= 0 &&
- Expand[m num xmin^dg+s] =!= 0,
- positiveList[-m num]; positiveList[s];
- Return[
- s^n Gamma[-n]^(-1)*
- Dispatcher[ done,
- MeijerG[ {n+1},{},{0},{},{1,m num x^dg/s} ] x^k f,
- x,lim1,lim2 ] ],
- function =
- If[ n === -1 && (xmin==0&&xmax===Infinity||done=!=1||!FreeQ[f,Power]||
- !FreeQ[f,Log]||!FreeQ[f,ArcCos]||!FreeQ[f,ArcSin]||!FreeQ[f,PolyLog]),
- positiveList[-m num]; positiveList[s];
- s^n Pi MeijerG[ {0},{1/2},{0},{1/2},{1,m Abs[num] x^dg/s} ],
- If[ !n === -1,
- If[ xmax=!=Infinity && Expand[m num xmax^dg+s] === 0 &&
- Expand[m num xmin^dg+s] =!= 0 ||
- xmax===Infinity && done=!=1, lim2 = Infinity;
- s^n *
- If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
- MeijerG[ {},{n+1},{0},{},{1,Abs[num] m x^dg/s} ],
- If[ Expand[m num xmin^dg+s] === 0 && xmax === 0 && EvenQ[dg] &&
- Expand[x^k f//.x->-z] === (x^k f//.x->z),
- lim1 = 0; lim2 = -xmin;
- s^n *
- If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
- MeijerG[ {},{n+1},{0},{},{1,Abs[num] m x^dg/s} ],
- If[ Expand[m num xmin^dg+s] === 0 && Expand[m num xmax^dg+s] === 0 &&
- EvenQ[dg] && Expand[x^k f//.x->-z] === (x^k f//.x->z),
- lim1 = 0; lim2 = Infinity;
- 2 s^n *
- If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
- MeijerG[ {},{n+1},{0},{},{1,Abs[num] m x^dg/s} ],
- FailInt ]]],
- FailInt ]]];
- Dispatcher[ done function,x^k f,x,lim1,lim2 ]
- ]
-
- SearchRuleGen1[done_,s_,num_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
- Module[ {z,lim1,lim2,function},
- lim1 = xmin; lim2 = xmax;
- If[ xmax=!=Infinity && Expand[m num xmax^dg+s] =!= 0 &&
- Expand[m num xmin^dg+s] =!= 0,
- positiveList[-m num]; positiveList[s];
- Return[
- s^n Gamma[-n]^(-1)*
- Dispatcher[ done,
- MeijerG[ {n+1},{},{0},{},{1,m num x^dg/s} ] f,
- x,lim1,lim2 ] ],
- function =
- If[ n === -1 && (xmin==0&&xmax===Infinity||done=!=1||!FreeQ[f,Power]||
- !FreeQ[f,Log]||!FreeQ[f,ArcCos]||!FreeQ[f,ArcSin]||!FreeQ[f,PolyLog]),
- positiveList[-m num]; positiveList[s];
- s^n Pi MeijerG[ {0},{1/2},{0},{1/2},{1,m Abs[num] x^dg/s} ],
- If[ !n === -1,
- If[ xmax=!=Infinity && Expand[m num xmax^dg+s] === 0 &&
- Expand[m num xmin^dg+s] =!= 0 ||
- xmax===Infinity && done=!=1, lim2 = Infinity;
- s^n *
- If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
- MeijerG[ {},{n+1},{0},{},{1,Abs[num] m x^dg/s} ],
- If[ Expand[m num xmin^dg+s] === 0 && xmax === 0 && EvenQ[dg] &&
- Expand[f//.x->-z] === (f//.x->z),
- lim1 = 0; lim2 = -xmin;
- s^n *
- If[NumberQ[n] && Im[n]==0 && n<-1,FailInt,Gamma[Expand[n+1]]]*
- MeijerG[ {},{n+1},{0},{},{1,Abs[num] m x^dg/s} ],
- If[ Expand[m num xmin^dg+s] === 0 && Expand[m num xmax^dg+s] === 0 &&
- EvenQ[dg] ,
- If[ Expand[(f//.x->-z) + (f//.x->z)]===0,0,
- If[ Expand[f//.x->-z] === (f//.x->z),
- lim1 = 0; lim2 = Infinity;
- 2 s^n *
- If[ NumberQ[n] && Im[n]==0 && n<-1,
- FailInt,
- Gamma[Expand[n+1]]
- ] *
- MeijerG[ {},{n+1},{0},{},{1,Abs[num] m x^dg/s} ],
- FailInt ]]]]],
- FailInt ]]];
- If[ function===0,0,
- Dispatcher[ done function,f,x,lim1,lim2 ]]
- ]
-
- SearchRule[done_,s_,m_,dg_,n_,f_,x_,{0,xmax_}] :=
- s^n Dispatcher[done (1+x^dg)^n,f,x,0,xmax]/;
- IntegerQ[n] && n> 0
-
- SearchRule[done_,s_,m_,dg_,n_,f_,x_,{xmin_,xmax_}] :=
- Module[ {lim1,lim2,function,z},
- lim1 = xmin; lim2 = xmax;
- function =
- If[ xmin === -Infinity && xmax === Infinity &&EvenQ[dg] &&
- Expand[f//.x->-z] === (f//.x->z),
- lim1 = 0; lim2 = Infinity;
- positiveList[m]; positiveList[s];
- 2 s^n*
- If[NumberQ[n] && Im[n]==0 && n>0,FailInt,Gamma[Expand[-n]]^(-1) ]*
- MeijerG[ {n+1},{},{0},{},{1,m x^dg/s} ],
- positiveList[m]; positiveList[s];
- s^n *
- If[NumberQ[n] && Im[n]==0 && n>0,FailInt,Gamma[Expand[-n]]^(-1) ]*
- MeijerG[ {n+1},{},{0},{},{1,m x^dg/s} ]
- ];
- Dispatcher[ done,function f,x,lim1,lim2 ]
- ]
-
- (****************************************************************************
- * Trigonometric Functions into Algebraic Functions
- *
- *****************************************************************************)
-
- AnalysAlgTrig[1,s_,m_,Cos[a_. x_]^dg_.,n_,f_,x_,{0,xmax_}] :=
- Module[{z,r},
- r = Expand[((f//.x->ArcCos[z]/a)/.TrigMultArg//.LogTrig)*
- (1-z^2)^(-1/2)]//.z->x;
- a^(-1)*
- If[Head[r]===Plus,
- Map[Dispatcher[1, (s+m x^dg)^n #,x,0,1]&,r],
- Dispatcher[1, (s+m x^dg)^n r,x,0,1]]
- ]/; xmax=== Pi/(2 a)
-
- AnalysAlgTrig[1,s_,m_,Sin[a_. x_]^dg_.,n_,f_,x_,{0,xmax_}] :=
- Module[{z,r},
- r = Expand[((f//.x->ArcSin[z]/a)/.TrigMultArg//.LogTrig)*
- (1-z^2)^(-1/2)]//.z->x;
- a^(-1)*
- If[Head[r]===Plus,
- Map[Dispatcher[1, (s+m x^dg)^n #,x,0,1]&,r],
- Dispatcher[1, (s+m x^dg)^n r,x,0,1]]
- ]/; xmax=== Pi/(2 a)
-
- AnalysAlgTrig[1,s_,m_,Tan[a_. x_]^dg_.,n_,f_,x_,{0,xmax_}] :=
- Module[{z},
- a^(-1) Dispatcher[1,(1+z^2)^(-1) (s+m z^dg)^n *
- Expand[f//.x->ArcTan[z]/a]//.LogTrig,z,0,Infinity]
- ]/; xmax=== Pi/(2 a)
-
- AnalysAlgTrig[1,s_,m_,Cot[a_. x_]^dg_.,n_,f_,x_,{0,xmax_}] :=
- Module[{z},
- a^(-1) Dispatcher[1,(1+z^2)^(-1) (s+m z^(-dg))^n *
- Expand[f//.x->ArcTan[z]/a]//.LogTrig,z,0,Infinity]
- ]/; xmax=== Pi/(2 a)
-
- AnalysAlgTrig[done_,s_,m_,trigf_[a_. x_]^dg_.,n_,f_,x_,{0,xmax_}] :=
- Block[ {z,answer,HyperInteg},
- answer = AnalysAlg[done//.x->z,s,m,trigf[a z]^dg,n,f//.x->z,z,{0,Pi/(2 a)}];
- If[ FreeQ[answer,FailInt],
- SimpPower[Expand[answer +
- AnalysAlg[done,s,m,trigf[a z+Pi/2]^dg/.TrigRule,n,
- (f//.x->z+Pi/(2 a))//.TrigRule/.ExpandIntoTrig,
- z,{0,Pi/(2 a)}]] ]//.SimpSign1/.{
- Arg[w_]:>Pi/;Znak[w], Arg[w_]:>0/;Not[Znak[w]]} ,
- FailInt]
- ]/; xmax=== Pi/a
-
- AnalysAlgTrig[done_,s_,m_,trigf_[a_. x_]^dg_.,n_,f_,x_,{0,xmax_}] :=
- Block[ {z,answer,HyperInteg},
- answer = AnalysAlg[done//.x->z,s,m,trigf[a z]^dg,n,f//.x->z,z,{0,Pi/a}];
- If[ FreeQ[answer,FailInt], Expand[answer +
- AnalysAlg[done,s,m,trigf[a z+Pi]^dg/.TrigRule,n,
- (f//.x->z+Pi/a)//.TrigRule/.ExpandIntoTrig,z,{0,Pi/a}]],
- FailInt]
- ]/; xmax=== 2 Pi/a
-
- AnalysAlgTrig[ __ ] := Module[ {var}, var FailInt]
-
- (*****************************************************************************
- * Search Trigonometric Functions
- *
- *****************************************************************************)
-
- AnalysTrig[done_,f1_,f2_Plus,x_,xmax_] :=
- Map[AnalysTrig[done,f1,#,x,xmax]&,f2]
-
- AnalysTrig[done_,f1_,const_ f2_,x_,xmax_] :=
- const AnalysTrig[done,f1,f2,x,xmax]/;FreeQ[const,x]
-
- AnalysTrig[done_,const_ f1_,f2_,x_,xmax_] :=
- const AnalysTrig[done,f1,f2,x,xmax]/;FreeQ[const,x]
-
- AnalysTrig[done_,f1_[a_. x_]^n1_.,f2_[b_. x_]^n2_.,x_,xmax_] :=
- If[ a xmax=!=Pi/2 ,AnalysTrig[done,f2[b x]^n2,f1[a x]^n1,x,xmax],
- a^(-1) Dispatcher[done 2,((f1[ArcCos[x]]^n1 f2[b/a ArcCos[x]]^n2*
- (1-x^2)^(-1/2))//.LogTrig)//.InputInvTrig,x,0,1]/2]/;
- a xmax===Pi/2 || b xmax===Pi/2
-
- AnalysTrig[done_,Sin[x_]^n_.,f2_[b_. x_],x_,Pi] :=
- 2^(n+1) Dispatcher[done,x^n (1-x^2)^(n/2-1/2) *
- f2[2 b ArcCos[x]]/.InputInvTrig,x,0,1]
-
- AnalysTrig[done_,f1_[x_]^n_.,f2_[b_. x_],x_,Pi] :=
- Block[ {answer,HyperInteg},
- answer = AnalysTrig[done,f1[x]^n,f2[b x],x,Pi/2];
- If[ FreeQ[answer,FailInt], Expand[answer +
- AnalysTrig[done,PowerExpand[f1[x + Pi/2]^n/.TrigRule],
- f2[b x+b Pi/2]/.TrRuleE,x,Pi/2]],
- FailInt] ]
-
- AnalysTrig[done_,f1_[a_. x_]^n_,f2_[b_. x_]^m_.,x_,xmax_] :=
- a^(-1) AnalysTrig[done,f1[x]^n,f2[b x/a],x,Pi]/;
- a xmax===Pi && m==1
-
- AnalysTrig[done_,f1_[a_. x_]^n_.,f2_[b_. x_]^m_,x_,xmax_] :=
- b^(-1) AnalysTrig[done,f2[x]^m,f1[a x/b],x,Pi]/;
- b xmax===Pi && n==1
-
- AnalysTrig[ __ ] := Module[ {var}, var FailInt]
-
- AnalysTrig1[1,f_[a_. x_]^n_.,1,x_,xmax_] :=
- Module[ {answer},
- answer = Integrate[f[a x]^n,x];
- (answer/.x->xmax) - (answer/.x->0)
- ]/;Complement[{f},{Sin,Cos}]==={} && IntegerQ[n]
-
- AnalysTrig1[done_,f_[a_. x_]^n_.,w_,x_,xmax_] :=
- a^(-1) Dispatcher[done,(f[ArcCos[x]]^n If[w===1,1,ArcCos[x]/a] *
- (1-x^2)^(-1/2)//.LogTrig)//.InputInvTrig,x,0,1]/;
- a xmax===Pi/2
-
- AnalysTrig1[done_,Sin[a_. x_]^n_.,w_,x_,xmax_] :=
- a^(-1) If[w===1,2,Pi/a] AnalysTrig1[done,Sin[x]^n,1,x,Pi/2]/;
- a xmax===Pi
-
- AnalysTrig1[done_,const_ Sin[a_. x_]^n_.,w_,x_,xmax_] :=
- a^(-1) If[w===1,2,Pi/a] Dispatcher[done,(1-x^2)^(n/2-1/2)*
- If[w===1,1,ArcCos[x]],x,0,1] const/;
- a xmax===Pi && FreeQ[const,x]
-
- AnalysTrig1[ __ ] := Module[ {var}, var FailInt]
-
-
- (*****************************************************************************
- * Search Exp Functions
- *
- *****************************************************************************)
-
- AnalysExp1[done_,f_,x_,0,xmax_] :=
- AnalysExp11[done, f/.{
- E^z_ :> Module[ {inter},
- inter = Together[Expand[z]];
- E^(Collect[Numerator[inter],x]/
- Collect[Denominator[inter],x])
- ] /;!FreeQ[z,x]
- },x,0,xmax]
-
- AnalysExp11[done_,E^(a_. x_^dg_. + c_.) f_.,x_,0,xmax_] :=
- E^c Dispatcher[done,If[ Znak[a],E^(a x^dg)/.InputElem,
- E^(a x^dg)/.InputExp ] f,x,0,xmax]/;
- FreeQ[a,x] && FreeQ[c,x]
-
- AnalysExp11[done_,E^(a_. x_^dg1_. + b_. x_^dg2_. + c_.) f_.,x_,0,xmax_] :=
- E^c Dispatcher[done,(E^(a x^dg1)/.InputExp) (E^(b x^dg2)/.InputExp) f,
- x,0,xmax]/;FreeQ[a,x] && FreeQ[b,x] && FreeQ[c,x]
-
- AnalysExp11[ __ ] := Module[ {var}, var FailInt]
-
- AnalysExp2[done_,E^c_. f_.,x_,0,Infinity] :=
- E^c AnalysExp21[done, f/.{E^z_ :> E^Collect[z,x]/;!FreeQ[z,x]},
- x,0,Infinity]/;FreeQ[c,x]
-
- AnalysExp2[done_,f_,x_,0,Infinity] :=
- AnalysExp21[done, Expand[f]/.{
- E^z_ :> E^Collect[z,x]/;!FreeQ[z,x]} /.{
- Abs[n_. z_] :> Abs[-n z] /; NumberQ[n] && Negative[n]
- },x,0,Infinity]
-
- AnalysExp21[done_,f_,x_,0,Infinity] :=
- IntFF[done,
- f/.{
- d_ - d_. E^(a_. x^dg_.+c_.) :>
- (
- positiveList[-a];
- d (1- E^(a x^dg)/.InputElem) E^c
- )/;FreeQ[d,E] && FreeQ[a,x] && FreeQ[c,x],
- d_. E^(a_. x^dg_.+c_.) - d_ :>
- (
- positiveList[-a];
- -d (1- E^(a x^dg)/.InputElem) E^c
- )/;FreeQ[d,E] && FreeQ[a,x] && FreeQ[c,x],
- E^(a_. x^dg_.+c_.) :> FailInt/;
- NumberQ[a] && Im[a]==0 &&a>0 && FreeQ[c,x],
- E^(a_. x^dg_.+c_.) :>
- (
- positiveList[-a];
- (E^(a x^dg)/.InputElem) E^c
- )/;FreeQ[a,x] && FreeQ[c,x],
- E^(a_. Abs[x]^dg_.+c_.) :>
- (
- positiveList[-a];
- (E^(a x^dg)/.InputElem) E^c
- )/;FreeQ[a,x] && FreeQ[c,x],
- E^(a_. x^dg1_. + b_. x^dg2_.+c_.) :>
- (
- positiveList[-a]; positiveList[-b];
- (E^(a x^dg1)/.InputElem) *
- (E^(b x^dg2)/.InputElem) E^c
- )/;FreeQ[a,x] && FreeQ[b,x] && FreeQ[c,x]
- },x]
-
- AnalysExp21[ done_,f_,x_,xmin_,xmax_ ] := f FailInt
-
- (*****************************************************************************
- * Search Other Functions
- *
- *****************************************************************************)
-
- IntFF[done_,f_,x_] := Module[ {},
- positive[__] = False;
- IntFF1[done,f,x] ]
-
- IntFF1[done_,MeijerG[par__] f_.,x_] := IntFF1[done MeijerG[par],f,x]
-
- IntFF1[done_,x_^dg_.,x_] := IntGG[dg+1,done,x] /; FreeQ[dg,x]
-
- IntFF1[done_,const_ f_,x_] := const IntFF1[done,f,x]/;FreeQ[const,x]
-
- IntFF1[done_,const_,x_] := const IntGG[1,done,x]/;FreeQ[const,x]
-
- IntFF1[done_,x_^deg_. f_,x_] :=
- FindIntegrand[ deg+1,done,f,x ] /;FreeQ[deg,x]
-
- IntFF1[done_,f_,x_] := FindIntegrand[ 1,Simplify[done],f,x ]
-
- FindIntegrand[alfa_,1,pol1_. f_[w_]^n_.+pol2_.,x_] :=
- Module[ {answer},
- answer = SingleGfunction[
- alfa,CollectSC[Expand[Expand[
- pol1 f[w]^n+pol2,Trig->True]/.ColTerm]],
- pol1 f[w]^n+pol2,x];
- answer/;FreeQ[answer,FailInt]
- ] /;
- Complement[{f},{Sin,Cos}]==={} && PolynomialQ[pol1,x] &&
- PolynomialQ[pol2,x]
-
- FindIntegrand[alfa_,1,f1_[w1_]^n_. f2_[w2_]^m_.+pol_.,x_] :=
- Module[ {answer},
- answer = SingleGfunction[
- alfa,CollectSC[Expand[Expand[
- f1[w1]^n f2[w2]^m+pol,Trig->True]/.ColTerm]],
- f1[w1]^n f2[w2]^m+pol,x];
- answer/;FreeQ[answer,FailInt]
- ] /;
- Complement[{f1,f2},{Sin,Cos}]==={} && PolynomialQ[pol,x]
-
- FindIntegrand[alfa_,1,pol1_. f1_[w1_]^n_.+pol2_. f2_[w2_]^m_.+pol3_.,x_] :=
- Module[ {answer},
- answer = SingleGfunction[
- alfa,CollectSC[Expand[Expand[ pol1 f1[w1]^n +
- pol2 f2[w2]^m+pol3,Trig->True]/.ColTerm]],
- pol1 f1[w1]^n + pol2 f2[w2]^m+pol3,x];
- answer/;FreeQ[answer,FailInt]
- ] /;
- Complement[{f1,f2},{Sin,Cos}]==={} &&
- (And@@(PolynomialQ[#,x]&/@{pol1,pol2,pol3}))
-
- FindIntegrand[alfa_,done_,f_,x_] :=
- GGfunctions[alfa,done,CollectSC[Expand[
- Expand[f,Trig->True]/.ColTerm]]//.{
- Sin[w_+v_] :>
- Sin[w] Cos[v] + Cos[w] Sin[v]/;Not[FreeQ[v,x]] && Not[FreeQ[w,x]],
- Cos[w_+v_] :>
- Cos[w] Cos[v] - Sin[w] Sin[v]/;Not[FreeQ[v,x]] && Not[FreeQ[w,x]],
- Sin[w_Plus] :>
- Module[ {add = ComPlus[w,x]},
- Sin[add] Cos[w-add] + Cos[add] Sin[w-add]
- ],
- Cos[w_Plus] :>
- Module[ {add = ComPlus[w,x]},
- Cos[add] Cos[w-add] - Sin[add] Sin[w-add]
- ]
- },x]/;
- Not[FreeQ[f,Sin]] || Not[FreeQ[f,Cos]]
-
- FindIntegrand[alfa_,done_,f_,x_] := GGfunctions[alfa,done,f,x]
-
- SingleGfunction[alfa_,f_,oldf_,x_] :=
- TaylorSeriesTrig[alfa,CondTrigDegree[f,x],f,oldf,x]/;
- CondTrig[f,x]
-
- SingleGfunction[alfa_,f_,oldf_,x_] := GGfunctions[alfa,1,oldf,x]
-
- TaylorSeriesTrig[ alfa_,{dg_,True},f_,oldf_,x_ ] :=
- Module[ {var},
- -1/dg *
- TaylorSeriesTrig[ alfa/dg,{1,True},f/.x->var^(1/dg),
- oldf,var]
- ] /;
- NumberQ[dg] && Negative[dg]
-
- GGfunctions[ alfa_,done_,f_,x_ ] :=
- f IntGG[alfa,done,x] /; FreeQ[f,x]
-
- GGfunctions[ alfa_,done_,f_,x_ ] :=
- IntGG[alfa,FindGfunctionGl[done,f,x],x]
-
- FindGfunctionGl[done_,f_Plus,x_] := Map[ FindGfunctionGl[done,#,x]&,f ]
-
- FindGfunctionGl[done_,MeijerG[par__] f_.,x_] :=
- FindGfunctionGl[done MeijerG[par],f,x]
-
- FindGfunctionGl[done_,f_,x_] := f done/;FreeQ[f,x]
-
- FindGfunctionGl[done_,const_ f_,x_] :=
- const FindGfunctionGl[done,f,x]/;FreeQ[const,x]
-
- FindGfunctionGl[done_,f_,x_] := FindGfunction[done,f,x]
-
- FindGfunction[done_,f_,x_] := FindGfunction1[done,Expand[f/.InputBessel],x]/;
- Apply[Or,Not[FreeQ[f,#]]&/@ListBessel] && Not[FreeQ[f,x]]
-
- FindGfunction[done_,f_,x_] := FindGfunction1[done,Expand[f/.InputOther],x]/;
- Apply[Or,Not[FreeQ[f,#]]&/@ListOther] && Not[FreeQ[f,x]]
-
- FindGfunction[done_,f_,x_] :=
- Module[ {answer},
- answer = f/.InputElem;
- If[ Not[SameQ[answer,f]],
- FindGfunction1[done,Expand[answer],x],
- Expand[f done] ]
- ]/;
- Apply[Or,Not[FreeQ[f,#]]&/@ListElem] && Not[FreeQ[f,x]]
-
- FindGfunction[ done_,f_,x_] := Expand[f done]
-
- FindGfunction1[ done_,f_Plus,x_] := Map[FindGfunction1[done,#,x]&,f]
-
- FindGfunction1[done_,MeijerG[par1__] MeijerG[par2__] f_.,x_] :=
- FindGfunction1[done MeijerG[par1] MeijerG[par2],f,x]
-
- FindGfunction1[done_,MeijerG[par__]^2 f_.,x_] :=
- FindGfunction1[done MeijerG[par]^2,f,x]
-
- FindGfunction1[done_,MeijerG[par__] f_.,x_] :=
- FindGfunction1[done MeijerG[par],f,x]
-
- FindGfunction1[done_,Sign[par_] f_.,x_] :=
- FindGfunction1[done Sign[par],f,x]
-
- FindGfunction1[done_,f_,x_] := f FailInt/;Not[FreeQ[f,MeijerG]]
-
- FindGfunction1[done_,c_. f_,x_] :=
- c FindGfunction[done,f,x]/;Not[FreeQ[f,x]] && FreeQ[c,x]
-
- FindGfunction1[done_,f_,x_] := Expand[f done]
-
- (*****************************************************************************
- * Convergent
- *
- *****************************************************************************)
-
- Convergent[ b_. f_[a_.x_^r_. + c_.],{x_,xmin_,Infinity} ] :=
- If[ NumberQ[r] && Re[r]<=1, False, True ] /;
- (f===Sin || f===Cos) && FreeQ[{a,b,r,c},x]
-
- Convergent[ f_,{x_,xmin_/;xmin=!=0,Infinity} ] :=
- Module[
- {answer =
- Module[ {test},
- Off[General::indet,Infinity::indet,Power::infy,General::dbyz];
- test = {PowerExpand[x f//.{
- a_ + b_. x^n_. :> b x^n /; Re[n]>0 && FreeQ[{a,b},x],
- a_. x^n1_. + b_. x^n2_. :> b x^Max[n1,n2] /; Im[n1]==0 &&
- Im[n2]==0 && FreeQ[{a,b},x] }
- ]/.x->Infinity, f/.x->Infinity};
- On[General::indet,Infinity::indet,Power::infy,General::dbyz];
- test
- ]},
- If[ FreeQ[x f,x] ||
- answer[[1]] === DirectedInfinity[-1] ||
- answer[[1]] === DirectedInfinity[1] ||
- answer[[2]] === RealInterval[{-Infinity, Infinity}] ||
- (FreeQ[answer[[1]],x] && answer[[1]]=!=0 && answer[[2]]=!=0 &&
- And@@(FreeQ[answer,#]&/@{ComplexInfinity,Indeterminate,
- DirectedInfinity,RealInterval})),
- False,
- True
- ]
- ] /; FreeQ[xmin,DirectedInfinity]
-
- Convergent[ f_,{x_,0,xmax_/;FreeQ[xmax,DirectedInfinity]} ] :=
- Module[ {z},
- Convergent[Together[PowerExpand[f/.x->1/z]/z^2],{z,1/xmax,Infinity}]
- ]
-
- Convergent[ f_,{x_,0,Infinity} ] :=
- Convergent[f,{x,0,1}] && Convergent[f,{x,1,Infinity}]
-
- Convergent[ f_,{x_,xmin_,xmax_} ] := True
-
- (*****************************************************************************
- * Supplement
- *
- *****************************************************************************)
- FreeQLaplace[ f_ ] :=
- If[ Names["LaplaceTransform"] =!= {},
- FreeQ[f, ToExpression["LaplaceTransform"]],
- True
- ]
-
- LogarithmCase[ {___,v_,___,u_,___} ] := True /;
- IntegerQ[Expand[u-v]]
-
- LogarithmCase[ {___} ] := False
-
- Delta[k_,x_] :=
- Expand[Flatten[ Map[ Table[ (#+i)/Floor[k],{i,0,Floor[k]-1} ] &, x ]]] /;
- NumberQ[k] && NonNegative[k] && (k-Floor[k])==0
-
- Delta[k_,x_] := {}
-
- ReducePar[{w1___,u_,w2___},{w3___,v_,w4___}] :=
- ReducePar[{w1,w2},{w3,w4}]/;u===v
-
- ReducePar[w1_,w2_] := {w1,w2}
-
- MultGamma[a_] :=
- Apply[ Times, Map[ Gamma, Expand[a] ] ]
-
- MultPochham[a_,k_] :=
- Apply[ Times, Map[ Pochhammer[ #,k] &, a] ]
-
- Znak[n_ a_] := True/;NumberQ[n] && Im[n]===0 && n<0
-
- Znak[Complex[0,n_] a_.] := True/;n<0
-
- Znak[n_] := True/;NumberQ[n] && Im[n]===0 &&n<0
-
- Znak[a_] := False
-
- SimpPower[f_Plus] := Map[ SimpPower[#]&,f ]
-
- SimpPower[f_Times] := Map[ SimpPower[#]&,f]
-
- SimpPower[Power[v_ u_,c_]] := SimpPower[v^c] SimpPower[u^c]
-
- SimpPower[Log[f_]] := Log[SimpPower[f]]
-
- SimpPower[Power[n_Integer,v_]] := n^Expand[v]
-
- SimpPower[Power[a_,v_+u_]] := SimpPower[a^v] SimpPower[a^u]
-
- SimpPower[Power[v_Plus,c_]] :=
- Module[ {w},
- w = Factor[v];
- If[ w=!=v, SimpPower[w^c], Map[ SimpPower[#]&,v ]^c]
- ]/;Length[v]>2
-
- SimpPower[Power[v_Plus,c_]] :=
- Module[ {w},
- w = Together[v];
- If[ w=!=v, SimpPower[w^c], Map[ SimpPower[#]&,v ]^c ]
- ]
-
- SimpPower[ Power[a_Rational,Times[b_Rational,f_]] ] :=
- (Numerator[a]^b)^f (Denominator[a]^Abs[b])^(-f Sign[b])
-
- SimpPower[ Power[Power[a_,n_Integer],m_Rational] ] :=
- If[positive[a],a^(n m),Abs[a]^(n m)]/;
- EvenQ[n] && EvenQ[Denominator[m]]
-
- SimpPower[ Power[Power[a_,n_Integer],Times[m_Rational,b_]] ] :=
- If[positive[a],a^Expand[n m b],Abs[a]^Expand[n m b]]/;
- EvenQ[n] && EvenQ[Denominator[m]]
-
- SimpPower[ Power[Power[E,u_],n_] ] := E^(u n)/;NumberQ[n]
-
- SimpPower[Power[4, Rational[1, 4]]] := 2^(1/2)
-
- SimpPower[Power[4, Rational[-1, 4]]] := 2^(-1/2)
-
- SimpPower[ f_] := f
-
- SimpIncompleteGamma[ expr_,args_/;Length[args] >1 ] :=
- Module[ {el,min,var},
- el = Union[ args/.n_. + v_. :> v/;NumberQ[n] ];
- If[ Length[el] >1, FailInt,
- argn = args/.el[[1]]->var;
- min = Min[argn/.n_. + v_. var :> n/;NumberQ[n]];
- SimpGamma[ (expr/.el[[1]]->var)//.Gamma[k_. + v_. var,n_,m_] :>
- (k+v var-1) Gamma[k+v var-1,n,m] - m^(k+v var-1) E^(-m)/;
- NumberQ[k] && k>min ]/.var->el[[1]] ]
- ]
-
- SimpIncompleteGamma[ expr_,args_ ] := FailInt
-
- SimpIncompleteGamma1[ expr_,{arg1_,arg___} ] :=
- Module[ {r,rnew},
- rnew =
- Factor[Plus@@((r=Cases[expr,a_. arg1])/.a_. arg1 :> a)] arg1;
- SimpIncompleteGamma1[ (expr - Plus@@r)+rnew,{arg} ]
- ]
-
- SimpIncompleteGamma1[ expr_, {___} ] := expr
-
- SimpGamma[ expr_Plus/;Not[FreeQ[expr,Gamma[u__]/;Length[{u}]>1]] ] :=
- Module[ {answer,r},
- answer = SimpIncompleteGamma[expr,
- Union[(r = Cases[ expr,a_. Gamma[u_,n_,m_] ])/.
- b_ Gamma[v_,n_,m_] :> v] ];
- If[ Not[FreeQ[answer,FailInt]],
- answer = SimpIncompleteGamma1[expr,
- Union[r/.b_ Gamma[v_,n_,m_] :> Gamma[v,n,m]] ]
- ];
- answer /; FreeQ[answer,FailInt]
- ]
-
- SimpGamma[f_Plus] := Map[ SimpGamma[#]&,f ]
-
- SimpGamma[ expr_/;Length[expr]>1 ] :=
- Module[ {p},
- ( expr/.Gamma[_]:>1) *
- SimpGamma1[ (Times@@Cases[p expr,Gamma[a_]^n_.])/.
- Gamma[r_]:>Gamma[Expand[r]] ]
- ]
-
- SimpGamma1[ Times[v1___,Gamma[w1_]^n_.,v2___,Gamma[w2_]^m_.] ] :=
- If[ (w2-w1)>0,
- SimpGamma1[v1 v2 ]/Factor[Pochhammer[w1,w2-w1]^n],
- Factor[Pochhammer[w2,w1-w2]^n] SimpGamma1[v1 v2 ]
- ] /; IntegerQ[w2-w1] && IntegerQ[n] && n>0 && n+m == 0
-
- SimpGamma1[Times[v1___,Gamma[u_]^n_.,v2___,Gamma[v_]^m_.]] :=
- If[ SameQ[Expand[v/2-u+1/2],0],
- (2^Expand[v-1] Pi^(-1/2))^Sign[m] *
- SimpGamma1[ Gamma[u]^(n+Sign[m])*
- Gamma[v]^(m-Sign[m]) v1 v2 *
- Gamma[Expand[u-1/2]]^Sign[m] ],
- (2^Expand[u-1] Pi^(-1/2))^Sign[n] *
- SimpGamma1[ Gamma[u]^(n-Sign[n])*
- Gamma[v]^(m+Sign[n]) v1 v2 *
- Gamma[Expand[v-1/2]]^Sign[n] ]
- ]/;
- (Expand[u/2-v+1/2]===0 || Expand[v/2-u+1/2]===0) && m n < 0
-
- SimpGamma1[Times[v1___,Gamma[u_]^n_.,v2___,Gamma[v_]^m_.]] :=
- If[ SameQ[Expand[v/2-u],0],
- (2^Expand[v-1] Pi^(-1/2))^Sign[m] *
- SimpGamma1[ Gamma[u]^(n+Sign[m])*
- Gamma[v]^(m-Sign[m]) v1 v2 *
- Gamma[Expand[u+1/2]]^Sign[m] ],
- (2^Expand[u-1] Pi^(-1/2))^Sign[n] *
- SimpGamma1[ Gamma[u]^(n-Sign[n])*
- Gamma[v]^(m+Sign[n]) v1 v2 *
- Gamma[Expand[v+1/2]]^Sign[n] ]
- ]/;
- (Expand[u/2-v]===0 || Expand[v/2-u]===0) && m n < 0
-
- SimpGamma1[Times[v1___,Gamma[u_]^n_.,v2___,Gamma[v_]^m_.]] :=
- If[ SameQ[Expand[v-u],1/2],(2^Expand[1-2 u] Pi^(1/2))^Sign[m] *
- SimpGamma1[ Gamma[u]^(n-Sign[m])*
- Gamma[v]^(m-Sign[m]) v1 v2 *
- Gamma[Expand[2 u]]^Sign[m] ],
- (2^Expand[1-2 v] Pi^(1/2))^Sign[n] *
- SimpGamma1[ Gamma[u]^(n-Sign[n])*
- Gamma[v]^(m-Sign[n]) v1 v2 *
- Gamma[Expand[2 v]]^Sign[n] ]
- ]/;
- Abs[Expand[u-v]]===1/2 && m n > 0
-
- SimpGamma1[Times[v1___,Gamma[u_]^n_.,v2___,Gamma[v_]^m_.]] :=
- SimpGamma1[ v1 v2 Gamma[u]^(n-Sign[n]) Gamma[v]^(m-Sign[m]) ] *
- (Pi/Sin[Expand[Pi u]])^Sign[n] /;
- Expand[u+v]===1 && m n > 0
-
- SimpGamma1[Times[v1___,Gamma[1+u_]^n_.,v2___,Gamma[1+v_]^m_.]] :=
- u^Sign[n] (Pi/(Sin[Expand[Pi u]]/.TrigRule))^Sign[n]*
- SimpGamma1[ v1 v2 Gamma[1+u]^(n-Sign[n]) Gamma[1+v]^(m-Sign[m]) ] /;
- Expand[u+v]===0 && m n > 0
-
- SimpGamma1[Times[v1___,Gamma[u_]^n_.,v2___,w_^m_.]] :=
- Module[ {p},
- SimpGamma1[v1 v2 Gamma[u+1]^(Sign[n] (p=Min[Abs[m],Abs[n]])) *
- Gamma[u]^(n-Sign[n] p) u^(n-Sign[n] p) ]
- ]/;Not[NumberQ[u]] && w===u && m n>0
-
- SimpGamma1[v_] := v
-
- SimpGamma[v__] := v
-
- SimpCond[ v_^n_ >= 1 ] := v^(-n)<=1/;Im[n]==0 &&n<0
-
- SimpCond[ v_^n_ > 1 ] := v^(-n)<1/;Im[n]==0 &&n<0
-
- SimpCond[ Abs[v_^n_ u_^m_] > 1 ] := Abs[v u] >1/;n-m==0 && Im[n]==0 &&n>0
-
- SimpCond[ Abs[v_^n_ u_^m_] > 1 ] := Abs[v/u] >1/;n+m==0 && Im[n]==0 &&n>0
-
- SimpCond[ Abs[v_^n_ u_^m_] >= 1 ] := Abs[v u]>=1/;n-m==0 && Im[n]==0 &&n>0
-
- SimpCond[ Abs[v_^n_ u_^m_] >= 1 ] := Abs[v/u]>=1/;n+m==0 && Im[n]==0 &&n>0
-
- SimpCond[ Abs[v_^n_ u_^m_] == 1 ] := Abs[v u]==1/;n-m==0 && Im[n]==0 &&n>0
-
- SimpCond[ Abs[v_^n_ u_^m_] == 1 ] := Abs[v/u]==1/;n+m==0 && Im[n]==0 &&n>0
-
- SimpCond[v_] := v
-
- CondTrig[f_,x_] := Apply[ And,Map[ TrigMon[#,x]&,Cases[f,z_]]]
-
- TrigMon[u_. Sin[c_. x_^n_.],x_] := True/;PolynomialQ[Expand[u],x]
-
- TrigMon[u_. Cos[c_. x_^n_.],x_] := True/;PolynomialQ[Expand[u],x]
-
- TrigMon[u_,x_] := True/;PolynomialQ[Expand[u],x]
-
- CollectSC[v_] :=
- Fold[ Collect[#1,#2[[2]]]&,
- v,
- Cases[Apply[Plus,
- Cases[v,Sin[_] | Cos[_],2]],a_ b_] ]
- ColTerm = {
- Sin[a_] :> Sin[Simplify[a]],
- Cos[a_] :> Cos[Simplify[a]]
- }
- CondTrigDegree[Sin[a_. x_^n_.],x_] := {n,True}/;FreeQ[a,x]
-
- CondTrigDegree[Cos[a_. x_^n_.],x_] := {n,True}/;FreeQ[a,x]
-
- CondTrigDegree[f_Plus,x_] := CondTrigDegree1[
- Cases[ Cases[f,Sin[_] | Cos[_],2],a_. x^_.,2 ],x]
-
- CondTrigDegree[f_,x_] := CondTrigDegree1[
- Cases[ Cases[f,Sin[_] | Cos[_]],a_. x^_.,2],x]
-
- CondTrigDegree1[{u_. x_^n_.},x_] := {n,True}/;FreeQ[u,x]
-
- CondTrigDegree1[{___,u_. x_^n_.,___,v_. x_^m_.,___},x_] :=
- {n,True} /; n===m && FreeQ[u,x] && FreeQ[v,x]
-
- ComMult[b_ f_,x_] := b ComMult[f,x]/;FreeQ[b,x]
-
- ComMult[f_,x_] := 1
-
- ComPlus[b_ + f_,x_] := b + ComPlus[f,x]/;FreeQ[b,x]
-
- ComPlus[f_,x_] := 0
-
- positiveList[(n_)*(v_)] := positiveList[v] /; NumberQ[n] && Positive[n]
-
- positiveList[(n_)*(v_Symbol)] := (positive[n v] = True) /;
- NumberQ[n] && Negative[n]
-
- positiveList[v_Times] := (positiveList[v[[1]]]; positiveList[Rest[v]])
-
- positiveList[v_^n_] := positiveList[v^(-n)] /;NumberQ[n]&&n<0
-
- positiveList[v_] := (positive[v] = True)
-
- SimpLog = {
- Log[Abs[a_]] :> Log[a],
- Log[a_ b_] :> Log[a] + Log[b],
- Log[a_Plus] :> Log[Together[a]],
- Log[a_Rational] :> -Log[1/a]/;Numerator[a]==1
- }
-
- SimpGfunction = {
- MeijerG[{0},{},{0},{0,1/2},{a_,z_}] :> Cos[2 Sqrt[z]]/Sqrt[Pi],
- MeijerG[{1/2},{},{1/2},{1/2,0},{a_,z_}] :>
- Sin[2 Sqrt[z]]/Sqrt[Pi]
- }
-
- TransfAnswer[v_. If[c_,t_,f_]] :=
- Apply[ If,{SimpCond[c/.arg[e_] :> Arg[e]], TransfAnswer[v t],
- If[ f===Infinity,Infinity,v f/.arg[e_] :> Arg[e]
- ] }]
-
- TransfAnswer[ v_ ] :=
- Module[ {answer = v},
- If[ !FreeQ[v,HypergeometricU],
- answer = (v/.arg[k_?Positive]:>0)//.HypergeometricURule ];
- answer = answer/.{arg[e_] :> Arg[e]};
- answer = PowerExpandMy[Expand[answer//.LogTrig]/.SimpSign//.SimpSign1];
- answer =
- If[ Not[FreeQ[v,PolyGamma]], SimpPolyGamma[answer]//.SimpTrigSum,
- answer];
- answer =
- If[ Not[FreeQ[v,Gamma]], SimpGamma[answer],answer];
- answer =
- If[ Not[FreeQ[v,Hypergeometric2F1]], answer/.SimpGaussSum,answer];
- answer =
- If[ Not[FreeQ[answer,Arg]],PowerExpand[SimpPower[answer]]//.{
- Arg[s_] :> Pi/;Znak[s],
- Arg[s_] :> 0/;Not[Znak[s]]},answer];
- If[ !FreeQ[answer,SinIntegral],
- answer = answer/.
- {SinIntegral[w_. Abs[q_]] :> Sign[q] SinIntegral[w q]}];
- answer =
- (Expand[PowerExpand[SimpPower[answer//.SimpLog]]/.LogTrig//.SimpSign1]/.{
- Sign[u_] Abs[w_]^(-1) :> 1/(w (-1)^If[w===u,0,1])/;w-u===0 || w+u===0,
- E^(w1_+ w2_) :> E^w1 E^w2})/.{
- Abs[u1_]^n_. Abs[u2_]^m_. :> If[Expand[u1+u2]===0,u1^(2 n),
- Abs[Expand[u1 u2]]^n]/;n===m};
- Clear[positive];
- If[ !FreeQ[answer,Log],answer = SimpLogFun[answer] ];
- answer =
- If[ Head[answer]===Plus && Depth[answer]<8 && Length[answer]<6 &&
- FreeQ[answer,Complex],
- Factor[answer]/.SimpSign2/.{
- Sign[u_] u_^n_. :> Abs[u] u^(n-1)/;OddQ[n] && n>0 },answer];
- If[ Not[FreeQ[answer,PolyGamma]], answer//.SimpPolyGammaSum,answer]
- ]/;FreeQ[v,HypergeometricPFQ]
-
- TransfAnswer[ v_ ] := ( Clear[positive]; v//.{
- arg[e_] :> Arg[e],
- Arg[s_] :> Pi/;Znak[s],
- Arg[s_] :> 0/;Not[Znak[s]]}//.SimpLog )
-
- SimpLogFun[ expr_Plus ] :=
- Module[ {exprN = Expand[expr],list,div,pos = {},i=0 },
- list = Union[Cases[exprN,w_. Log[n_Integer]/;FreeQ[w,Log]]/.
- w_. Log[n_] :> n];
- div = GCD@@list;
- If[ Length[list]>1 && div!=1,
- list = Complement[list,{div}];
- SimpLogFun[exprN//.BuildRule[
- Log[#]&/@list ,Log[div]+Log[#]&/@(list/div) ]],
- If[ Length[list]==1 || Length[list]==2,
- expr,
- While[Length[pos]==0 && Length[list]>1,
- i = i+ 1;
- listN = {list[[1]],#}&/@Rest[list];
- list = Rest[list];
- pos = Position[ (GCD@@#)&/@listN,a_/; a != 1 ]
- ];
- If[ Length[pos]!=0,
- list = Take[listN,pos[[1]]][[1]];
- div = GCD@@list;
- SimpLogFun[exprN//.BuildRule[Log[#]&/@list ,
- Log[div]+Log[#]&/@(list/div) ]],
- expr
- ]
- ]
- ]
- ] /; !FreeQ[expr,Log]
-
- SimpLogFun[ expr_ ] := expr
-
- BuildRule[{l_,lR___},{r_,rR___}] :=
- Join[{l :> r},BuildRule[{lR},{rR}]]
-
- BuildRule[{},{}] := {}
-
- SimpTrigSum = {
- a_. Tan[x_] + b_. Cot[x_] +c_.:> c + 2 a Csc[2 x]/;a===b,
- a_. Tanh[x_] + n_?Negative b_. Coth[x_] +c_.:> c-2 a Csch[2 x]/;
- a+b n===0&&Not[Znak[a]],
- n_?Negative a_. Tanh[x_] + b_. Coth[x_] +c_.:> c+2 a Csch[2 x]/;
- a n+b===0&&Not[Znak[b]]
- }
-
- SimpPolyGamma[ expr_ ] :=
- Module[ {exprP,listP,exprRest},
- exprP = Cases[ expr,w_/;Not[FreeQ[w,PolyGamma]] ];
- listP = Union[ exprP/.
- {a_ PolyGamma[n_,w_] :> PolyGamma[n,w]/;FreeQ[a,PolyGamma]}];
- exprP =
- Plus@@(Factor[Plus@@Cases[exprP,a_. #]]&/@listP) +
- If[ Length[exprRest = expr - Plus@@exprP] < 7,
- Factor[ exprRest ],
- exprRest ];
- exprP//.SimpPolyGammaSum/.PolyGammaRule
- ]
-