首先在win系统下可以直接用

pip insert scipy

但在 Linux的系统下用

sudo apt-get install python-scipy

安装之后下面就是简单的介绍


#求解非线性方程组2x1-x2^2=1,x1^2-x2=2
from scipy.optimize import fsolve #导入求解方程组的函数
def f(x): #定义要求解的方程组
x1=x[0]
x2=x[1]
return [2*x1-x2**2-1,x1**2- x2 -2]
result=fsolve(f,[1,1])#输入初始值[1,1]并求解
print(result)

#数值积分
from scipy import integrate #导入积分函数
def g(x): #定义被积函数
return (1-x**2)**0.5
pi_2,err=integrate.quad(g,-1,1)#积分结果和误差
print(pi_2*2)

 

相关文章:

  • 2021-11-04
  • 2021-12-19
  • 2021-07-01
  • 2022-12-23
  • 2021-12-19
  • 2021-11-10
  • 2021-06-23
  • 2021-11-28
猜你喜欢
  • 2021-11-15
  • 2021-11-10
  • 2022-12-23
  • 2023-02-21
  • 2022-12-23
  • 2021-08-20
  • 2021-11-22
相关资源
相似解决方案