# Same ODEProblem has differente results when variable is Float64 and Vector{Float64}

Hello!

I’m having trouble with the following code. As of now it’s working fine, but if I change y0 (Float64) to y0 (Vector{Float64}) and dy to dy, it returns a wrong result.

Since it’s a simple problem I must be missing something important. Thanks in advance!

``````using DifferentialEquations

function teste_step!(dy, y, t)
b = 50
dy = (650.0 - 628.0) * (exp((300.0 - t)/b) / (b * (exp((300.0 - t)/b)+1.0)^2.0 ))
return dy
end

# y0 = zeros(1)
y0 = 628

t_span = (0, 600.0)

prob = ODEProblem(teste_step!, y0, t_span)
sol = solve(prob)

``````

I think it has something to do with the argument placement in `teste_step!` ?

This seems to give the desired result:

``````function teste_step!(dy, y, p, t)
y0, b, c, d = p
dy = (c - y0) * (exp((d - t)/b) / (b * (exp((d - t)/b)+1.0)^2.0 ))
return dy
end

y0 = [628.0]

p = [y0, 50.0, 650.0, 300.0]

t_span = (0, 600.0)

prob = ODEProblem(teste_step!, y0, t_span, p)
sol = solve(prob)
``````

I put all the important looking constants into a parameters vector (just gave them arbitrary names) and that seems to solve the problem. Maybe someone else can comment on the subtleties of including/excluding a parameters argument. It’s weird that it effects the `Vector{Float64}` case and not the `Float64` case.

1 Like

Yes, either the in-place form or out of place:

``````function teste_step(y, p, t)
b = 50
(650.0 - 628.0) * (exp((300.0 - t)/b) / (b * (exp((300.0 - t)/b)+1.0)^2.0 ))
end
y0 = 628
t_span = (0, 600.0)
prob = ODEProblem(teste_step!, y0, t_span)
sol = solve(prob)
``````

It has to be one of the two. See Ordinary Differential Equations · DifferentialEquations.jl