Status: Accepted
Owner: asmeurer
Labels: Type-Defect Priority-Medium Integration
New issue 2010 by asmeurer: Integration with the full Risch Algorithm
http://code.google.com/p/sympy/issues/detail?id=2010
I have ready in my integration3 branch a prototype risch_integrate()
function, that is a user-level function for the full Risch Algorithm I have
been implementing this summer. Pull from
http://github.com/asmeurer/sympy/tree/integration3.
This is NOT ready to go in. It is a prototype function that I am making
available so people can try out the new algorithm and hopefully help me to
find the bugs in it. Please pass it your favorite non-elementary integrals
and see if it can determine that they are not elementary. If you try to
pass it a very crazy function at random, the chances are pretty high that
it will not be elementary. So a better way to test it is to come up with a
crazy function, then differentiate it. Then pass the derivative and see if
it can give you your original function back. Note that it will probably
not look exactly the same as your original function, and may differ by a
constant. You should verify by differentiating the result you get and
calling cancel() (or simplify(), but usually cancel() is enough) on the
difference.
So you can review the code too, if you like, but just know that things are
not stable yet, and this isn't strictly a branch for review.
So far, this function only supports exponentials and logarithms.
Support for trigonometric functions is planned. Algebraic functions are
not supported. If the function returns an unevaluated Integral, it means
that it has proven the integral to be non-elementary. Note that several
cases are still not implemented, so you may get NotImplementedError
instead. Eventually, these will all be eliminated, and the only
NotImplementedError you should see from this function is
NotImplementedError("Algebraic extensions are not supported.")
This function has not been integrated in any way with the already
existing integrate() yet, and you can use it to compare.
Examples:
In [1]: risch_integrate(exp(x**2), x)
Out[1]:
⌠
⎮ ⎛ 2⎞
⎮ ⎝x ⎠
⎮ ℯ dx
⌡
In [2]: risch_integrate(x**100*exp(x), x).diff(x)
Out[2]:
100 x
x ⋅ℯ
In [3]: %timeit risch_integrate(x**100*exp(x), x).diff(x)
1 loops, best of 3: 270 ms per loop
In [4]: integrate(x**100*exp(x), x)
... hangs ...
In [5]: risch_integrate(x/log(x), x)
Out[5]:
⌠
⎮ x
⎮ ────── dx
⎮ log(x)
⌡
In [6]: risch_integrate(log(x)**10, x).diff(x)
Out[6]:
10
log (x)
In [7]: integrate(log(x)**10, x).diff(x)
Out[7]:
10
log (x)
In [8]: %timeit risch_integrate(log(x)**10, x).diff(x)
10 loops, best of 3: 159 ms per loop
In [9]: %timeit integrate(log(x)**10, x).diff(x)
1 loops, best of 3: 2.35 s per loop
Be warned that things are still very buggy and you should always verify
results by differentiating. Usually, cancel(diff(result, x) - result)
should be enough. This should go to 0.
So please, please, PLEASE, try out this function and report any bugs that
you find. It is not necessary to report NotImplementedError bugs, because
I already know about those (I put them in there), and as I mentioned above,
they are all planned to disappear. Also, I am continually updating my
branch with fixes, so you should do a "git pull" and try again before you
report anything.
Also, I am aware that there are test failures. This is because I had to
hack exp._eval_subs() to only do exact substitution (no algebraic
substitution). It's just a quick hack workaround, and I should eventually
get a real fix.
Finally, I'm thinking there needs to be a way to differentiate between an
unevaluated Integral because the integrator failed and an unevaluated
Integral because it has proven the integral to be non-elementary. Any
ideas?
--
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.