Davide_sd
Davide_sd

Reputation: 13150

sympy - parametric limit

Say I would like to solve a parametric limit: in the following example, alpha > 0 is the parameter.

import sympy as sp
x = sp.symbols("x", real=True)
alpha = sp.symbols("alpha", real=True, positive=True, nonzero=True)
expr = (x * sp.exp(x) - sp.exp(2 * sp.sqrt(1 + x**2))) / (sp.exp(alpha * x) + x** alpha)
sp.limit(expr, x, sp.oo)

If I execute the code I get the result -oo, which is arguably incorrect.

If I were to compute this limit by hand I would look at the numerator and conclude that exp(2 * sp.sqrt(1 + x**2)) is of the same order of exp(2*x), which dominates x * exp(x). Similarly, looking at the denominator I would say that exp(alpha * x) dominates the term x**alpha.

Therefore, I can compute the limit of the function -exp((2 - alpha) * x). The correct result would be:

-oo for 0 < alpha < 2
-1 for alpha = 2
0 for alpha > 2

Is there an easy way to achieve this result with sympy?

Upvotes: 0

Views: 105

Answers (1)

asmeurer
asmeurer

Reputation: 91480

This should be considered a bug in SymPy. I would suggest opening an issue about it https://github.com/sympy/sympy/issues.

Regarding what you are asking for in general, it isn't implemented yet. See https://github.com/sympy/sympy/issues/13312.

Upvotes: 1

Related Questions