Hi,
On 13 September 2013 02:09, Aaron Meurer <[email protected]> wrote:
> Yes, the fallback algorithm in SymPy, heurisch, is very slow. What's
> the longest time an integral took that still gave an answer from your
> tests?
Example 181 can be computed, in improve-heurisch branch, as follows:
In [1]: from sympy.integrals.heurisch import heurisch, trigrewrite
In [2]: f = trigrewrite(sec(x)**2*log(cos(x)))
In [3]: %time g = heurisch(f, x, extension=None)
[heurisch] use field extension: None
CPU times: user 19.8 s, sys: 48 ms, total: 19.8 s
Wall time: 19.7 s
In [4]: trigsimp(g).rewrite(cos, tan).cancel()
Out[4]: -x + log(cos(x))⋅tan(x) + tan(x)
In [5]: simplify(g.diff(x) - f)
Out[5]: 0
This still isn't good enough, because heurisch() tries direct approach
in Q and Q(I), and both fail taking considerable amount of time. Q(I)
is very slow because coefficients are symbolic (although don't have to
be). 90%+ of time is taken by linear systems solver, so we know where
to improve.
Example 161 needs an explicit extension:
In [1]: from sympy.integrals.heurisch import heurisch, trigrewrite
In [2]: f = trigrewrite(1/(3*cos(x)**2 + 2))
In [3]: %time g = heurisch(f, x, extension=(sqrt(10), I))
CPU times: user 1.7 s, sys: 0 ns, total: 1.7 s
Wall time: 1.7 s
In [4]: g
Out[4]:
⎛ ____ ⎛x⎞ ⎞ ⎛
____ ⎛x⎞ ⎞
⎜ 2⋅╲╱ 10 ⋅ⅈ⋅tan⎜─⎟ ⎟ ⎜
2⋅╲╱ 10 ⋅ⅈ⋅tan⎜─⎟ ⎟
____ ⎜ 2⎛x⎞ ⎝2⎠ ⎟ ____ ⎜ 2⎛x⎞
⎝2⎠ ⎟
╲╱ 10 ⋅ⅈ⋅log⎜tan ⎜─⎟ - ───────────────── - 1⎟ ╲╱ 10 ⋅ⅈ⋅log⎜tan ⎜─⎟
+ ───────────────── - 1⎟
⎝ ⎝2⎠ 5 ⎠ ⎝ ⎝2⎠
5 ⎠
- ───────────────────────────────────────────── +
─────────────────────────────────────────────
20
20
In [5]: simplify(g.diff(x) - f)
Out[5]: 0
At this point I don't know how to approach example 164.
> There has been work this summer on improving the Risch algorithm in
> SymPy to handle trigonometric functions. Unfortunately, none of it is
> exposed to integrate() yet, because a certain algorithm has to be
> implemented first (let me know if you are interested in helping out).
>
> And to be fair to SymPy, one of the more advanced algorithms SymPy
> implements, the Roach Meijer G algorithm, is stronger with integrals
> involving special functions (either in the integrand or
> antiderivative), and especially definite integrals, neither of which
> appear to be represented well in the test suite.
>
> I'm also not sure that it's fair that your script calls Piecewise
> solutions messy. While it's true that they are hard to deal with in
> simplify(), they are also more correct.
>
> Can you paste tracebacks for the two integrals that raised exceptions?
> They both seem to hang for me.
>
> Aaron Meurer
>
> On Thu, Sep 12, 2013 at 1:18 PM, Peter Luschny <[email protected]>
> wrote:
>> Two integration test suites
>>
>> For some history of the two integration test suites see [1].
>> An implementation for SymPy can be found at github [2].
>> The results are listed at [3].
>>
>> Running the test suites I found some examples which seem
>> to need special attention by the developers:
>>
>> [161] Timofeev
>> integrand : 1/(3*cos(x)**2 + 2)
>> antideriv : sqrt(10)*(x - atan(3*sin(x)*cos(x)/(3*cos(x)**2 + 2 +
>> sqrt(10))))/10
>> integrator: ValueError: logarithm of a negative number
>>
>> [164] Timofeev
>> integrand : (a**2 - 4*cos(x)**2)**(3/4)*sin(2*x)
>> antideriv : (a**2 - 4*cos(x)**2)**(7/4)/7
>> integrator: RuntimeError: maximum recursion depth exceeded while calling a
>> Python object
>>
>> [181] Timofeev
>> integrand : sec(x)**2*log(cos(x))
>> antideriv : -x + log(cos(x))*tan(x) + tan(x)
>> sympy : Integral(sec(x)**2*log(cos(x)), x)
>> comment : Unevaluated!
>> time : 47 min
>>
>> [1] http://luschny.de/math/quad/IntegralTestsSage.html
>> [2] https://github.com/PeterLuschny/CharlwoodTest
>> [3] http://luschny.de/math/quad/IntegralTestsSympy.html
>>
>> Peter
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/sympy.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
Mateusz
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.