python求解含有参量常微分方程组的解析解(笔记)

加载包

import sympy as sy

参数声明

t = sy.symbols("t")
c = sy.symbols('c')
b = sy.symbols('b')
a = sy.symbols('a')
k = sy.symbols('k')
x1 = sy.Function("x1")
x2 = sy.Function("x2")
x3 = sy.Function("x3")
x4 = sy.Function("x4")
x5 = sy.Function("x5")
x6 = sy.Function("x6")

定义方程

equation1=x1(t).diff(t,1)+2*x1(t)+2*c*x5(t)/b
equation2=x2(t).diff(t,1)-(-2*b*x2(t)+2*a*x4(t))
equation3=x3(t).diff(t,1)-(2*(k-c/b)*x3(t))
equation4=x4(t).diff(t,1)-(-(b+1)*x4(t)+c*x6(t)/b)
equation5=x5(t).diff(t,1)-(c*x3(t)/b+(k-c/b-1)*x5(t))
equation6=x6(t).diff(t,1)-(a*x5(t)+(k-c/b-b)*x6(t))

求解

#求解
print(sy.dsolve([equation1,equation2,equation3,equation4,equation5,equation6], [x1(t),x2(t),x3(t),x4(t),x5(t),x6(t)]))
sy.pprint(sy.dsolve([equation1,equation2,equation3,equation4,equation5,equation6],[x1(t),x2(t),x3(t),x4(t),x5(t),x6(t)]))

你可能感兴趣的:(笔记,python,开发语言)