incorrect integration of fractions

94 views
Skip to first unread message

David Schueler

unread,
May 6, 2014, 1:20:03 PM5/6/14
to sy...@googlegroups.com
It seems that sympy cannot properly break apart functions for integration.

Python 2.7.6 |Anaconda 1.9.1 (x86_64)| (default, Jan 10 2014, 11:23:15)
Type "copyright", "credits" or "license" for more information.

IPython 2.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
%guiref   -> A brief reference about the graphical user interface.

In [1]: from sympy import *

In [2]: init_session()
IPython console for SymPy 0.7.5 (Python 2.7.6-64-bit) (ground types: python)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)

Documentation can be found at http://www.sympy.org
WARNING: Hook shutdown_hook is deprecated. Use the atexit module instead.

 

In [5]: print integrate(expand((x-2)/sqrt(x)),(x,1,4))
2/3

In [6]: print integrate((x-2)/sqrt(x),(x,1,4))
-6

The former is correct based on other calculations.

Also:

print integrate(expand((x-2)/sqrt(x)),x)
2*x**(3/2)/3 - 4*sqrt(x)

print integrate((x-2)/sqrt(x),x)
2*sqrt(1 + 2/(x - 2))*(x - 2)**(7/2)/(6*x + 3*(x - 2)**2 - 12) - 4*sqrt(1 + 2/(x - 2))*(x - 2)**(5/2)/(6*x + 3*(x - 2)**2 - 12) - 16*sqrt(1 + 2/(x - 2))*(x - 2)**(3/2)/(6*x + 3*(x - 2)**2 - 12) + 8*sqrt(2)*(x - 2)**2/(6*x + 3*(x - 2)**2 - 12) + 16*sqrt(2)*(x - 2)/(6*x + 3*(x - 2)**2 - 12)

Again, the former is correct.

Thoughts?

Aaron Meurer

unread,
May 6, 2014, 6:02:57 PM5/6/14
to sy...@googlegroups.com
Is the other result incorrect, or just more complicated?

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/63e4d240-59d5-422f-b265-0b2b1895142f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ondřej Čertík

unread,
May 6, 2014, 9:08:48 PM5/6/14
to sympy
The latter is incorrect, since when you integrate you get the wrong
result (or the definite integral doesn't work).

That's a big bug, thanks for reporting it!
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6LAqdTZVa0Nn6uOR90SEnNrA_LxfOvccAjCf2p_tF1sRg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages