forked from sympy/sympy
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement prototype risch_integrate() function for the Risch Algorithm
This is a user-level function which allows you to play around with the new algorithm. Changes here include adding a build_extension() function, which builds up the transcendental tower of differential extensions necessary to integrate. Also includes some fixes to is_log_deriv_k() and is_log_deriv_k_t_radical() to handle constant terms, and a bug fix in residue_reduce(). 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.
- Loading branch information
Showing
6 changed files
with
473 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
-cos(x) | ||
""" | ||
from integrals import integrate, Integral, line_integrate | ||
from risch import risch_integrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.