Using SymPy's New Assumptions

杀马特。学长 韩版系。学妹 提交于 2019-12-13 19:33:21

问题


I'm having some issues with SymPy's current assumptions. Look at this thread. One of the hints said to use the assume module (reference here).

I tried doing the following computation $\lim_{x \to \infty} \frac{\ln{x}}{x^k}$. I want to evaluate this limit for $k >0$.

So I tried this:

 with assuming(k>0):
     limit((log(x))/(x**k),x,oo)

I also tried this:

eval(limit((log(x))/(x**k),x,oo),k>0)

But regardless, I get this error:

NotImplementedError: Result depends on the sign of -sign(k)

In the case of

with assume(k>0):
    limit((log(x))/(x**k),x,oo)

I get this error:

TypeError: 'module' object is not callable

Any ideas what I'm doing wrong?


回答1:


This seems to work. The first answer in the thread that you linked says that "The assumption system of SymPy is kind of a mess right now". I'm not sure if that has changed since then.

k = Symbol('k', positive=True)
print limit((log(x))/(x**k),x,oo)


来源:https://stackoverflow.com/questions/22749270/using-sympys-new-assumptions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!