I have found some erratic behaviour for the IntervalRootFinding.jl package when using multithreading. Specifically, when using multiple threads, the roots
interface will sometimes return either false positives for non-existing roots, or fail to identify roots. Moreover, the errors vary at every run.
The minimum working example below repeatedly looks for roots on an interval without roots, and then counts the number of unique roots found. It should always return 1. When using one thread, everything is fine, but as soon as I run the same code with multiple threads, random errors start creeping up.
using IntervalRootFinding
let
results = []
Threads.@threads for iter in 1:1000
f(x) = (x^-1)-1
result = roots(f, 0.0001..10000)
push!(results, result)
end
length(unique(results))
end
Am I doing something wrong, or is this an issue within the package? I’ve tried this on multiple computers, and the problem already emerges when starting the REPL with multiple cores.