The integrate function when used without limits finds an
antiderivative. In general antiderivatives are not unique and can
differ by a constant which I think is the case here. The
simplifications below won't work though unless the symbols are
declared positive:

In [44]: a, b, x = symbols('a b x', positive=True)

In [45]: f = x / sqrt(a*x + b)

In [46]: integral = integrate(f, x)

In [47]: simplify(integral.diff(x) - f)
Out[47]: 0

In [48]: expected = 2 * sqrt(a*x + b) * (a*x - 2*b) / (3*a**2)

In [49]: simplify(integral - expected)
Out[49]:
   3/2
4⋅b
──────
    2
 3⋅a


The integral result from sympy does seem unnecessarily complicated in
this example though. You can get a more natural form by using
manualintegrate:

In [55]: integral = integrate(f, x, manual=True)

In [56]: factor(integral)
Out[56]:
                _________
2⋅(a⋅x - 2⋅b)⋅╲╱ a⋅x + b
─────────────────────────
              2
           3⋅a

That's the result you expected and that's because it is also
(probably) calculated using integration by parts.

--
Oscar

On Mon, 13 Jan 2020 at 11:33, Gösta Ljungdahl <[email protected]> wrote:
>
> Apparently there is some error in the integrate algorithm.
>
> Consider the following integral:
>
> int(x/sqrt(ax+b)) which is 2*sqrt(ax+b)*(ax-2b)/(3a**2) as is easily 
> confirmed doing integration by parts. Many integral tables (not all) has this 
> integral correctly listed.
>
> sympy 1.4 gives me this:
>
> code (ipython 7.5.0):
> In [1]: from sympy import *
>
> In [2]: a,b,x=symbols('a b x')
>
> In [6]: f=x/sqrt(a*x+b)
>
> In [7]: int=integrate(f,x)
>
> In [8]: factor(int)
> Out[8]: 2*sqrt(b)*(a*x*sqrt(a*x/b + 1) - 2*b*sqrt(a*x/b + 1) + 2*b)/(3*a**2)
>
> where clearly the last term shouldn't be there.
>
> Hope this can help improving the integrate algorithm.
>
> --
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/b9fe9ccf-68cb-4720-a5a3-e36dfdbc620e%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxQP_0U3st2S8NVH3FFdq8xNGPR%3DrSBzMLRqRnNqYL%2BJ8Q%40mail.gmail.com.

Reply via email to