Trouble with integral of ln(x-y)

149 views
Skip to first unread message

Filip

unread,
Oct 22, 2015, 10:24:33 AM10/22/15
to sympy
I'm trying to calculate the integral of ln(x-y) dy (with x and y complex)
>> integrate(ln(x-y), y)
but sympy gives me 
    -x*log(-x + y) + y*log(x - y) - y
If I try to differentiate this wrt. y I get
>> diff(-x*log(-x + y) + y*log(x - y) - y, y)
    -x/(-x + y) - y/(x - y) + log(x - y) - 1
which is not exactly equal to ln(x-y).
As far as I know the result of the integration should be -ln(x - y)*(x - y) + x - y, which also gives the correct result when differentiated in sympy
>> diff(-ln(x-y)*(x-y)+x-y, y)
    log(x - y)

The calculations can be seen as a IPython Notebook here

Aaron Meurer

unread,
Oct 22, 2015, 11:38:00 AM10/22/15
to sy...@googlegroups.com
On Thu, Oct 22, 2015 at 2:45 AM, Filip <filip...@gmail.com> wrote:
> I'm trying to calculate the integral of ln(x-y) dy (with x and y complex)
>>> integrate(ln(x-y), y)
> but sympy gives me
> -x*log(-x + y) + y*log(x - y) - y
> If I try to differentiate this wrt. y I get
>>> diff(-x*log(-x + y) + y*log(x - y) - y, y)
> -x/(-x + y) - y/(x - y) + log(x - y) - 1

If you call simplify() on this you get log(x - y)

> which is not exactly equal to ln(x-y).
> As far as I know the result of the integration should be -ln(x - y)*(x - y)
> + x - y, which also gives the correct result when differentiated in sympy

Remember that integrals can differ by a constant. In this case, the
argument of one of the logs is negated from what you expect, but this
amounts to a complex constant.

Aaron Meurer

>>> diff(-ln(x-y)*(x-y)+x-y, y)
> log(x - y)
>
> The calculations can be seen as a IPython Notebook here
> http://nbviewer.ipython.org/gist/FSund/2a49222b54fa95ccdbc0
>
> --
> 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/67936dfa-3e04-4766-9c18-da3a49944115%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages