# DifferentialEquations inexact error

**URL:** <https://discourse.julialang.org/t/differentialequations-inexact-error/31208>\
**Category:** New to Julia\
**Tags:** diffeq\
**Created:** [November 18, 2019, 3:02am UTC](https://discourse.julialang.org/t/differentialequations-inexact-error/31208 "2019-11-18T03:02:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FrankBerninger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frankberninger/32/21086_2.png) [@FrankBerninger](https://discourse.julialang.org/u/FrankBerninger)\
**Post date:** [November 18, 2019, 3:02am UTC](https://discourse.julialang.org/t/differentialequations-inexact-error/31208/1 "2019-11-18T03:02:32Z")

</div>

Hello  
I am trying to learn the Differential Equations and I end up with a stupid newbie mistake can anybody help me:

function Diffusive(du,u,p,t)  
du = p\*(100.0-u)  
end  
u0=0.1  
tspan=(0, 10)  
p=0.2  
prob2 =ODEProblem(Diffusive,u0,tspan,p)  
solve(prob2)

Error message after last line:  
)  
ERROR: InexactError: Int64(161//1000)  
Stacktrace:  
[1] Type at ./rational.jl:87 [inlined]  
[2] convert(::Type{Int64}, ::Rational{Int64}) at ./number.jl:7  
[3] OrdinaryDiffEq.Tsit5ConstantCache(::Type, ::Type) at /home/franb/.julia/packages/OrdinaryDiffEq/rdNK0/src/tableaus/low\_order\_rk\_tableaus.jl:604  
[4] alg\_cache(::Tsit5, ::Float64, ::Float64, ::Type, ::Type, ::Type, ::Float64, ::Float64, ::ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}, ::Int64, ::Int64, ::Float64, ::Float64, ::Bool, ::Val{true}) at /home/franb/.julia/packages/OrdinaryDiffEq/rdNK0/src/caches/low\_order\_rk\_caches.jl:348  
[5] (::getfield(OrdinaryDiffEq, Symbol(“##193#194”)){Float64,Float64,DataType,DataType,DataType,Float64,Float64,ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Int64,Int64,Float64,Float64,Bool})(::Tsit5) at /home/franb/.julia/packages/OrdinaryDiffEq/rdNK0/src/caches/basic\_caches.jl:22  
[6] map(::getfield(OrdinaryDiffEq, Symbol(“##193#194”)){Float64,Float64,DataType,DataType,DataType,Float64,Float64,ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Int64,Int64,Float64,Float64,Bool}, ::Tuple{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType}}) at ./tuple.jl:140  
[7] alg\_cache(::CompositeAlgorithm{Tuple{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType}},AutoSwitch{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType},Rational{Int64},Int64}}, ::Float64, ::Float64, ::Type, ::Type, ::Type, ::Float64, ::Float64, ::ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}, ::Int64, ::Int64, ::Float64, ::Float64, ::Bool, ::Val{true}) at /home/franb/.julia/packages/OrdinaryDiffEq/rdNK0/src/caches/basic\_caches.jl:21  
[8] #\_\_init#329(::Array{Int64,1}, ::Array{Int64,1}, ::Array{Int64,1}, ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::Nothing, ::Bool, ::Bool, ::Int64, ::Int64, ::Int64, ::Bool, ::Bool, ::Rational{Int64}, ::Nothing, ::Nothing, ::Rational{Int64}, ::Int64, ::Int64, ::Int64, ::Rational{Int64}, ::Bool, ::Int64, ::Nothing, ::Nothing, ::Int64, ::typeof(DiffEqBase.ODE\_DEFAULT\_NORM), ::typeof(LinearAlgebra.opnorm), ::typeof(DiffEqBase.ODE\_DEFAULT\_ISOUTOFDOMAIN), ::typeof(DiffEqBase.ODE\_DEFAULT\_UNSTABLE\_CHECK), ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::String, ::typeof(DiffEqBase.ODE\_DEFAULT\_PROG\_MESSAGE), ::Nothing, ::Bool, ::Bool, ::Bool, ::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:default\_set,),Tuple{Bool}}}, ::typeof(DiffEqBase.\_\_init), ::ODEProblem{Float64,Tuple{Int64,Int64},true,Float64,ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem}, ::CompositeAlgorithm{Tuple{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType}},AutoSwitch{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType},Rational{Int64},Int64}}, ::Array{Float64,1}, ::Array{Int64,1}, ::Array{Any,1}, ::Type{Val{true}}) at /home/franb/.julia/packages/OrdinaryDiffEq/rdNK0/src/solve.jl:255  
[9] (::getfield(DiffEqBase, Symbol(“#kw##\_\_init”)))(::NamedTuple{(:default\_set,),Tuple{Bool}}, ::typeof(DiffEqBase.\_\_init), ::ODEProblem{Float64,Tuple{Int64,Int64},true,Float64,ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem}, ::CompositeAlgorithm{Tuple{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType}},AutoSwitch{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType},Rational{Int64},Int64}}, ::Array{Float64,1}, ::Array{Int64,1}, ::Array{Any,1}, ::Type{Val{true}}) at ./none:0 (repeats 5 times)  
[10] #\_\_solve#328(::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:default\_set,),Tuple{Bool}}}, ::typeof(DiffEqBase.\_\_solve), ::ODEProblem{Float64,Tuple{Int64,Int64},true,Float64,ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem}, ::CompositeAlgorithm{Tuple{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType}},AutoSwitch{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType},Rational{Int64},Int64}}) at /home/franb/.julia/packages/OrdinaryDiffEq/rdNK0/src/solve.jl:4  
[11] (::getfield(DiffEqBase, Symbol(“#kw##\_\_solve”)))(::NamedTuple{(:default\_set,),Tuple{Bool}}, ::typeof(DiffEqBase.\_\_solve), ::ODEProblem{Float64,Tuple{Int64,Int64},true,Float64,ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem}, ::CompositeAlgorithm{Tuple{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType}},AutoSwitch{Tsit5,Rosenbrock23{0,false,DefaultLinSolve,DataType},Rational{Int64},Int64}}) at ./none:0  
[12] #\_\_solve#2(::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.\_\_solve), ::ODEProblem{Float64,Tuple{Int64,Int64},true,Float64,ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem}, ::Nothing) at /home/franb/.julia/packages/DifferentialEquations/2PnT0/src/default\_solve.jl:15  
[13] #\_\_solve at ./none:0 [inlined]  
[14] #\_\_solve#1 at /home/franb/.julia/packages/DifferentialEquations/2PnT0/src/default\_solve.jl:5 [inlined]  
[15] \_\_solve at /home/franb/.julia/packages/DifferentialEquations/2PnT0/src/default\_solve.jl:2 [inlined]  
[16] #solve\_call#433(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DiffEqBase.solve\_call), ::ODEProblem{Float64,Tuple{Int64,Int64},true,Float64,ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem}) at /home/franb/.julia/packages/DiffEqBase/4V8I6/src/solve.jl:40  
[17] solve\_call at /home/franb/.julia/packages/DiffEqBase/4V8I6/src/solve.jl:37 [inlined]  
[18] #solve#434 at /home/franb/.julia/packages/DiffEqBase/4V8I6/src/solve.jl:59 [inlined]  
[19] solve(::ODEProblem{Float64,Tuple{Int64,Int64},true,Float64,ODEFunction{true,typeof(Diffusive),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem}) at /home/franb/.julia/packages/DiffEqBase/4V8I6/src/solve.jl:45  
[20] top-level scope at none:0

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 18, 2019, 4:30am UTC](https://discourse.julialang.org/t/differentialequations-inexact-error/31208/2 "2019-11-18T04:30:07Z")

</div>

> [@FrankBerninger](#):
>
> tspan=(0, 10)

You chose to use `Int` values for time. I updated the default handling to throw a warning in this case:

```julia
┌ Warning: Integer time values are incompatible with adaptive integrators. Utilize floating point numbers instead of integers in this case, i.e. (0.0,1.0) instead of (0,1).
└ @ DiffEqBase C:\Users\accou\.julia\dev\DiffEqBase\src\solve.jl:157

```

So you need to use `tspan = (0.0,10.0)` for what you’re trying to do.

Also, your equation doesn’t make sense.

```julia
function Diffusive(du,u,p,t)
  du = p*(100.0-u)
end

```

is not a mutating function. If you want to not use a mutating function, then use the 3-argument form:

```julia
function Diffusive(u,p,t)
  p*(100.0-u)
end

```

otherwise, if you want to use the in-place functions, then you need to be using a mutable type as your integration state.

In total, your fixed example is:

```julia
using DifferentialEquations
function Diffusive(u,p,t)
  p*(100.0-u)
end
u0=0.1
tspan=(0.0, 10.0)
p=0.2
prob2 =ODEProblem(Diffusive,u0,tspan,p)
solve(prob2)

```

---

<div class="post-metadata">

**Author:** ![FrankBerninger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frankberninger/32/21086_2.png) [@FrankBerninger](https://discourse.julialang.org/u/FrankBerninger)\
**Post date:** [November 18, 2019, 4:37am UTC](https://discourse.julialang.org/t/differentialequations-inexact-error/31208/3 "2019-11-18T04:37:23Z")

</div>

Thanks…

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [November 18, 2019, 5:18am UTC](https://discourse.julialang.org/t/differentialequations-inexact-error/31208/4 "2019-11-18T05:18:46Z")

</div>

> [@ChrisRackauckas](#):
>
> You chose to use `Int` values for time. I updated the default handling to throw a warning in this case:

Out of curiosity, why not just dispatch on `Int` t-spans and promote them to float? i.e. `float.(tspan)`.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 18, 2019, 5:24am UTC](https://discourse.julialang.org/t/differentialequations-inexact-error/31208/5 "2019-11-18T05:24:38Z")

</div>

Because not all differential equations work in continuous time, and so that assumption is incorrect in some important cases.
