Julia 微分方程.jl 说 "InexactError"

标签 julia differential-equations

这是我第一次尝试复杂的耦合颂方程:

using DifferentialEquations
using Plots

function chaos!(dx, x, p, t)
    dx[1] = 1im*((p[3] * x[1] - 2 * real(x[2])) * x[1] - 0.5) -  x[1] / 2 
    dx[2] = -1im*(0.5 * p[2] * abs(x[2])^2 + x[2]) - x[2] * p[1] / 2
end

x0 = [1, 1];
tspan = (0, 100);
p =[0.001, 1.4, -0.95]
prob = ODEProblem(chaos!, x0, tspan, p)

sol = solve(prob,Tsit5())

事情是这样的:

ERROR: InexactError: Float64(-0.5 - 3.45im)
Stacktrace:
  [1] Real
    @ .\complex.jl:44 [inlined]
  [2] convert
    @ .\number.jl:7 [inlined]
  [3] setindex!
    @ .\array.jl:903 [inlined]
  [4] chaos!(dx::Vector{Float64}, x::Vector{Float64}, p::Vector{Float64}, t::Float64)
    @ Main .\Untitled-1:5
  [5] ODEFunction
    @ C:\Users\CTCY\.julia\packages\SciMLBase\BoNUy\src\scimlfunctions.jl:345 [inlined]
.....

我不太明白它想告诉我什么。 “不精确错误”到底意味着什么?

最佳答案

初始条件需要很复杂:

x0 = ComplexF64[1, 1];

关于 Julia 微分方程.jl 说 "InexactError",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71535585/

相关文章:

python - SymPy 是否正确求解此 ODE?

微分方程的Python有限差分法

dataframe - Julia Dataframes 中的重复列

julia - 离散连续概率分布

julia - 如何在 AMD GPU 上使用 Flux.jl?

c++ - 绑定(bind)一个 odeint 变量

animation - 如何在 Julia 中绘制多个 3D 轨迹(大概使用 for 循环?)——还有,如何随着时间的推移制作动画?

tuples - 将一个大 float 插入元组 Julia 中

python - 使用欧拉方法求解微分方程组

java - 如何将函数作为 Java 中 JTextField 的输入?