Skip to content

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

@lmiq

Description

@lmiq

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions