Comment #7 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

We can do the definite integral, albeit with a few tricks:

In [1]: integrate(exp(-x)*log(x)*x**y, (x, 0, oo), meijerg=True)
Out[1]:
⎧  ╭─╮2, 1 ⎛ -y   1, 1 │  ⎞   ╭─╮0, 3 ⎛-y, 1, 1       │  ⎞
⎪- │╶┐ ⎜ │ 1⎟ + │╶┐ ⎜ │ 1⎟ for 0 < re(y) + 1
⎪  ╰─╯3, 2 ⎝0, 0       │  ⎠   ╰─╯3, 2 ⎝          0, 0 │  ⎠
⎪
⎪                   ∞
⎨                   ⌠
⎪                   ⎮  y  -x
⎪                   ⎮ x ⋅ℯ  ⋅log(x) dx                          otherwise
⎪                   ⌡
⎪                   0
⎩

In [4]: hyperexpand(_.args[0].args[0], allow_hyper=True)
Out[4]:
2 ┌─ ⎛y + 1, y + 1 │ ⎞ 2 ┌─ ⎛y + 1, y + 1 │ ⎞ Γ(y + 1) ⋅ ├─ ⎜ │ -1⎟ Γ(-y - 1) ⋅ ├─ ⎜ │ -1⎟ 2╵ 2 ⎝y + 2, y + 2 │ ⎠ 2╵ 2 ⎝y + 2, y + 2 │ ⎠ y⋅Γ(y)⋅polygamma(0, y) + Γ(y) - ────────────────────────────────── + ─────────────────────────────────── 2 2 Γ(y + 2) Γ(-y)

In [5]: simplify(_)
Out[5]:
(y⋅polygamma(0, y) + 1)⋅Γ(y + 2)
────────────────────────────────
           y⋅(y + 1)
In [10]: expand_func(_)
Out[10]: (y⋅polygamma(0, y) + 1)⋅Γ(y)

That is hyperexpand() is not currently clever enough to do these simplifications on its own, and decides the g-functions are better than the mess at the intermediate stages. Actually this sort of cancellation happens a lot with integrals involving log(x) [since we write it as log(x)*H(x-1) + log(x)*H(1-x)], I should try to make hyperexpand clever enough...


I'm not sure how the indefinite integral is computed by mathematica. Note that my computation above is essentially the mellin transform of exp(-x)*log(x). Since it contains polygamma(0, y) we see that exp(-x)*log(x) is not a g-function, so the standard tricks don't work. Playing around with the mellin transform I can show that there exists an antiderivative of the form -[log(x)*G1(x) + G2(x)] but I have no idea how right now how to make this into an algorithm...

[I can spell out the computation if you want.]

--
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.

Reply via email to