Results for integrate(Rational(1,4)*(1/(4-t)))

35 views
Skip to first unread message

Raphael Timbó

unread,
Sep 18, 2016, 2:18:31 PM9/18/16
to sympy
Hi,
I was trying to use:
integrate(Rational(1,4)*(1/(4-t)))

This was returning:
14log(4t16)

I was not expecting this result... I went to sympy gamma to see the steps and I saw that:

  • integrate(1/(4*(-t + 4)), t)
    14log(4t16)

But when you check the steps you have:

The answer is:

14log(t+4)+constant





I could not understand why the results are different...
Any explanation?

Thank you!

Raphael Timbó

unread,
Sep 18, 2016, 10:06:22 PM9/18/16
to sympy
Since the images with the results are distorted:

First result:

-(1/4)*log(4*t - 16)

Results given by the step-by=step solution on sympy gamma:

-(1/4)*log(-t + 4)

Aaron Meurer

unread,
Sep 18, 2016, 11:29:01 PM9/18/16
to sy...@googlegroups.com
A multiplication of a constant inside a log is the same as adding a constant to the log (log(a*b) = log(a) + log(b)). So both are valid integrals, because of the constant of integration. You can check yourself that both give the original expression if you differentiate them.

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+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/c70c7c01-296d-4998-bb0e-04f324ad64fc%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Kalevi Suominen

unread,
Sep 19, 2016, 2:43:55 AM9/19/16
to sympy

There are several integrators in SymPy. The latter form is produced by ratint.

>>> from sympy.integrals.rationaltools import ratint
>>> from sympy.abc import t
>>> ratint(1/(4*(-t + 4)), t)
-log(t - 4)/4

Kalevi Suominen

Aaron Meurer

unread,
Sep 19, 2016, 11:43:19 AM9/19/16
to sy...@googlegroups.com
See https://github.com/sympy/sympy/issues/11017. It would be nice if we could fix ratint to not flip signs in the logarithm. 

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+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.

Aaron Meurer

unread,
Sep 19, 2016, 11:44:24 AM9/19/16
to sy...@googlegroups.com
With that being said, either answer is wrong if you want a real function. For that, you need log(abs(4 - t)). But unfortunately, the abs() answer isn't valid in the general complex case, which is why SymPy doesn't return it. 

Aaron Meurer

Raphael Timbó

unread,
Sep 19, 2016, 4:18:19 PM9/19/16
to sympy
Thank you very much!
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 https://groups.google.com/group/sympy.
Reply all
Reply to author
Forward
0 new messages