# Error while solving differential equation

**URL:** <https://discourse.julialang.org/t/error-while-solving-differential-equation/12488>\
**Category:** General Usage\
**Created:** [July 19, 2018, 12:31pm UTC](https://discourse.julialang.org/t/error-while-solving-differential-equation/12488 "2018-07-19T12:31:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Johnson](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Alex\_Johnson](https://discourse.julialang.org/u/Alex_Johnson)\
**Post date:** [July 19, 2018, 12:31pm UTC](https://discourse.julialang.org/t/error-while-solving-differential-equation/12488/1 "2018-07-19T12:31:57Z")

</div>

While solving differential equation encountered this error:  
`MethodError: objects of type Float64 are not callable`  
This error is returned while using the solve() function of “Differential equations” package. What can be a reason of this error? A wrong data format given to solve()?

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [July 19, 2018, 1:04pm UTC](https://discourse.julialang.org/t/error-while-solving-differential-equation/12488/2 "2018-07-19T13:04:53Z")

</div>

The reason for the error is that a float is tried to be called:

```julia
julia> a = 1.2                                                                                                                                                           
1.2                                                                                                                                                                      

julia> a()                                                                                                                                                               
ERROR: MethodError: objects of type Float64 are not callable                                                                                                             

```

Presumably you provide a float somewhere where you should give a function. However, without an example it is hard to tell. (And please do make it a MWE, a minimal working example).

---

<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:** [July 19, 2018, 2:00pm UTC](https://discourse.julialang.org/t/error-while-solving-differential-equation/12488/3 "2018-07-19T14:00:32Z")

</div>

And to add a little heuristic to @mauro3’s answer, I find that this happens to me when I do something like `2(a + b * c)`. Notice that the literal `2(` does not get expanded to `2*(`, i.e. there’s no implicit multiplication and instead it does a call. I would search for that happening in your derivative `f` somewhere.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [July 20, 2018, 3:02pm UTC](https://discourse.julialang.org/t/error-while-solving-differential-equation/12488/4 "2018-07-20T15:02:00Z")

</div>

> [@ChrisRackauckas](#):
>
> I find that this happens to me when I do something like `2(a + b * c)` . Notice that the literal `2(` does not get expanded to `2*(` , i.e. there’s no implicit multiplication and instead it does a call.

```julia
julia> a,b,c = 1,1,1
(1, 1, 1)

julia> 2(a + b * c)
4

```

---

<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:** [July 20, 2018, 3:03pm UTC](https://discourse.julialang.org/t/error-while-solving-differential-equation/12488/5 "2018-07-20T15:03:27Z")

</div>

Oh I thought it was literals that did it too. Must just be non-literals.

```julia
julia> a,b,c = 2.0,2.0,2.0
(2.0, 2.0, 2.0)

julia> a(b-c)
ERROR: MethodError: objects of type Float64 are not callable
Stacktrace:
 [1] top-level scope at none:0

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [July 20, 2018, 3:04pm UTC](https://discourse.julialang.org/t/error-while-solving-differential-equation/12488/6 "2018-07-20T15:04:24Z")

</div>

Yes, `a(b)` is indeed a function call 🙂

---

<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:** [July 20, 2018, 3:05pm UTC](https://discourse.julialang.org/t/error-while-solving-differential-equation/12488/7 "2018-07-20T15:05:15Z")

</div>

Did you have a literal parameter in one code, and then refactor that later to use the passed in parameter `p[i]`, but it had the implicit multiplication?

Without seeing the code this is as much help as we can give, but I would guess we’re pretty close 😛.

---

<div class="post-metadata">

**Author:** ![Alex\_Johnson](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Alex\_Johnson](https://discourse.julialang.org/u/Alex_Johnson)\
**Post date:** [July 21, 2018, 11:22am UTC](https://discourse.julialang.org/t/error-while-solving-differential-equation/12488/8 "2018-07-21T11:22:41Z")

</div>

It was a mistake of kind `2(a + b * c)`. Forgot a multiplication sign. Thanks everybody for help!
