python做微积分

sympy官方文档地址:https://docs.sympy.org/latest/index.html

python的科学计算包十分强大我之前就有所感受,今天又一次把我震惊了,python竟然还能做微积分

首先安装第三方包

pip3 install sympy

直接上代码
from sympy import *
#定义变量
x = symbols('x')
#微分
diff(x**2,x)
Out[4]: 2*x
#微分
diff(sin(x),x)
Out[5]: cos(x)
#微分
diff(cos(x),x)
Out[6]: -sin(x)
#积分
integrate(2*x,(x,0,1))
Out[7]: 1
#积分
integrate(2*x,x)
Out[8]: x**2
原文地址:https://www.cnblogs.com/wangbin2188/p/15466623.html