1.4.3 使用SymPy求极限
使用SymPy可以方便地进行极限计算。首先从SymPy中导入limit()方法。
1. from sympy import *
或者
1. from sympy import limit
SymPy中求解极限的方法为
1. limit(f,x,a)
其中,f为函数,x为自变量,a为求极限的点。如果需要求左极限或者右极限,则在后面添加“-”或“+”号。

【例1-28】 求极限。(代码:ch1函数与极限\1.4极限的计算\例1-28。)

运行结果:
4
【例1-29】 求极限。(代码:ch1函数与极限\1.4极限的计算\例1-29。)

运行结果:
0
【例1-30】 求极限。(代码:ch1函数与极限\1.4极限的计算\例1-30。)
在SymPy中使用两个重复字母“oo”表示∞。

运行结果:
-5