# InexactError in HomotopyContinuation.jl when solving a 5-body central configuration system

**URL:** <https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462>\
**Category:** Specific Domains\
**Tags:** question\
**Created:** [March 30, 2026, 12:22pm UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462 "2026-03-30T12:22:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaoming](https://avatars.discourse-cdn.com/v4/letter/x/a6a055/32.png) [@xiaoming](https://discourse.julialang.org/u/xiaoming)\
**Post date:** [March 30, 2026, 12:22pm UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462/1 "2026-03-30T12:22:04Z")

</div>

I am trying to use HomotopyContinuation.jl to solve the central configuration problem. Below is a minimal working example of my code:

```julia-auto
using HomotopyContinuation, LinearAlgebra
function gen_equations(m)
    n = length(m)
    @var r[1:n, 1:n]
    @var u[1:n, 1:n]
    S = Matrix(undef, n, n)
    R = (i, j) -> (i == j ? zero(r[1, 1]) : (i < j ? r[i, j] : r[j, i]))
    U = (i, j) -> (i == j ? zero(u[1, 1]) : (i < j ? u[i, j] : u[j, i]))
    for i in 1:n
        for j in 1:n
            if i == j
                S[i, j] = 0.0
            else
                S[i, j] = (U(i, j)^3) - 1
            end
        end
    end
    result = Matrix(undef, n, n)
    for i in 1:n
        for j in 1:n
            a = 0
            for k in 1:n
                a = a + m[k] * (S[i, k] * (R(j, k)^2 - R(i, k)^2 - R(i, j)^2) + S[j, k] * (R(i, k)^2 - R(j, k)^2 - R(i, j)^2))
            end
            result[i, j] = a
        end
    end
    eq = Expression[]
    var = Variable[]
    for i in 1:n
        for j in 1:n
            if i < j
                push!(eq, result[i, j])
                append!(var, [r[i,j],u[i,j]])
                push!(eq, U(i, j) * R(i, j) - 1)
            end
        end
    end
    System(eq, variables=var)
end
m=[1.0,2.0,3.0,4.0,5.0]
sys = gen_equations(m)
result_hc = solve(sys)

```

For `n = 4`, the code runs successfully. However, when I increase the number of bodies to `n = 5`, I encounter the following error:

```julia-auto
Computing mixed cells... 13742 Time: 0:00:19
   mixed_volume: 133998561
ERROR: InexactError: trunc(Int32, 488183162732544)
Stacktrace:
  [1] throw_inexacterror(func::Symbol, to::Type, val::Int64)
    @ Core .\boot.jl:815
  [2] checked_trunc_sint
    @ .\boot.jl:829 [inlined]
  [3] toInt32
    @ .\boot.jl:866 [inlined]
  [4] Int32
    @ .\boot.jl:956 [inlined]
  [5] convert
    @ .\number.jl:7 [inlined]
  [6] cconvert
    @ .\essentials.jl:687 [inlined]
  [7] set_si!
    @ .\gmp.jl:217 [inlined]
  [8] _broadcast_getindex_evalf
    @ .\broadcast.jl:699 [inlined]
  [9] _broadcast_getindex
    @ .\broadcast.jl:672 [inlined]
 [10] _getindex
    @ .\broadcast.jl:620 [inlined]
 [11] getindex
    @ .\broadcast.jl:616 [inlined]
 [12] macro expansion
    @ .\broadcast.jl:995 [inlined]
 [13] macro expansion
    @ .\simdloop.jl:77 [inlined]
 [14] copyto!
    @ .\broadcast.jl:994 [inlined]
 [15] copyto!
    @ .\broadcast.jl:947 [inlined]
 [16] copy
    @ .\broadcast.jl:919 [inlined]
 [17] materialize
    @ .\broadcast.jl:894 [inlined]
 [18] solve!(BSS::HomotopyContinuation.BinomialSystemSolver)
    @ HomotopyContinuation C:\Users\PC\.julia\packages\HomotopyContinuation\07UGP\src\binomial_system.jl:178
 [19] solve
    @ C:\Users\PC\.julia\packages\HomotopyContinuation\07UGP\src\binomial_system.jl:162 [inlined]
 [20] iterate(iter::PolyhedralStartSolutionsIterator{Vector{…}}, state::Tuple{MixedSubdivisions.MixedCell, Int64, Int64})
    @ HomotopyContinuation C:\Users\PC\.julia\packages\HomotopyContinuation\07UGP\src\polyhedral.jl:94
 [21] _collect(cont::UnitRange{…}, itr::PolyhedralStartSolutionsIterator{…}, ::Base.HasEltype, isz::Base.SizeUnknown)
    @ Base .\array.jl:741
 [22] collect
    @ .\array.jl:728 [inlined]
 [23] #solve#278
    @ C:\Users\PC\.julia\packages\HomotopyContinuation\07UGP\src\solve.jl:535 [inlined]
 [24] solve(args::System; show_progress::Bool, threading::Bool, catch_interrupt::Bool, target_parameters::Nothing, stop_early_cb::Function, transform_result::Nothing, transform_parameters::typeof(identity), flatten::Nothing, target_subspaces::Nothing, iterator_only::Bool, bitmask::Nothing, kwargs::@Kwargs{})
    @ HomotopyContinuation C:\Users\PC\.julia\packages\HomotopyContinuation\07UGP\src\solve.jl:508
 [25] solve(args::System)
    @ HomotopyContinuation C:\Users\PC\.julia\packages\HomotopyContinuation\07UGP\src\solve.jl:439
 [26] top-level scope
    @ c:\Users\PC\Desktop\同伦延拓\ask.jl:43
Some type information was truncated. Use `show(err)` to see complete types.

```

### **Question**

It seems that the error is caused by an integer overflow when converting to `Int32`, likely due to the extremely large mixed volume.

Is there any way to make this computation work (even if it takes a very long time)? For example:

- Can this limitation be bypassed (e.g., using `Int64` or arbitrary precision)?
- Is there a recommended way to handle such large systems in `HomotopyContinuation.jl`?

Any suggestions would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [March 31, 2026, 9:28am UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462/2 "2026-03-31T09:28:30Z")

</div>

Can you share more details about your platform and the julia/package versions? E.g. the output of `versioninfo()` and `Pkg.status()` in the corresponding environment.

I’m not familiar with the package or the underlying math, but I just tried to run your code on Linux with Julia 1.10.10 and HomotopyContinuation.jl version 2.18.0 and couldn’t reproduce the error (although I stopped the computation after a while, since the displayed ETA is over 20 days… so the error might appear much later (?) ).

```julia-auto
Tracking 133998561 paths... 0%| | ETA: 24.62 days
                   # paths tracked: 8076
   # non-singular solutions (real): 6630 (0)
       # singular endpoints (real): 3 (0)
          # total solutions (real): 6633 (0)

```

> **versions**
>
> ```julia-repl
> julia> versioninfo()
> Julia Version 1.10.10
> Commit 95f30e51f41 (2025-06-27 09:51 UTC)
> Build Info:
> Official https://julialang.org/ release
> Platform Info:
> OS: Linux (x86_64-linux-gnu)
> CPU: 64 × AMD Ryzen Threadripper PRO 3975WX 32-Cores
> WORD_SIZE: 64
> LIBM: libopenlibm
> LLVM: libLLVM-15.0.7 (ORCJIT, znver2)
> Threads: 1 default, 0 interactive, 1 GC (on 64 virtual cores)
> Environment:
> JULIA_PKG_USE_CLI_GIT = true
> JULIA_MAX_NUM_PRECOMPILE_FILES = 50
> 
> (jl_acS1S7) pkg> st
> Status `/tmp/jl_acS1S7/Project.toml`
> [f213a82b] HomotopyContinuation v2.18.0
> [37e2e46d] LinearAlgebra
> 
> ```

---

<div class="post-metadata">

**Author:** ![xiaoming](https://avatars.discourse-cdn.com/v4/letter/x/a6a055/32.png) [@xiaoming](https://discourse.julialang.org/u/xiaoming)\
**Post date:** [March 31, 2026, 10:03am UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462/3 "2026-03-31T10:03:59Z")

</div>

Thanks for your attention to this issue. Below are my platform details and the versions of Julia and the relevant packages:

```julia-auto
julia> versioninfo()
Julia Version 1.12.5
Commit 5fe89b8ddc (2026-02-09 16:05 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 28 × Intel(R) Core(TM) i7-14700KF
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, alderlake)
  GC: Built with stock GC
Threads: 28 default, 1 interactive, 28 GC (on 28 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_VSCODE_REPL = 1
  JULIA_NUM_THREADS = 28

(同伦延拓) pkg> st
Status `C:\Users\PC\Desktop\同伦延拓\Project.toml`
⌃ [0f109fa4] BifurcationKit v0.5.6
  [e9467ef8] GLMakie v0.13.9
⌃ [f213a82b] HomotopyContinuation v2.16.0
  [91a5bcdd] Plots v1.41.6
Info Packages marked with ⌃ have new versions available and may be upgradable.

```

I will give a try with julia 1.10.10 and HomotopyContinuation v2.18.0

---

<div class="post-metadata">

**Author:** ![xiaoming](https://avatars.discourse-cdn.com/v4/letter/x/a6a055/32.png) [@xiaoming](https://discourse.julialang.org/u/xiaoming)\
**Post date:** [March 31, 2026, 10:17am UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462/4 "2026-03-31T10:17:14Z")

</div>

I have tested this on my platform using Julia 1.10.10 together with HomotopyContinuation.jl v2.18.0, but I encountered the same error:

```julia-auto
Computing mixed cells... 17171 Time: 0:00:05
   mixed_volume: 133998561
ERROR: InexactError: trunc(Int32, 327523762176)
Stacktrace:
  [1] throw_inexacterror(f::Symbol, ::Type{Int32}, val::Int64)
    @ Core .\boot.jl:634
  [2] checked_trunc_sint
    @ .\boot.jl:656 [inlined]
  [3] toInt32
    @ .\boot.jl:693 [inlined]
  [4] Int32
    @ .\boot.jl:783 [inlined]
  [5] convert
    @ .\number.jl:7 [inlined]
  [6] cconvert
    @ .\essentials.jl:543 [inlined]
  [7] set_si!
    @ .\gmp.jl:211 [inlined]
  [8] _broadcast_getindex_evalf
    @ .\broadcast.jl:709 [inlined]
  [9] _broadcast_getindex
    @ .\broadcast.jl:682 [inlined]
 [10] getindex
    @ .\broadcast.jl:636 [inlined]
 [11] macro expansion
    @ .\broadcast.jl:1004 [inlined]
 [12] macro expansion
    @ .\simdloop.jl:77 [inlined]
 [13] copyto!
    @ .\broadcast.jl:1003 [inlined]
 [14] copyto!
    @ .\broadcast.jl:956 [inlined]
 [15] copy
    @ .\broadcast.jl:928 [inlined]
 [16] materialize
    @ .\broadcast.jl:903 [inlined]
 [17] solve!(BSS::HomotopyContinuation.BinomialSystemSolver)
    @ HomotopyContinuation C:\Users\PC\.julia\packages\HomotopyContinuation\3ppvs\src\binomial_system.jl:178
 [18] solve
    @ C:\Users\PC\.julia\packages\HomotopyContinuation\3ppvs\src\binomial_system.jl:162 [inlined]
 [19] iterate(iter::PolyhedralStartSolutionsIterator{Vector{…}}, state::Tuple{MixedSubdivisions.MixedCell, Int64, Int64})
    @ HomotopyContinuation C:\Users\PC\.julia\packages\HomotopyContinuation\3ppvs\src\polyhedral.jl:94
 [20] _collect(cont::UnitRange{…}, itr::PolyhedralStartSolutionsIterator{…}, ::Base.HasEltype, isz::Base.SizeUnknown)
    @ Base .\array.jl:772
 [21] collect
    @ .\array.jl:759 [inlined]
 [22] #solve#306
    @ C:\Users\PC\.julia\packages\HomotopyContinuation\3ppvs\src\solve.jl:541 [inlined]
 [23] solve(args::System; show_progress::Bool, threading::Bool, catch_interrupt::Bool, target_parameters::Nothing, stop_early_cb::Function, transform_result::Nothing, transform_parameters::typeof(identity), flatten::Nothing, target_subspaces::Nothing, iterator_only::Bool, bitmask::Nothing, kwargs::@Kwargs{})
    @ HomotopyContinuation C:\Users\PC\.julia\packages\HomotopyContinuation\3ppvs\src\solve.jl:514
 [24] solve(args::System)
    @ HomotopyContinuation C:\Users\PC\.julia\packages\HomotopyContinuation\3ppvs\src\solve.jl:445
 [25] top-level scope
    @ c:\Users\PC\Desktop\同伦延拓\ask.jl:43
Some type information was truncated. Use `show(err)` to see complete types.

```

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [March 31, 2026, 5:56pm UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462/5 "2026-03-31T17:56:16Z")

</div>

> [@xiaoming](#):
>
> ```julia-auto
> Platform Info:
> OS: Windows (x86_64-w64-mingw32)
> 
> ```

I think maybe `Clong === Int32` on this platform, but not on other platforms, such as Linux. That could be connected.

Possibly related piece of code:

> <https://github.com/JuliaHomotopyContinuation/HomotopyContinuation.jl/blob/ae53233bdce0c813f4d97ac20bc8cd7793c5eef7/src/utils.jl#L486-L497>

cc @saschatimme @jonas-schulze

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [April 1, 2026, 10:01am UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462/6 "2026-04-01T10:01:40Z")

</div>

> [@nsajko](#):
>
> I think maybe `Clong === Int32` on this platform

Looks like it. I just tried to reproduce the error on a Windows VM and there indeed `Clong === Int32`:

```julia-repl
julia> versioninfo()
Julia Version 1.12.5
Commit 5fe89b8ddc (2026-02-09 16:05 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 16 × Common KVM processor
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, k8-sse3)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 16 virtual cores)

```

Following the stack trace: On Windows, if I just try this in a fresh Julia session and empty environment I get the same error (but not on Linux):

```julia-repl
julia> using Base.GMP.MPZ: set_si!

julia> a = BigInt(1)
1

julia> set_si!(a, 2)
2

julia> set_si!(a, 13316210621153480)
ERROR: InexactError: trunc(Int32, 13316210621153480)
Stacktrace:
 [1] throw_inexacterror(func::Symbol, to::Type, val::Int64)
   @ Core .\boot.jl:815
 [2] checked_trunc_sint
   @ .\boot.jl:829 [inlined]
 [3] toInt32
   @ .\boot.jl:866 [inlined]
 [4] Int32
   @ .\boot.jl:956 [inlined]
 [5] convert
   @ .\number.jl:7 [inlined]
 [6] cconvert
   @ .\essentials.jl:687 [inlined]
 [7] set_si!(x::BigInt, a::Int64)
   @ Base.GMP.MPZ .\gmp.jl:217
 [8] top-level scope

```

The function at `Base.GMP.MPZ .\gmp.jl:217` looks like this:

> <https://github.com/JuliaLang/julia/blob/5a8e96257630dd57abe41f679f7b8c4864d0c921/base/gmp.jl#L214-L220>

(copied here for nicer syntax highlighting)

```julia
for (op, T) in ((:fac_ui, Culong), (:set_ui, Culong), (:set_si, Clong), (:set_d, Cdouble))
    op! = Symbol(op, :!)
    @eval begin
        $op!(x::BigInt, a) = (ccall($(gmpz(op)), Cvoid, (mpz_t, $T), x, a); x)
        $op(a) = $op!(BigInt(), a)
    end
end

```

Like @nsajko suspected, there is an attempt to convert the Julia integer to `Clong` which is `Int32` and can’t hold the number from the argument. It basically boils down to trying

```julia
Base.cconvert(Clong, 13316210621153480)

```

which fails on the `x86_64-w64-mingw32` system, but if `Clong === Int64` (e.g. on my Linux machine).

* * *

I just learned that the various `int`, `long`, `long long` etc. types in C are not defined in terms of absolute sizes (bits), but they just have to respect that the next larger type can contain at least all the numbers from the smaller type. This is kind of unfortunate 😅 and makes me wonder if the problem with the above `set_si!` function is actually a bug or not?

For me it sounds reasonable that `set_si!` for arbitrary precision integers should convert to `long long`, not just `long`, but `libgmp` doesn’t seem to implement that internally, so that gives wrong results:

```julia-repl
julia> Base.GMP.MPZ.gmpz(:set_si)
(:__gmpz_set_si, "libgmp-10.dll")

julia> a = BigInt(1)
1

julia> ccall((:__gmpz_set_si, "libgmp-10.dll"), Cvoid, (Base.GMP.MPZ.mpz_t, Clonglong), a, 13316210621153480); a
-472645432

```

So I’m not sure how to proceed here 😅 Is this an issue with the package or with Base/libgmp (or both)? At least the functions from HomotopyContinuation.jl quoted above by @nsajko also (wrongly) assumes that `Clong` is equal to `Int64`. Probably the way the low-level `set_si!` is used in the package assumes the same? In Base, the regular arithmetic with `BigInt` works fine, so it’s probably best to file an issue with the package (?)

---

<div class="post-metadata">

**Author:** ![xiaoming](https://avatars.discourse-cdn.com/v4/letter/x/a6a055/32.png) [@xiaoming](https://discourse.julialang.org/u/xiaoming)\
**Post date:** [April 1, 2026, 11:34am UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462/7 "2026-04-01T11:34:51Z")

</div>

Thank you very much for your helpful comments and suggestions. I found a related issue in the repository: [InexactError on certain operating systems](https://github.com/JuliaHomotopyContinuation/HomotopyContinuation.jl/issues/644), which seems to describe a very similar behavior (especially the overflow in `trunc(Int32, ...)` and the dependence on mixed volume and platform). So this might not be specific to my example.  
I will follow up there and, if needed, provide additional details for my example.

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [April 1, 2026, 2:13pm UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462/8 "2026-04-01T14:13:47Z")

</div>

For a proper fix, I see two alternatives:

- reimplement this logic in HomotopyContinuation.jl:

- Make HomotopyContinuation.jl depend on MutableArithmetics.jl

Will make a PR, if no one else does first.

My plan currently is to:

- make some PRs to MutableArithmetics.jl, relevant issues:

- then make HomotopyContinuation.jl depend on MutableArithmetics.jl

---

<div class="post-metadata">

**Author:** ![jonas-schulze](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonas-schulze/32/9228_2.png) [@jonas-schulze](https://discourse.julialang.org/u/jonas-schulze)\
**Post date:** [April 9, 2026, 11:37am UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462/9 "2026-04-09T11:37:41Z")

</div>

Thanks for tackling this, @nsajko! I am not working in the field of homotopy continuation anymore, unfortunately. Your action plan sounds reasonable to me, though would it be possible to make HC.jl use the logic from `julia/base/gmp.jl` you referenced?

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [April 9, 2026, 2:45pm UTC](https://discourse.julialang.org/t/inexacterror-in-homotopycontinuation-jl-when-solving-a-5-body-central-configuration-system/136462/10 "2026-04-09T14:45:36Z")

</div>

> [@jonas-schulze](#):
>
> would it be possible to make [HC.jl](https://juliaregistries.github.io/General/packages/redirect_to_repo/HC) use the logic from `julia/base/gmp.jl` you referenced?

Sure, but MutableArithmetics.jl seems like the more appropriate place for that code to live. Then it can be reused across the ecosystem, instead of duplicated in each package that uses `BigInt`.
