I found the source of the issue. See the issue page for more details.
The fix is easy, I think, but to really be sure it is OK, we need to
test for performance regressions, which I don't have time to do right
now.
Basically, it boils down to the fact that heurisch is very sensitive
to the form of an expression. In this case, it has a hard time
recognizing -cos(pi*x) and sin(pi*(x - 1/2)) as the same thing (or the
derivative of one as the derivative of the other). I will be very glad
when the Risch algorithm is extended to work with trig functions,
because it has very nice decision procedures to rewrite expressions in
canonical ways so that it never gets confused about this sort of
thing. It will also be way faster just by the nature of the algorithm.
This sort of thing used to happen all the time with exponentials as
well. For example, look at how drastically different both the time and
the results used to be for exp(x + x*log(x)) and exp(x)*exp(x*log(x))
(which are mathematically exactly the same).
In [7]: from sympy.integrals.heurisch import heurisch
In [18]: %time heurisch(diff(exp(x)*exp(x*log(x))), x)
CPU times: user 4.52 s, sys: 66.2 ms, total: 4.59 s
Wall time: 4.55 s
Out[18]:
x x⋅log(x)
ℯ ⋅ℯ
In [19]: %time heurisch(diff(exp(x + x*log(x))), x)
CPU times: user 36.8 s, sys: 90 ms, total: 36.9 s
Wall time: 36.9 s
<no output>
In [20]: from sympy.integrals.risch import risch_integrate
In [21]: %time risch_integrate(diff(exp(x)*exp(x*log(x))), x)
CPU times: user 201 ms, sys: 38.2 ms, total: 240 ms
Wall time: 213 ms
Out[21]:
x x⋅log(x)
ℯ ⋅ℯ
In [22]: %time risch_integrate(diff(exp(x + x*log(x))), x)
CPU times: user 78 ms, sys: 16.7 ms, total: 94.7 ms
Wall time: 84.6 ms
Out[22]:
x⋅log(x) + x
ℯ
I still think getting manualintegrate to do this integral would be a
good idea too.
Aaron Meurer
On Tue, Apr 30, 2013 at 7:13 PM, Chris Smith <
smi...@gmail.com> wrote:
> I left comments about using expand successfully on the issues page [1]
>