Different results for same model with DifferentialEquations.jl

I am defining two ODEProblems, where they are both the same but the implementation is different. There is a parameter I specify for one problem directly inside the function and for the other problem as an argument to the function.

function decay1(dx,x,t,p)
    dx[1] = -p[1]*x[1]*0.04*0.00127
end
function decay2(dx,x,t,p)
    dx[1] = -1574*x[1]*0.04*0.00127
end
prob1 = ODEProblem(decay1, [0.25], (0.,8.), [1574])
prob2 = ODEProblem(decay1, [0.25], (0.,8.))

When solving, different results are obtained:

It also does not help to specify e.g. tstops. Can anyone help?

I restarted julia and the DifferentialEquations.jl pkg and now both versions are not solved properly.

As a comparison, I solved it with MATLAB:
image

decay1(dx,x,t,p) should be
decay1(dx,x,p,t)

2 Likes

It also looks like you would want to use decay2 in prob2 if you want to do a comparison?

1 Like

2.0[1] works, which is why the code didn’t error when indexing the scalar for time. For reference, this is the corrected code with @larsm and @karajan’s corrections:

function decay1(dx,x,p,t)
    dx[1] = -p[1]*x[1]*0.04*0.00127
end
function decay2(dx,x,p,t)
    dx[1] = -1574*x[1]*0.04*0.00127
end
prob1 = ODEProblem(decay1, [0.25], (0.,8.), [1574])
prob2 = ODEProblem(decay2, [0.25], (0.,8.))