Fabian
Fabian

Reputation: 103

Sympy - Limit with parameter constraint

I try to calculate the limit of a function with a constraint on one of its parameters. Unfortunately, I got stuck with the parameter constraint.

I used the following code where 0 < alpha < 1 should be assumed

import sympy
sympy.init_printing()
K,L,alpha = sympy.symbols("K L alpha")
Y = (K**alpha)*(L**(1-alpha))
sympy.limit(sympy.assumptions.refine(Y.subs(L,1),sympy.Q.positive(1-alpha) & sympy.Q.positive(alpha)),K,0,"-")

Yet, this doesn't work. Is there any possibility to handle assumptions as in Mathematica?

Best and thank you, Fabian

Upvotes: 2

Views: 1173

Answers (1)

user6655984
user6655984

Reputation:

To my knowledge, the assumptions made by the Assumptions module are not yet understood by the rest of SymPy. But limit can understand an assumption that is imposed at the time a symbol is created:

K, L = sympy.symbols("K L")
alpha = sympy.Symbol("alpha", positive=True)
Y = (K**alpha)*(L**(1-alpha))
sympy.limit(Y.subs(L, 1), K, 0, "-")

The limit now evaluates to 0.

There isn't a way to declare a symbol to be a number between 0 and 1, but one may be able to work around this by declaring a positive symbol, say t, and letting L = t/(1+t).

Upvotes: 3

Related Questions