Hey everyone!
I want to solve f(u,p,t) = An*u + b, where:
An = [0.0+0.0im 1.0+0.0im
5.0+0.0im -1.0+0.0im],
b = [1.0+0.0im, 0.0+0.0im],
x = [0.0+0.0im, 1.0+0.0im] (initial condition)
Which means that I have a system like this:
x’ = y+1, x(0) = 0
y’ = 5x-y, y(0) = 1
And I get the following ODE: x"(t)+x’(t)-5x(t)=1. The analytic solution gives me x(1) = 3.1259897764930082
However, when I solve it via Julia’s ODE solver, I get x(1) = 4.21229.
Am I missing something? Here’s my code:
An = [0.0+0.0im 1.0+0.0im
5.0+0.0im -1.0+0.0im]
b = [1.0+0.0im, 0.0+0.0im]
x = [0.0+0.0im, 1.0+0.0im]
tspan = (0.0,1.0)
f(u,p,t) = An*u + b;
prob = ODEProblem(f, x, tspan)
sol = solve(prob, Vern7(), dt = 0.1, adaptive = false, reltol=1e-8)
Another thing even though unrelated to your original problem: Setting adaptive = false, should basically invalidate your reltol = 1e-8 option, since the ODE solver is only allowed to go in steps of 0.1 without adjusting the stepsize due to error. It should always be safer to use the default, which is adaptive = true.
Thanks!
I’m using complex numbers only because the other parts of my code require complex inputs.
Also, yes - I’m mainly focusing on stable systems to get lower errors (which is not this case though).