Comment #12 on issue 1893 by [email protected]: integrate(log(x) *
x**(k-1) * exp(-x) / gamma(k), (x, 0, oo)) hangs
http://code.google.com/p/sympy/issues/detail?id=1893
Hm. Combsimp is definitely not idempotent (should it be?):
[I fear this is not going to be very readable...]
In [1]: a = Symbol('a', positive=True)
In [2]: integrate(exp(-x)*log(x)*x**a, (x, 0, oo), meijerg=True)
Out[2]:
2 ┌─ ⎛a + 1, a + 1 │
⎞ 2 ┌─ ⎛a + 1, a + 1 │ ⎞
Γ(a + 1) ⋅ ├─ ⎜ │ -1⎟ Γ(-a -
1) ⋅ ├─ ⎜ │ -1⎟
2╵ 2 ⎝a + 2, a + 2 │
⎠ 2╵ 2 ⎝a + 2, a + 2 │ ⎠
a⋅Γ(a)⋅polygamma(0, a) + Γ(a) - ────────────────────────────────── +
───────────────────────────────────
2 2
Γ(a +
2) Γ(-a)
In [3]: expr=_
In [4]: together(cancel(powsimp(expr)).expand())
Out[4]:
2 2 2 2
2 2 ┌─ ⎛a + 1, a + 1 │ ⎞ 2 2 ┌─ ⎛a + 1, a
+ 1 │ ⎞
a⋅Γ(-a) ⋅Γ(a)⋅Γ(a + 2) ⋅polygamma(0, a) + Γ(-a) ⋅Γ(a)⋅Γ(a + 2) - Γ(-a)
⋅Γ(a + 1) ⋅ ├─ ⎜ │ -1⎟ + Γ(-a - 1) ⋅Γ(a + 2) ⋅ ├─
⎜ │ -1⎟
2╵
2 ⎝a + 2, a + 2 │ ⎠ 2╵ 2 ⎝a + 2, a + 2 │ ⎠
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
2 2
Γ(-a)
⋅Γ(a + 2)
In [5]: expand_func(_)
Out[5]:
2
2 2 2 ┌─ ⎛a + 1, a + 1 │ ⎞
a
⋅(a + 1) ⋅Γ(-a) ⋅Γ(a) ⋅ ├─ ⎜ │ -1⎟
3 2 2 3 2 2 2 3
2 2 2 ┌─ ⎛a + 1, a + 1 │ ⎞ 2╵ 2 ⎝a
+ 2, a + 2 │ ⎠
a ⋅(a + 1) ⋅Γ(-a) ⋅Γ(a) ⋅polygamma(0, a) + a ⋅(a + 1) ⋅Γ(-a) ⋅Γ(a) - a
⋅Γ(-a) ⋅Γ(a) ⋅ ├─ ⎜ │ -1⎟ +
─────────────────────────────────────────────────
2╵
2 ⎝a + 2, a + 2 │ ⎠ 2
(-a
- 1)
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
2 2 2 2
a ⋅(a
+ 1) ⋅Γ(-a) ⋅Γ(a)
In [6]: combsimp(_4)
Out[6]:
(a⋅polygamma(0, a) + 1)⋅Γ(a + 2)
────────────────────────────────
a⋅(a + 1)
In [7]: combsimp(_)
Out[7]: (a⋅polygamma(0, a) + 1)⋅Γ(a)
In [8]: factor(_5)
Out[8]: (a⋅polygamma(0, a) + 1)⋅Γ(a)
The first line simulates simplify(). Combsimp calls factor in the end, and
this is where the hyper cancels. So really what happens is
1) "simplify" via together(cancel(...))
2) expand all the gamma functions (in combsimp)
3) mess around with the products separately (i.e. put the factors back into
the gammas)
4) factor the expression. now the hyper cancels
This is why the gamma(a + 2) in the end result is not expanded: because
combsimp considers the various products in numerator and denominator
separately. Perhaps should we could call expand_mul first ...
Does this seem important?
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.