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

Do not impose tol to be Float64 #133

Open
lbenet opened this issue Jul 24, 2019 · 2 comments
Open

Do not impose tol to be Float64 #133

lbenet opened this issue Jul 24, 2019 · 2 comments

Comments

@lbenet
Copy link
Member

lbenet commented Jul 24, 2019

The following throws a MethodError:

julia> using IntervalArithmetic, IntervalRootFinding

julia> f(x) = -4*x^3 + 5*x^4
f (generic function with 1 method)

julia> dom = big(0) .. big(1)
[0, 1]₂₅₆

julia> roots(f, dom, Newton, 1.0e-5)  # works ok
2-element Array{Root{Interval{BigFloat}},1}:
 Root([0.799999, 0.800001]₂₅₆, :unique)
 Root([0, 6.67704e-06]₂₅₆, :unknown)   

julia> roots(f, dom, Newton, parse(BigFloat, "1.0e-5"))
ERROR: MethodError: no method matching roots(::typeof(f), ::Interval{BigFloat}, ::Type{Newton}, ::BigFloat)
Closest candidates are:
  roots(::Any, ::Interval{T}, ::Union{Type{Krawczyk}, Type{Newton}}) where T at /Users/benet/.julia/dev/IntervalRootFinding/src/roots.jl:153
  roots(::Any, ::Interval{T}, ::Union{Type{Krawczyk}, Type{Newton}}, ::Float64) where T at /Users/benet/.julia/dev/IntervalRootFinding/src/roots.jl:153
  roots(::F<:Function, ::F<:Function, ::Any) where F<:Function at /Users/benet/.julia/dev/IntervalRootFinding/src/roots.jl:226
  ...
Stacktrace:
 [1] top-level scope at none:0

I think it makes sense to allow tol in the roots methods to be <:AbstractFloat?

@dpsanders
Copy link
Member

Sure. I think it can be any real number in fact.

@Kolaru
Copy link
Collaborator

Kolaru commented Nov 6, 2024

Currently we are requiring all arguments to have the same type, but this type can be anything.

This still fails, because some default arguments are Float64, so if not everything is specified, it fails.

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

3 participants