# ERROR: InexactError: Int64(NaN) in LsqFit.jl

**URL:** <https://discourse.julialang.org/t/error-inexacterror-int64-nan-in-lsqfit-jl/98580>\
**Category:** General Usage\
**Tags:** lsqfit\
**Created:** [May 9, 2023, 10:41pm UTC](https://discourse.julialang.org/t/error-inexacterror-int64-nan-in-lsqfit-jl/98580 "2023-05-09T22:41:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [May 9, 2023, 10:41pm UTC](https://discourse.julialang.org/t/error-inexacterror-int64-nan-in-lsqfit-jl/98580/1 "2023-05-09T22:41:18Z")

</div>

If you face this issue working with `LsqFit.jl` it might help to specify the initial values `p0` as floating point numbers, instead of `Int`.  
This was wrong in my example:

```julia
p0 = [100, 2000, 4000]

```

This cured the issue:

```julia
p0 = [100.0, 2000.0, 4000.0]

```

---

<div class="post-metadata">

**Author:** ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Post date:** [May 9, 2023, 11:28pm UTC](https://discourse.julialang.org/t/error-inexacterror-int64-nan-in-lsqfit-jl/98580/2 "2023-05-09T23:28:50Z")

</div>

This was [154](https://github.com/JuliaNLSolvers/LsqFit.jl/pull/154) but it’s marked closed. I thought the code was changed to insert `float(p0)` which will silently fix this, but perhaps not everywhere? Might be worth making an issue.
