简体   繁体   中英

python solving differential equation with complex variables

folks,

Is it possible to solve ODE with complex variable in python? The equation I have has the following form

dx/dt = -a x -i y(t)

where y(t) is a known function, a is a known number and i is the root of -1.

I tried to use odeint() but it gives many error messages.

I am guessing odeint() does not work with complex variables. So one way out would be to separate the real and imaginary parts of x and treat the original ODE as two coupled ODEs.

But I am also wondering if there are some more convenient way for this task? Solving ODE/PDE with complex variables is a general problem and it will be quite a hassle to make this complex -> real conversion by hand all the time.

Thanks very much.

我建议使用scipy.integrate.complex_ode而不是scipy.integrate.odeint自动执行转换

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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