# InexactError when trying to define in DynamicalSystems.jl

**URL:** <https://discourse.julialang.org/t/inexacterror-when-trying-to-define-in-dynamicalsystems-jl/30076>\
**Category:** General Usage\
**Created:** [October 19, 2019, 12:26pm UTC](https://discourse.julialang.org/t/inexacterror-when-trying-to-define-in-dynamicalsystems-jl/30076 "2019-10-19T12:26:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamsuddhasattwa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iamsuddhasattwa/32/7441_2.png) [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)\
**Post date:** [October 19, 2019, 12:26pm UTC](https://discourse.julialang.org/t/inexacterror-when-trying-to-define-in-dynamicalsystems-jl/30076/1 "2019-10-19T12:26:10Z")

</div>

I am trying to create a dynamical system using the `DynamicalSystems.jl` package. However, I am encountering a very basic problem when trying to define a system.

```julia
using DynamicalSystems;
function L63_eom!(du, u, p, t)
         du[1] = p[1]*(u[2]-u[1]);
         du[2] = u[1]*(p[2]-u[3])-u[2];
         du[3] = u[1]*u[2]-p[3]*u[3];
         return nothing;
end
L63_param = [10.0, 28.0, 8.0/3];
L63 = ContinuousDynamicalSystem( L63_eom!, [0, 1, 0], L63_param );

```

I get the following error.

```julia
ERROR: InexactError: Int64(-2.6666666666666665)
Stacktrace:
 [1] Type at ./float.jl:703 [inlined]
 [2] convert at ./number.jl:7 [inlined]
 [3] convert at ./essentials.jl:304 [inlined] (repeats 3 times)
 [4] Type at /home/dass/.julia/packages/ForwardDiff/N0wMF/src/partials.jl:2 [inlined]
 [5] convert at /home/dass/.julia/packages/ForwardDiff/N0wMF/src/partials.jl:74 [inlined]
 [6] convert at /home/dass/.julia/packages/ForwardDiff/N0wMF/src/dual.jl:355 [inlined]
 [7] setindex! at ./array.jl:766 [inlined]
 [8] L63_eom!(::Array{ForwardDiff.Dual{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3},1}, ::Array{ForwardDiff.Dual{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3},1}, ::Array{Float64,1}, ::Int64) at ./REPL[7]:4
 [9] #9 at /home/dass/.julia/packages/DynamicalSystemsBase/W0ZBG/src/dynamicalsystem.jl:298 [inlined]
 [10] vector_mode_dual_eval(::getfield(DynamicalSystemsBase, Symbol("##9#16")){Array{Float64,1},Int64,typeof(L63_eom!)}, ::Array{Int64,1}, ::Array{Int64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3,Tuple{Array{ForwardDiff.Dual{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3},1}}}) at /home/dass/.julia/packages/ForwardDiff/N0wMF/src/apiutils.jl:44
 [11] vector_mode_jacobian!(::Array{Int64,2}, ::getfield(DynamicalSystemsBase, Symbol("##9#16")){Array{Float64,1},Int64,typeof(L63_eom!)}, ::Array{Int64,1}, ::Array{Int64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3,Tuple{Array{ForwardDiff.Dual{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3},1}}}) at /home/dass/.julia/packages/ForwardDiff/N0wMF/src/jacobian.jl:164
 [12] jacobian! at /home/dass/.julia/packages/ForwardDiff/N0wMF/src/jacobian.jl:74 [inlined]
 [13] #8 at /home/dass/.julia/packages/DynamicalSystemsBase/W0ZBG/src/dynamicalsystem.jl:297 [inlined]
 [14] get_J(::getfield(DynamicalSystemsBase, Symbol("##8#15")){typeof(L63_eom!),Array{Int64,1},ForwardDiff.JacobianConfig{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3,Tuple{Array{ForwardDiff.Dual{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{getfield(DynamicalSystemsBase, Symbol("##7#14")){typeof(L63_eom!),Array{Float64,1},Int64},Int64},Int64,3},1}}}}, ::Array{Int64,1}, ::Array{Float64,1}, ::Int64, ::Bool) at /home/dass/.julia/packages/DynamicalSystemsBase/W0ZBG/src/dynamicalsystem.jl:318
 [15] #ContinuousDynamicalSystem#2(::Float64, ::Type{ContinuousDynamicalSystem}, ::Function, ::Array{Int64,1}, ::Array{Float64,1}) at /home/dass/.julia/packages/DynamicalSystemsBase/W0ZBG/src/dynamicalsystem.jl:239
 [16] ContinuousDynamicalSystem(::Function, ::Array{Int64,1}, ::Array{Float64,1}) at /home/dass/.julia/packages/DynamicalSystemsBase/W0ZBG/src/dynamicalsystem.jl:228
 [17] top-level scope at REPL[8]:1

```

Why would the program try to convert a parameter value into Int64 ?

---

<div class="post-metadata">

**Author:** ![dawbarton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dawbarton/32/215461_2.png) [@dawbarton](https://discourse.julialang.org/u/dawbarton)\
**Post date:** [October 19, 2019, 12:55pm UTC](https://discourse.julialang.org/t/inexacterror-when-trying-to-define-in-dynamicalsystems-jl/30076/2 "2019-10-19T12:55:15Z")

</div>

Just a guess but it looks like you are specifying your initial conditions as an Int64 array and so it assumes that your states are Int64 rather than Float64. Try using `[0.0, 1.0, 0.0]` instead of `[0, 1, 0]`.

---

<div class="post-metadata">

**Author:** ![iamsuddhasattwa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iamsuddhasattwa/32/7441_2.png) [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)\
**Post date:** [October 19, 2019, 2:37pm UTC](https://discourse.julialang.org/t/inexacterror-when-trying-to-define-in-dynamicalsystems-jl/30076/3 "2019-10-19T14:37:42Z")

</div>

> [@iamsuddhasattwa](#):
>
> L63 = ContinuousDynamicalSystem( L63\_eom!, [0, 1, 0], L63\_param );

Thank you, you were right. Becaue the function L63\_eom was a generic function, probably Julia tries to switch to Int64 arithmetic when it reads the vector [0,1,1].
