简体   繁体   English

带有 Sympy 的 4 个方程组

[英]System of 4 equations with Sympy

I am trying to solve a system of 4 equations with four unknows with non define constatnt, but when I run my program in Spyder the consol display ''solution'' without giving the solution.我正在尝试用非定义常量求解具有四个未知数的 4 个方程组,但是当我在 Spyder 中运行我的程序时,consol 显示“解决方案”而没有给出解决方案。 this is what I have这就是我所拥有的

In[54]: runfile('E:/Spyder/eigen_functions.py', wdir='E:/Spyder') Solution: [] In[54]: runfile('E:/Spyder/eigen_functions.py', wdir='E:/Spyder') 解决方法:[]

Here is my code and I was expecting to have the value of k1, k2, k3 and k4 as function of the other parameters.这是我的代码,我期望将 k1、k2、k3 和 k4 的值作为其他参数的 function。

from sympy.solvers import solve

from sympy import symbols, Eq

from sympy import exp

k1, k2, k3, k4, x, a, b, d, h, l,t = symbols(" k1 k2 k3 k4 x a b d h l t ") 
equation_1 = Eq((k1*exp(-a*t*1j) + k2*exp(-b*t*1j)+ k3*exp(a*t*1j) + k4*exp(b*t*1j)) ,1)

equation_2 = Eq(((1/(2*l*h*(x+1)))*(-k1*((x**2)-1-2*(a*x)+(d**2)+(l**2)+a**2)*exp(-a*t*1j) -k2*((x**2)-1-2*(b*x)+(d**2)+(l**2)+b**2)*exp(-b*t*1j) -k3*((x**2)-1+2*(a*x)+(d**2)+(l**2)+a**2)*exp(a*t*1j) -k4*((x**2)-1+2*(b*x)+(d**2)+(l**2)+b**2)*exp(b*t*1j))) , 0)

equation_3 = Eq(((1/(2*d*h*l*h*(x+1)))*(-k1*((l**2)*(x+1+a)-(d**2)*(x+1-a)-(x**3)-(x**2)+x+1-a*((x**2)+1+2*x)-(a**2)*(x-1)-a**3)*exp(-a*t*1j) -k2*((l**2)*(x+1+b)-(d**2)*(x+1-b)-(x**3)-(x**2)+x+1-b*((x**2)+1+2*x)-(b**2)*(x-1)-b**3)*exp(-b*t*1j) -k3*((l**2)*(x+1-a)-(d**2)*(x+1+a)-(x**3)-(x**2)+x+1+a*((x**2)+1+2*x)-(a**2)*(x-1)+a**3)*exp(a*t*1j) -k4*((l**2)*(x+1-b)-(d**2)*(x+1+b)-(x**3)-(x**2)+x+1+b*((x**2)+1+2*x)-(b**2)*(x-1)+b**3)*exp(b*t*1j))) ,0)

equation_4 = Eq(((1/(2*d*h*(x+1)))*(-k1*(((d**2)+(l**2)-(a**2)-(x**2)+1+2*a*x))*exp(-a*t*1j) -k2*(((d**2)+(l**2)-(b**2)-(x**2)+1+2*b*x))*exp(-b*t*1j) -k3*(((d**2)+(l**2)-(a**2)-(x**2)+1-2*a*x))*exp(a*t*1j) -k4*(((d**2)+(l**2)-(b**2)-(x**2)+1-2*b*x))*exp(b*t*1j))) , 0)

solution = solve((equation_1, equation_2, equation_3, equation_4), (k1, k2, k3, k4))

print("Solution:", solution)

Here is my code and I was expecting to have the value of k1, k2, k3 and k4 as function of the other parameters.这是我的代码,我期望将 k1、k2、k3 和 k4 的值作为其他参数的 function。

The determinant of the system is 0 so there is not a unique solution.系统的行列式为 0,因此不存在唯一解。

>>> eqs = [equation_1,equation_2,equation_3,equation_4]
>>> Matrix([i.rewrite(Add) for i in eqs]).jacobian(var("k1:5")).det()
0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM