This fixes traceback for calculating integrals like a**x + b*x and also ratint(x, x). Although I'm not really sure if it is a proper fix (for me it looks more like a workaround), but you guys know better ;) You can either check from here: https://code.plaes.org/git/sympy.git/commit/?h=issue-1417 or the attachment.. Cheers, Priit :)
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@googlegroups.com To unsubscribe from this group, send email to sympy-patches+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---
>From 8bd1d50ab2092f464edfc9e5ee04fcee3623e21e Mon Sep 17 00:00:00 2001 From: Priit Laes <pl...@plaes.org> Date: Tue, 12 May 2009 22:23:35 +0300 Subject: [PATCH] Fix integrals containing sums with simple coeff*x term. Fixes bug #1417. --- sympy/integrals/rationaltools.py | 6 +++++- sympy/integrals/tests/test_integrals.py | 3 +++ sympy/integrals/tests/test_rationaltools.py | 2 ++ 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/sympy/integrals/rationaltools.py b/sympy/integrals/rationaltools.py index 97657e0..38d3965 100644 --- a/sympy/integrals/rationaltools.py +++ b/sympy/integrals/rationaltools.py @@ -1,7 +1,7 @@ """This module implements tools for integrating rational functions. """ from sympy import S, Symbol, symbols, I, log, atan, Poly, \ - div, quo, resultant, roots, collect, solve, RootSum, Lambda + div, quo, resultant, roots, collect, solve, RootSum, Lambda, Rational from sympy.polys.algorithms import poly_div, poly_gcd, \ poly_gcdex, poly_sqf, poly_subresultants @@ -26,6 +26,10 @@ def ratint(f, x, **flags): Functions, Second Edition, Springer-Verlang, 2005, pp. 35-70 """ + # Return early when f(x) = x + if f is x: + return x*x/Rational(2) + if type(f) is not tuple: p, q = f.as_numer_denom() else: diff --git a/sympy/integrals/tests/test_integrals.py b/sympy/integrals/tests/test_integrals.py index 301090c..0483f4b 100644 --- a/sympy/integrals/tests/test_integrals.py +++ b/sympy/integrals/tests/test_integrals.py @@ -339,3 +339,6 @@ def test_subs5(): def test_integration_variable(): raises(ValueError, "Integral(exp(-x**2), 3)") raises(ValueError, "Integral(exp(-x**2), (3, -oo, oo))") + +def test_issue_1417(): + assert integrate(2**x - 5*x**2, x) == 2**x/log(2) - 5*x**3/3 diff --git a/sympy/integrals/tests/test_rationaltools.py b/sympy/integrals/tests/test_rationaltools.py index e212b60..4cd53dd 100644 --- a/sympy/integrals/tests/test_rationaltools.py +++ b/sympy/integrals/tests/test_rationaltools.py @@ -50,3 +50,5 @@ def test_ratint(): x + S(1)/2*x**2 + S(1)/2*log(2-x+x**2) + (S(9)/7-4*x/7)/(2-x+x**2) + \ 13*7**(S(1)/2)*atan(-S(1)/7*7**(S(1)/2) + 2*x*7**(S(1)/2)/7)/49 + # issue #1417 + assert ratint(x, x) == x**2/2 -- 1.6.3