# DifferentialEquations.jl Error

**URL:** <https://discourse.julialang.org/t/differentialequations-jl-error/20482>\
**Category:** General Usage\
**Tags:** diffeq\
**Created:** [February 5, 2019, 7:06pm UTC](https://discourse.julialang.org/t/differentialequations-jl-error/20482 "2019-02-05T19:06:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blue](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@Blue](https://discourse.julialang.org/u/Blue)\
**Post date:** [February 5, 2019, 7:06pm UTC](https://discourse.julialang.org/t/differentialequations-jl-error/20482/1 "2019-02-05T19:06:20Z")

</div>

I get the error `MethodError: objects of type Float64 are not callable` when trying to run `sol = solve(prob)`. I have checked solutions to this error and none have worked.

```julia
using DifferentialEquations
const σ = 0.002; const θ = -0.5

function s(val)
return 1+exp(-(val - θ) / σ)^-1
end

function model(du,u,p,t)
x1, x2, y1, y2, xJ, yJ = u
τJ, τE, ε, γ, γJ, β, βJ, δ, δJ, λ, λJ, gexc, ginh, xinh, xexc = p
du[1] = ẋ1 = 3*x1 - x1^3 + y1 - ginh*s(xJ*(t - τJ))(x1 - xinh)
du[2] = ẏ1 = ε*(λ - γ*tanh(β*(x1 - δ)) - y1)
du[3] = ẋ2 = 3*x2 - x2^3 + y2 - ginh*s(xJ*(t - τJ))(x2 - xinh)
du[4] = ẏ1 = ε*(λ - γ*tanh(β*(x2 - δ)) - y2)
du[5] = ẋJ = 3*xJ - xJ^3 + yJ - gexc*(s(du[1]*(t - τE)) + s(du[3]*(t-τE)))(xJ - xexc)
du[6] = ẏJ = ε*(λJ - γJ*tanh(βJ*(xJ - δ)) - yJ)
end

u0 = [-1, -0.3, 0.2, 0.02, -1.1, 0.1]
p = [0, 0, 0.025, 5, 5, 10, 10, -1.1, -1.1, 1, 0, 1, 1, -3, 3]
tspan = (0.0,200.0)
prob = ODEProblem(model,u0,tspan,p)
sol = solve(prob)
using Plots
plot(sol)

```

Any help is appreciated.

---

<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:** [February 5, 2019, 8:02pm UTC](https://discourse.julialang.org/t/differentialequations-jl-error/20482/2 "2019-02-05T20:02:36Z")

</div>

> [@Blue](#):
>
> _s(du[3]_ (t-τE)))(xJ - xexc)

You might want to format you code with ```

But looking at that, `s(du[3]* (t-τE)))` returns a Float64, and so this is like calling a function on that number, which doesn’t make sense and throws that error. Did you mean for this to be `s(du[3]* (t-τE)))*(xJ - xexc)`? I see multiple cases where implicit multiplication is assumed.

---

<div class="post-metadata">

**Author:** ![Blue](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@Blue](https://discourse.julialang.org/u/Blue)\
**Post date:** [February 14, 2019, 6:01pm UTC](https://discourse.julialang.org/t/differentialequations-jl-error/20482/3 "2019-02-14T18:01:07Z")

</div>

Hi Chris.

I did not realize Julia did not support implicit multiplication.

However, a new issue has arisen. I am getting the following error:

```julia
julia> sol = solve(prob)
┌ Warning: Instability detected. Aborting
└ @ DiffEqBase ~/.julia/packages/DiffEqBase/PvfXM/src/integrator_interface.jl:162
retcode: Unstable
Interpolation: 3rd order Hermite
t: 1-element Array{Float64,1}:
 0.0
u: 1-element Array{Array{Float64,1},1}:
 [-1.0, -0.3, 0.2, 0.02, -1.1, 0.1]

```

I assumed this was because a number returned as NaN, but I cannot figure it out. Any ideas?

---

<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:** [February 14, 2019, 11:07pm UTC](https://discourse.julialang.org/t/differentialequations-jl-error/20482/4 "2019-02-14T23:07:52Z")

</div>

Yes, a returned NaN is likely the cause of this, so t only returns the initial condition. I’d need to see what you ran to help.

---

<div class="post-metadata">

**Author:** ![Blue](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@Blue](https://discourse.julialang.org/u/Blue)\
**Post date:** [February 16, 2019, 1:34am UTC](https://discourse.julialang.org/t/differentialequations-jl-error/20482/6 "2019-02-16T01:34:15Z")

</div>

Hi Chris.

Below is the updated code I’ve been trying.

This is a model I am attempting to port from XPP to Julia, but it’s harder than anticipated.

```julia
using DifferentialEquations
# parameters
const τJ = 10; const τE = 0
const ε = 0.025; const γ = 5; const γJ = 5; const β = 10; const βJ = 10; const δ = -1.1; const δJ = -1.1; const λ = 1; const λJ = 0
const σ = 0.002; const θ = -0.5
const gexc = 1; const ginh = 1; const xinh = -3; const xexc = 3
# const x1 = -1; const x2 = -0.3; const y1 = 0.2; const y2 = 0.02; const xJ = -1.1; const yJ = 0.1

function s(val)
  return 1+exp(-(val - θ) / σ)^-1
end

function model(du,u,h,p,t)
  x1, x2, y1, y2, xJ, yJ = u # initial conditions
  du[1] = ẋ1 = 3x1 - x1^3 + y1 - ginh*s(xJ*(h(p, t-τJ)))*(x1 - xinh)
  du[2] = ẏ1 = ε*(λ - γ*tanh(β*(x1 - δ)) - y1)
  du[3] = ẋ2 = 3x2 - x2^3 + y2 - ginh*s(xJ*(h(p, t-τJ)))*(x2 - xinh)
  du[4] = ẏ1 = ε*(λ - γ*tanh(β*(x2 - δ)) - y2) 
  du[5] = ẋJ = 3xJ - xJ^3 + yJ - gexc(s(du[1]*(h(p, t-τE))) + s(du[3]*(h(p, t-τE))))*(xJ - xexc)
  du[6] = ẏJ = ε*(λJ - γJ*tanh(βJ*(xJ - δ)) - yJ)
end

h(p, t) = ones(6) # temporary history
tspan = (0.0,10.0)
u0 = [-1, -0.3, 0.2, 0.02, -1.1, 0.1] # initial conditions
prob = DDEProblem(model,u0,h,tspan)
alg = MethodOfSteps(BS3())
sol = solve(prob,alg) 
using Plots; plot(sol)

```

Thanks for taking a look 🙂 . If you’d like to see my XPP model, I am more than happy to share that as well.

---

<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:** [February 16, 2019, 2:43am UTC](https://discourse.julialang.org/t/differentialequations-jl-error/20482/7 "2019-02-16T02:43:49Z")

</div>

What’s the issue with the model?

---

<div class="post-metadata">

**Author:** ![Blue](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@Blue](https://discourse.julialang.org/u/Blue)\
**Post date:** [February 16, 2019, 5:13am UTC](https://discourse.julialang.org/t/differentialequations-jl-error/20482/8 "2019-02-16T05:13:52Z")

</div>

This is the error I am getting:

```julia
ERROR: MethodError: no method matching -(::Array{Float64,1}, ::Float64)
Closest candidates are:
  -(::Float64, ::Float64) at float.jl:397
  -(::Complex{Bool}, ::Real) at complex.jl:298
  -(::Missing, ::Number) at missing.jl:97
  ...

```

Clearly I am supplying incorrect arguments to the solver, but I am not sure why. I followed the example problems and documentation closely.

---

<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:** [February 16, 2019, 5:32am UTC](https://discourse.julialang.org/t/differentialequations-jl-error/20482/9 "2019-02-16T05:32:02Z")

</div>

`h(p, t-τJ)` is an array. When you subtract a scalar from it you get an error. Did you need intend for it to be an array?
