DifferentialEquations.jl - solve not defined


I am relatively new to Julia, have been trying to solve a system of differential equations using Julia, but it always returns the error ’
LoadError: UndefVarError: solve not defined’. I am not able to figure out why. Could anyone please help me. I have included a simple example code here.

using DifferentialEquations
U₀ₙₑₔ = 0.1635
dₚ = 100e-6
a = 315*(dₚ^0.64/U₀ₙₑₔ)
f(z,c) = a*c
cₛ₀ = 0.5
tspan = (0.6,1.2)
prob = ODEProblem(f,cₛ₀,tspan)
sol = solve(prob,Tsit5(),reltol=1e-8,abstol=1e-8)

What does Pkg.status("DifferentialEquations"); Pkg.status("OrdinaryDiffEq") say?


  • DifferentialEquations 3.0.2


  • OrdinaryDiffEq 2.26.0

Initially, when I first tried this in the older version of julia, I got the same error, so I tried updating to latest version, but still I get the same error everytime.

Weird. You’re on the latest versions of the packages. Did it not say anything during precompile or build stages? No error messages at all?

Replace using DifferentialEquations with using OrdinaryDiffEq and see if it works.

It gives me the same error, with OrdinaryDiffEq

LoadError: UndefVarError: solve not defined
while loading untitled-217b70b82c9a0ba6d911c4b161998771, in expression starting on line 9
include_string(::String, ::String) at loading.jl:522
include_string(::Module, ::String, ::String) at Compat.jl:174
(::Atom.##57#60{String,String})() at eval.jl:74
withpath(::Atom.##57#60{String,String}, ::Void) at utils.jl:30
withpath(::Function, ::String) at eval.jl:38
macro expansion at eval.jl:72 [inlined]
(::Atom.##56#59{Dict{String,Any}})() at task.jl:80

And there are no other errors or warnings? If so, bizarre. Try prefacing it with the package name:

sol = OrdinaryDiffEq.solve(prob,Tsit5(),reltol=1e-8,abstol=1e-8)

What does Pkg.status("DiffEqBase") say?

  • DiffEqBase 2.6.1
    There are no other errors or warnings, just that solve is not defined

And, it worked, when prefaced with the package name.
sol = OrdinaryDiffEq.solve(prob,Tsit5(),reltol=1e-8,abstol=1e-8)

Thank you so much.

But what could be the issue, why didn’t it work with the usual procedure? I’m wondering because I frequently update the packages and have no idea what could have possibly gone wrong

You have some other package exporting solve, and it will throw a warning when using DifferentialEquations or using OrdinaryDiffEq is done. That warning will tell you what other package is using without extending solve.

1 Like

Okay, Thank you.

But, I didn’t get any warning, just the error

Is this a standard Julia installation?

Yes, of course!

Well then I’m baffled as to why you don’t get a warning that tells you what other package is exporting solve, but at least I could identify the issue :slight_smile:

Please try to simplify what you’re doing as much as possible and post everything from the REPL in a gist (gist.github.com). It seems very weird that you’re not getting a warning as Chris mentions.

1 Like

Maybe he got the warning way back when he started the session, and all of this is done in a “old” session?


Indeed. Maybe I should have emphasized that I meant “everything!!!” when I said “everything” :slight_smile: Let’s see the splash screen! :slight_smile:

1 Like

Sorry, it was my mistake.

@yakir12 was right. To check that, I restarted Julia and solved one of my files using solve and then when I came back and tried to solve this again, it gave me a warning:

WARNING: using JuMP.solve in module Main conflicts with an existing identifier.

I guess, it might have displayed the warning way back and I kept running different modules, didn’t notice the warning in the old session.

@ChrisRackauckas Thank you :slight_smile:

1 Like

You can mark the answer as a solution, that way this topic will be marked as solved :slight_smile:

1 Like