3

I'm attempting to solve the following problem:

enter image description here

Applying the following I get the correct answer.

α, t, x = symbols('α t x')
integrate(α*x*exp(-α*x), (x, 0, oo), conds='none')

To check the solution (1/α) I attempted the following.

limit(integrate(α*x*exp(-α*x), (x, 0, t), conds='none'), t, oo)

But this yields NotImplementedError: Result depends on the sign of -sign(α) as well as a further **NotImplementedError** with no description. The function works for real numbers but not oo. How can I work around this problem?

Josmoor98
  • 1,721
  • 10
  • 27
  • 1
    This seems to be a bug, because `limit(1/α, t, oo)` doesn't raise this error. – MegaIng Apr 17 '18 at 14:44
  • Also, storing the result of `limit(integrate(α*x*exp(-α*x), (x, 0, t), conds='none'), t, oo)` in variable `result` and then calling `limit(result, t, oo)` does not raise this error. – MegaIng Apr 17 '18 at 14:48
  • 1
    Actually, the Exception is correct. The error lies in giving the answer `1/α`. You can easily convince yourself by setting `α = -1`. Then the integral is `-oo`. It is supposed to work by assumption, see https://stackoverflow.com/questions/27587985/how-to-add-assumptions-in-limit-in-sympy, but it seems to be not implemented, yet. – Hennich Apr 17 '18 at 15:30
  • Couldn't manage to get `with assuming(...)` working, but posted a solution that seems to work. – Josmoor98 Apr 17 '18 at 16:00

1 Answers1

3

Adding the argument positive = True to the symbols function mitigates this issue.

α, t, x = symbols('α t x', positive = True)

func = integrate(α*x*exp(-α*x), (x, 0, t), conds='none')

(limit(func, t, oo))

Yielding 1/α

Josmoor98
  • 1,721
  • 10
  • 27