Error while solving differential equation

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()?

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

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).

3 Likes

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.

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

julia> 2(a + b * c)
4

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

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

Yes, a(b) is indeed a function call :slight_smile:

1 Like

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 :stuck_out_tongue:.

1 Like

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