Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Integration in terms of exponential integrals and incomplete gamma functions Waldemar Hebisch Wrocªaw University [email protected] 13 July 2016 Introduction What is FriCAS? FriCAS is an advanced computer algebra system forked from Axiom in 2007 about 30% of mathematical code is new compared to Axiom about 200000 lines of mathematical code math code written in Spad (high level strongly typed language very similar to FriCAS interactive language) runtime system currently based on Lisp I I I I I I Some functionality added to FriCAS after fork: several improvements to integrator limits via Gruntz algorithm knows about most classical special functions guessing package package for computations in quantum probability noncommutative Groebner bases asymptotically fast arbitrary precision computation of elliptic functions and elliptic integrals new user interfaces (Emacs mode and Texmacs interface) I I I I I I I I FriCAS inherited from Axiom good (probably the best at that time) implementation of Risch algorithm (Bronstein, ...) strong for elementary integration when integral needed special functions used pattern matching Part of motivation for current work came from Rubi testsuite: Rubi showed that there is a lot of functions which are integrable in terms of relatively few special functions. Adapting Rubi looked dicult Previous work on adding special functions to Risch integrator was widely considered impractical My conclusion: Need new algorithmic approach. Ex post I claim that for considered here class of functions extension to Risch algorithm is much more powerful than pattern matching. I I I I Informally exp(u)/u Γ(a, u ) = u u exp(−u) for a = (m + k )/k and −k < m < 0. Our extension is very natural: log(x − x ) = x −1 x exp(x − x ) Ei(x − x ) = x −x Exponential integral plays the same role for integrals containing exponential function as logarithm plays for rational functions! Incomplete Gamma functions is has related role: it allows integrating functions of form x exp(x ). Ei (u )0 = u 0 0 0 0 0 / m k 0 0 0 0 0 k +m−1 k Simple examples integrate(exp(x)/x^2, x) −e x + x Ei (x ) x Needs preprocessing (Hermite reduction) to see Ei term. integrate((x-1)*exp(x)/x^2, x) e x x Similar looking, but elementary. integrate(exp(x)/(x^2 - 2), x) 2 + x e − Ei √2 + x 2 √2 e Single exponential and denominator irreducible over integers, but two Ei terms. √ Ei − √ 2 2 √ 2 x*exp(x^2)/(x^4-5) √ 5 Ei 5 5 5 √ √ √ 2 √ − + x2 e 5 − Ei + x2 20 e Similar, but relation between complex factors of denominator and Ei terms is more complicated. √ 5 integrate(((x+1)*exp(x))/log(x*exp(x)), x) li (x e ) x This shows that result may appear as logarithmic integral. integrate(((x+1)*exp(x))/(x + log(x)), x) li (x e ) x This shows that system can perform necessary simplications. integrate(exp(-x^2+2*x), x) 1 e erf (x − ) 2 D(%, x) e e− x erf term with a shift. 2 +2 x √ π −1 integrate((2*x+4)*exp(-x^2-2*x-1)/(x+1), x) √ erf (x + ) π + Ei −x 2 − x − 2 1 This shows that Ei and erf may be mixed together. 1 integrate((1 + exp(x))*exp(exp(x)^2), x) √ π er (e x ) + Ei e x 2 2 Similar, but no denominator to signal presence of Ei term. Also, we get er when appropriate. integrate(x^3*exp(-x^3), x) −Γ 1 3, Gamma plus elementary part. 3 x 3 − x e− 9 x 3 integrate((x+1)*exp(-x^3-3*x^2-3*x), x) e Γ 23 , x 3 + x 2 + x + − Gamma with a shift. 3 3 3 1 integrate(x^2*exp(-(x+1)^3), x) Γ 23 , x 3 + x 2 + x + − Γ 13 , x 3 + 3 3 1 3 x + 3 x + 1 − e 2 3 Single term in the input, two Gamma terms plus elementary part in the output. integrate(sin(x+1)/x^2, x) 2 −x 3 −3 x 2 −3 2 sin (x + 1) − 2 x sin (1) Si (x ) + x cos (1) Ci (x ) + x cos (1) Ci (−x ) 2x Si and Ci terms with shift. − integrate(x*sin(x^4), x) fresnelS can generate Fresnel integrals. 2 x2 q 2 π q 2 π integrate(exp(x + sqrt(x+1)), x) 2e 5 4 e √ x +1+x − √ π er 2 √ x +1+1 2 2e we can handle some algebraics by cheating (change of variable). 5 4 f := (2*x^4-x^3+3*x^2+2*x+2)*exp(x/(x^2+2))/(x^3+2*x) integrate(f, x) 2 x 2 + 2 x + e + Ei x2 + 2 Hard to separate elementary and Ei part. x x 2 Peek inside )trace INTEF )math integrate(sin(x^2), x) 1<enter ElementaryIntegration.lfintegrate,43 : 2 2 %i x - %i (%e ) + %i arg1= -------------------2 %i x 2%e arg2= x 1>exit ElementaryIntegration.lfintegrate,43 : +---+ | 2 fresnelS(x |--- ) \|%pi Theoretical background If K is a dierential eld, v , u ∈ K and v = u /u we say that u is exponential element and that v is logarithmic element. The set of exponential elements in K is an abelian group with respect to multiplication. The set of logarithmic elements in K is an abelian group with respect to addition. Main examples: explicit exponential is exponential element argument of logarithm is exponential element if a is an exponential element, then a is also an exponential element Example: If K = F (θ), θ is Lambert W over F , that is θ is transcendental and there exist z ∈ F such that θ = , then θ/z is an exponential element in K and −θ is corresponding logarithmic element. 0 0 I I I k 0 z 0 z θ (θ+1) Theorem If K is nitely generated dierential eld, then group of logarithmic elements modulo additive constants is a nite rank free abelian group. The same for group of exponential elements modulo multiplicative constants. In our elds we can eectively test if element is an exponential element and nd associated logarithmic element and vice versa. Gamma extensions We say that a dierential eld E is a gamma extension of F if there exists θ , . . . , θ ∈ E such that E = F (θ , . . . , θ ) and for each i , 1 ≤ i ≤ n, one of the following holds 1. θ is algebraic over F 2. = u for some u ∈ F 3. θ = for some u ∈ F 4. θ = for some u, v ∈ F such that u = v u 5. there are w , u, v ∈ F and integers k , m such that θ = wu , u = v u , w = v , −k < m < 0. where F = F (θ , . . . , θ ). 1 1 n i n i θi0 θi 0 0 u i 0 i u 0 u i v i 0 i i 0 0 i k 1 m i −i 0 0 0 i 0 Liouville principle Let f ∈ K (θ) where θ is a exponential or a primitive. Under appropriate technical assumptions, if f has integral in a Gamma extension of K (θ), then there is an algebraic extension K̄ of K such that X X v u X cv + cvwu (1) f =v + c + v v where c ∈ K are constants, u = v u , v ∈ K (θ) for i ∈ I ∪ I , u ∈ K (θ) for i ∈ I , u , w ∈ K̄ (θ), w u ∈ K (θ) for i ∈ I , w =v . 0 0 0 i i 2 ki mi ∈I1 i i i i i i i 0 i i i i i ∈I2 0 0 i i 0 i i i i i i i i i i ∈I3 2 3 3 The main case is integration of functions of form f θ where θ is an exponential. We get equation: f θ = (g θ)0 + X v0 i i ∈I2 uθ X 0 + vwuθ v ∈ i i i i i I3 i where v u θ = (u θ) . We will denote logarithm of θ as v , that is θ = v θ. Then we can write X u X vwu (2) f =g +v g + v + v We will call terms of the sum over I Ei terms and terms of the sum over I gamma terms. Formula 2 generalises Risch dierential equation (RDE). 0 i i i 0 0 0 0 0 0 i i i i i ∈I2 2 3 0 i ∈I3 i i Parametric RDE Problem: given f , u nd set of g , c such that i i f0 = g 0 + ug + X cf i i and c are constants. We assume availability of solver for parametric RDE. In generic case we need to nd nite number of candidates for possible Ei and gamma terms and use solver for parametric RDE. In few special cases we have innite number of candidate Ei or gamma terms and determine which terms actually occur during solving RDE. i The following cases may appear: regular Ei terms, depend only on denominator of f special Ei terms, depend only on structure of dierential eld innite family of Ei terms in case of v linear in logarithm regular gamma terms, depend only on structure of dierential eld innite families of gamma (erf ) terms I I I I I General setup Let ψ be top transcendental in K and M be a dierential subeld such that K is algebraic over M (ψ). By assumption we can write v = v + r ψ + a where a ∈ M and r ∈ Q 6= 0 only when ψ is a logarithm. When ψ is not an exponential let S be integral closure of M [ψ] in K . When ψ is an exponential let S be integral closure of M [ψ, ψ ]. (In general we put inverses of all special elements in S ). We can write elements of f as quotient with numerator in S and denominator in M [ψ]. When ψ is an exponential we additionally may assume that denominator is relatively prime to ψ. i i −1 i i i Notation: v , = v + rψ + a r a is norm of numerator of v . is norm of numerator of ∂ v . is norm of numerator of ∂ v . N, L P , r a r r a ψ 2 ψ , r a Ei terms Theorem If v 0 is an Ei term appearing in formula 2 and p is a prime divisor such that ord (v ) > . Then ord (E ) > . Res(N , , E ) = ui 0 0 Corollary: 0. Problem: If ψ is a logarithm we need more equations. Solution: If denominator of v is divisible by two prime divisors we combine constraints from both divisors. In transcendental case we just can use Res(N , E ) = 0 and ∂ Res(N , E ) = 0. i vi p i p r a , r a ψ , r a Ei cases Algebraic constants exp(x )/(x − 5) = e Ei(x − √5) − e Ei(x + √5) In general, if p is irreducible polynomial with constant coecients, c are roots of p, d are nonzero constants and Ei(φ) has denominator P Q D , then d Ei(φ + c ) has denominator (D + c ). In our method we get polynomial equation q(a) = 0 for possible shifts. Each irreducible factor q of q corresponds to orbit of single logarithmic element by algebraic shifts. The second highest coecient of q gives trace ã of a. Shifting arguments of q by −ã we get equation for algebraic shifts. √ 2 i 5 0 √ − 5 0 i 0 i i 0 i i i i Factors in higher powers x exp(log(x ) )/(log(x ) + 1) = Ei((log(x ) + 1) ) /(2e ) extra equation comes from condition that v is divisible by a square. Overlapped factors (x (2log(x ) + 3log(x )) + (2log(x ) + 5log(x ) + 2)) exp(log(x ) ) = log(x )(log(x ) + 1)(log(x ) + 2) (Ei((log(x ) + 1)(log(x ) + 2)) /e + Ei(log(x )(log(x ) + 1)) . Actually, no problem for our method but may confuse systems using partial fraction decomposition. 2 2 0 , r a 2 2 2 0 2 2 0 Special terms 1 exp(exp(x )/(exp(x )+1)) = Ei e + 1 e +1 When ψ is an exponential than we check if v + a can reduce to a monomial. exp(x − log(x )) = Ei (x ) When ψ is a logarithm degree at innity can drop to 0. In transcendental case this can only happen if v is a polynomial of degree 1 in ψ with integer leading coecient. In such case we can reduce integral to integral with v ∈ M . In algebraic case there are nitely many values of r which may lead to zeros at innity, we need to handle them separately. e x 0 x 0 −e Ei − x 0 Innite family exp((c + k ) log(x )) = x exp(c log(x )) Ei((c + k ) log(x )) = x log(x ) log(x ) so we get innite family of Ei terms with the same denominator. Can happen only if v is linear in ψ. We can reduce the problem to f ∈ M and then to equation k 0 f˜ = with constant c . k X c z k k −1 Completing powers To nd Gamma terms we search for r , v such that v is a power modulo multiplication by exponentials. Main idea is that exponentials have no nontrivial divisors, so that if v is divisible by a nontrivial divisor p and v is a k -th power, then k is divisible by p . To test for divisibility by power of divisors we use GCD with derivative. More precisely, if v is divisible by p than N and L have common factor, that is Res(N , L ) = 0. This works if ψ is not a logarithm. For k ≥ 3 we get second equation using second derivative. For k = 2 (that is erf terms) we need to check for presence of two zeros of multiplicity 2. In case of single zero of multiplicity 2 there is possibility for innite family ("movable zero"). , r a , r a , r a k 2 , r a , r a r , r a r exp(−x 2 − erf (x )2 ) , , 2, 4 , 0 i , so and the corresponding term is . ψ = erf (x ) va = −ψ 2 − x 2 + a ∂ψ va = − ψ Res(va , ∂ψ va ) = (a − x 2 ) Res(va , ∂ψ va ) = a = x2 2 va = −ψ erf (erf (x ))0 It may happen that there are no nontrivial zeros: f = Γ(1/3, exp(x )) = exp(− exp(x ) + x /3). We have u = exp(− exp(x )), v = − exp(x ) and w = exp(x /3). Variation: f = erf (exp(3x /2)) = exp(− exp(x ) + 3x /2). The a term is uniquely determined by condition that v + a contains only one term. Consequently the gamma term is uniquely determined and can appear only if v is a monomial or a binomial. √ √ √ π erf ( x ) = exp(−x )/ x = exp(−x − log(x )/2) Non reduced case. 0 1 0 0 1 3 1 Movable zeros There are four cases where we get innite families divisible by a square of prime divisor: v = bψ + c ψ + d is quadratic polynomial p v = bψ + c + dy where y = e ψ + f p v = bψ + c + dy where y = e ψ + f ψ + g I 2 I 2 I 2 I v= 2 bψ2 + c ψ + d ψ+e In integration context there are extra constraints and they eliminate the second family. For the three other families we show via examples that they may appear during integration. Innite families log(x ) + k ) = 2x exp(− log(x ) − 2k log(x ) − k ) = 2exp(−k )x exp(− log(x ) ). This one is due to Cherry and he also gave method to handle it. √ π erf ( −1 0 2 2k −1 2 2 2 log(plog(x )) + log(x )/2 ) = log(log(x )) 2(log(x ) + k ) log(logp(x )) − log(x ) × 2x log(x ) log(log(x )) log(log(x )) 4 k log(log(x )) + 4k log(x ) log(log(x )) + log(x ) exp = 4log(log(x )) ((log(x ) + k ) log(log(x )) − log(x )/2) log(x ) x × (x ) exp 4loglog(log − 3log(log(log(x )))/2 (x )) √ 2 π er( k 0 2 2 k 2 2 −1 k −1 In general can happen when ψ is a logarithm and v = (bψ + c ψ + d )/ψ − 3/2log(ψ). Then b is a constant. We can reduce problem to 2 Aψ + B = X v 0w u . i i i I3 This is the most complicated case. We get a quadratic relation between a and r . Depending on this relation we have further subcases: change of variables reduces problem to dierent case a is uniquely determined by r . Can use method similar to quadratic case P a is a constant. Need to solve C = d z where d are unknown constants and z and C are known can use onePcoordinate of a to parametrise solutions. Need to solve C = d z z where d are unknown constants, z and z are known and r is quadratic function of k . I I I r r r I k 2 r k 1 2 r 1 The last subcase is most tricky to solve. We use a single pole of z to get bound on k . More precisely, the problem is that there may be two values of k , k such that z (k )z have pole of the same maximal order and the constants are such that 1 1 r 2 1 ki 2 i d 1 z1 (k1 )z2 1 + d 2 z1 (k2 )z2 2 r k k r k k is of lower order. However we can look at highest order term in such combination dierence between order of linear combination and order of terms is bounded by a constant. Since orders of terms grow quadratically there is gap between orders of consecutive terms growing linearly in |k |. So for |k | large enough the can be no cancellation between highest order term of linear combination above and lower order terms. Examples were known, but there were no theory how to handle them. If y = plog(x ) − 1, φ = log(x ) + y , v = y , γ = √k − 1/k , then √ k (φ + γ) π er( √ ) = (k γ(log(x ) − 1) − k (γ log(x ) − 1)y ) × φ 2 2 0 exp((2k − 1) log(x ) + 2k γ + y )/pφ = (k γ(log(x ) − 1) − k (γ log(x ) − 1)y ) x × exp(2k γ) exp(y + log(φ)/2) so we get innite family of erf terms. The example above contains new constants γ and exp(2k γ). exp(2k γ) is a multiplicative factor so we can simply omit it. γ plays nontrivial role but taking trace with respect to γ we get example with rational coecients: k (−1 + y )x exp(y + log(φ)/2). 2 2 2k 2 −1 2 2 2k 2 −1 2 In general we have log 2 with , , 1, . Method of solving is similar to previous examples. In particular, innite family is possible only when b, d e and (f − 4eg )/e are constants and we have linear relation between r and a . v = bφ + c + dy + (φ)/ y 2 = e ψ 2 + f ψ + g φ = h(ψ + ty ) et 2 = h ∈ M 2 2 2 0 Thank you