Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: MethodError: no method matching contains_zero(::Float64) #202

Closed
lmiq opened this issue May 22, 2024 · 1 comment
Closed

ERROR: MethodError: no method matching contains_zero(::Float64) #202

lmiq opened this issue May 22, 2024 · 1 comment

Comments

@lmiq
Copy link

lmiq commented May 22, 2024

Example:

julia> using IntervalArithmetic, IntervalRootFinding

julia> function f(x; δ=0.001)
           if x < 1 - δ || x > 1 + δ
               0.5
           else
               cos((x-(1.0-δ))*π/δ) - 0.5
           end
       end
f (generic function with 1 method)

julia> roots(x -> f(x; δ = 0.2), 0..1)
ERROR: MethodError: no method matching contains_zero(::Float64)

Closest candidates are:
  contains_zero(::IntervalBox)
   @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/EquAX/src/multidim/intervalbox.jl:107
  contains_zero(::StaticArraysCore.SVector)
   @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/EquAX/src/multidim/intervalbox.jl:106
  contains_zero(::Interval{T}) where T
   @ IntervalArithmetic ~/.julia/packages/IntervalArithmetic/EquAX/src/intervals/special.jl:77

Stacktrace:
  [1] determine_region_status(op::IntervalRootFinding.var"#35#36"{Newton{…}, Float64}, f::var"#26#27", R::Root{Interval{…}})
    @ IntervalRootFinding ~/.julia/packages/IntervalRootFinding/gKaGR/src/contractors.jl:147
  [2] Newton
    @ ~/.julia/packages/IntervalRootFinding/gKaGR/src/contractors.jl:116 [inlined]
  [3] Newton
    @ ~/.julia/packages/IntervalRootFinding/gKaGR/src/contractors.jl:115 [inlined]
  [4] process(search::DepthFirstSearch{Interval{Float64}, Newton{var"#26#27", IntervalRootFinding.var"#41#42"{…}}, Float64}, r::Root{Interval{Float64}})
    @ IntervalRootFinding ~/.julia/packages/IntervalRootFinding/gKaGR/src/roots.jl:56
  [5] iterate(search::DepthFirstSearch{Interval{…}, Newton{…}, Float64}, wt::IntervalRootFinding.BBTree{Root{…}})
    @ IntervalRootFinding ~/.julia/packages/IntervalRootFinding/gKaGR/src/branch_and_bound.jl:307
  [6] branch_and_prune(r::Root{…}, contractor::Newton{…}, search::Type{…}, tol::Float64)
    @ IntervalRootFinding ~/.julia/packages/IntervalRootFinding/gKaGR/src/roots.jl:88
  [7] _roots(f::Function, deriv::Function, r::Root{Interval{Float64}}, contractor::Type{Newton}, strategy::Type{DepthFirstSearch}, tol::Float64)
    @ IntervalRootFinding ~/.julia/packages/IntervalRootFinding/gKaGR/src/roots.jl:169
  [8] _roots
    @ ~/.julia/packages/IntervalRootFinding/gKaGR/src/roots.jl:163 [inlined]
  [9] _roots
    @ ~/.julia/packages/IntervalRootFinding/gKaGR/src/roots.jl:192 [inlined]
 [10] roots
    @ ~/.julia/packages/IntervalRootFinding/gKaGR/src/roots.jl:123 [inlined]
 [11] roots(f::Function, X::Interval{Float64})
    @ IntervalRootFinding ~/.julia/packages/IntervalRootFinding/gKaGR/src/roots.jl:123
 [12] top-level scope
    @ REPL[66]:1
Some type information was truncated. Use `show(err)` to see complete types.

with:

(jl_Kl2P2p) pkg> st
Status `/tmp/jl_Kl2P2p/Project.toml`
⌅ [d1acc4aa] IntervalArithmetic v0.20.9
  [d2bf35a9] IntervalRootFinding v0.5.11
  [91a5bcdd] Plots v1.40.4
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated`

julia> versioninfo()
Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 20 × 12th Gen Intel(R) Core(TM) i7-12700F
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 20 virtual cores)
@Kolaru
Copy link
Collaborator

Kolaru commented Nov 6, 2024

Piecewise functions have been causing problem for a while to IntervalArithmetic, and are not yet gracefully supported.

See JuliaIntervals/IntervalArithmetic.jl#655

IntervalRootFinding should work out of the box once we figure out a satisfying solution.

@Kolaru Kolaru closed this as completed Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants