实验二:py用limit求解一点或者无穷区间函数极限

本博文源于python实现高等数学基础,详细讲述了,如何用python中的sympy库求一点或无穷区间的极限。并附有多道例题可供修改,复制。可谓是收藏佳作。

数学运算 Python函数命令
lim x->a+ limit(f,x,a)
lim x->a- limit(f,x,a,dir=’-’)
lim x->a limit(f,x,a,dir=’+’)
lim x-> + ∞ +\infty + limit(f,x,oo)
lim x-> − ∞ -\infty limit(f,x,-oo)

1.求下列函数的极限

( 1 ) lim ⁡ x → 1 ( 1 x + 1 − 2 x 3 − 2 ) (1)\lim\limits_{ {x}\to{1}}(\frac{1}{x+1}-\frac{2}{x^3-2}) (1)x1lim(x+11x322)
( 2 ) lim ⁡ x → + ∞ ( 3 − 2 x + 3 ) n (2)\lim\limits_{ {x}\to{+\infty}}(\frac{3-2}{x+3})^n (2)x+lim(x+332)n

>>> from sympy import *
>>> x = symbols('x')
>>> limit(1/(x+1)-2/(x**3-2),x,1)
5/2
>>>
>>> from sympy import *
>>> x,n = symbols('x  n')
>>> print(limit(((3*x-2)/(x+3))**n,x,oo))
3**n
>>>

2.考察函数 f ( x ) = sin ⁡ x x f(x)=\frac{\sin{x}}{x} f(x)=xsinx在x->0时的变化趋势,并求极限

import matplotlib.pyplot as plt
from numpy import *

x = arange(-5*pi,5*pi,0.01)
y = sin(x)/x
plt.figure() # 打开窗口
plt.plot(x,y) # 画出图像
plt.grid(True) # 网格线开始
plt.show() # 展示show出来

在这里插入图片描述

>>> from sympy import *
>>> x = symbols('x')
>>> y = sin(x)/x
>>> print(limit(y,x,0))
1

3.考察函数 f ( x ) = ( 1 + 1 x ) x f(x)=(1+\frac{1}{x})^x f(x)=(1+x1)x在x-> ∞ \infty 时的变化趋势,并求其极限.

import matplotlib.pyplot as plt
from numpy import *
x1 = arange(-100,-2,0.01)
x2 = arange(0,100,0.01)
y1 = (1+1/x1)**x1
y2 = (1+1/x2)**x2
plt.figure()
plt.plot(x1,y1,x2,y2)
plt.grid(True)
plt.show()

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_37149062/article/details/120930093