且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

没有 Sympy 的两侧限制?

更新时间:2023-11-21 12:57:16

limit 有第四个参数,dir,它指定一个方向:

>>>限制(1/x,x,0,'+')哦>>>限制(1/x,x,0,'-')-oo>>>限制(1/x,x,0)哦

默认是从右边开始.双向限制尚未直接实施,但您可以轻松检查两个方向.

I can't get Sympy to handle two-sided limits. Running in a Jupyter notebook, Anaconda installation:

from sympy import *
x = symbols('x')
limit(1/x,x,0)

gives an answer of oo. Furthermore,

Limit(1/x,x,0)

prints as a right-sided limit. In fact, all of my two-sided limits 'pretty-print' as right-sided limits. They seem to be evaluated that way, too. Can't find a way to force two-sided. Of course, one could write a short program to remedy this.

What am I doing wrong?

limit has a fourth argument, dir, which specifies a direction:

>>> limit(1/x, x, 0, '+')
oo
>>> limit(1/x, x, 0, '-')
-oo
>>> limit(1/x, x, 0)
oo

The default is from the right. Bidirectional limits are not directly implemented yet, but you can easily check both directions.