-
不定积分原函数求法
#不定积分原函数 from sympy import * x = symbols('x')#symbols()函数用于初始化多个变量 y = cos(x)/((sin(x)*(1+sin(x))**2)) jf = integrate(y,x) jf = simplify(jf) print("原函数为:",jf)
原函数为: (-log(sin(x) + 1)*sin(x) - log(sin(x) + 1) + log(sin(x))*sin(x) + log(sin(x)) + 1)/(sin(x) + 1)
#不定积分原函数 from sympy import * x = symbols('x')#symbols()函数用于初始化多个变量 f = sqrt(4-x**2) jf = integrate(f,x) jf = simplify(jf) print("原函数为:",jf)
原函数为: x*sqrt(-x**2 + 4)/2 + 2*asin(x/2)
-
求定积分
#求定积分 from sympy import * x = symbols('x')#symbols()函数用于初始化多个变量 f = x**2*sin(x) jf = integrate(f,(x,0,pi/2)) #jf = simplify(jf) print("定积分为:",jf)
定积分为: -2 + pi
#求广义积分 from sympy import * x = symbols('x')#symbols()函数用于初始化多个变量 f = x*exp(-x) jf = integrate(f,(x,0,oo)) #jf = simplify(jf) print("广义积分为:",jf)
广义积分为: 1
-
求封闭区间的面积
-
#计算曲线与直线围成的图形面积 import matplotlib.pyplot as plt from numpy import * x = arange(-2,3,0.01) y1 = 8-x**2 y2 = x+1 plt.figure() plt.plot(x,y1,x,y2,[-1,-1],[-2,8],[2,2],[-2,8]) plt.show()
-
#求面积 from sympy import * x = symbols('x')#symbols()函数用于初始化多个变量 f = 8-x**2 g = x+1 jf = integrate(f-g,(x,-1,2)) #jf = simplify(jf) print("封闭面积为:",jf)
封闭面积为: 33/2