2

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

Fabian
  • 103
  • 6

1 Answers1

3

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).

  • I like your workaround, thank you for that trick. As you wrote "not yet", are there plans to introduce a possibility to declare assumptions for limit and other operations? – Fabian Mar 18 '17 at 14:40
  • Can't speak for Sympy team (it's an open source project). If there is ever a person willing and able to rewrite the calculus submodules so that they use new assumptions.... then that will happen. But it hasn't happened since 2013, see http://stackoverflow.com/a/16435975 –  Mar 18 '17 at 16:57
  • Yes, we would like to do it. We just need people to implement it. – asmeurer Mar 18 '17 at 23:32