Skip to content

suspect behavior when attempting to bisect an unbounded interval #781

Closed

Description

@nsajko

I feel like this principle would be nice to have:

When i is an interval unbounded from at least one side, when α is a real number between zero and one, bisect(i, α) should not depend on α, except perhaps if α=0 or α=1 (not sure how should bisect behave for α=0 or α=1).

Does that make sense?

The principle does not hold:

julia> bisect(interval(7.0, Inf), prevfloat(0.5))
([7.0, 7.0]_dac, [7.0, ∞)_dac)

julia> bisect(interval(7.0, Inf), 0.5)
([7.0, ∞)_dac, [1.79769e+308, ∞)_dac)

Seems like α=0.5 is a branching point for bisect when the first argument is an unbounded interval. Why should 0.5 be special here?

Activity

  1. nsajko commented on Sep 23, 2026

    @nsajko
    ContributorAuthor

    Versions:

    julia> versioninfo()
    Julia Version 1.14.0-DEV.3338
    Build Info:
      Official https://julialang.org release
      Commit 70fd7971038 (2026-09-23 02:23 UTC)
      GC: Built with stock GC
    Platform Info:
      OS: Linux (x86_64-unknown-linux-gnu)
      CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics (znver2)
      WORD_SIZE: 64
      LLVM: libLLVM-22.1.8 (ORCJIT, znver2)
    Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)
    Environment:
      JULIA_NUM_PRECOMPILE_TASKS = 2
      JULIA_PKG_PRECOMPILE_AUTO = 0
    
    julia> using Pkg: status
    
    julia> status("IntervalArithmetic")
    Status `~/.julia/environments/v1.14/Project.toml`
      [d1acc4aa] IntervalArithmetic v1.0.12
  2. OlivierHnt commented on Sep 23, 2026

    @OlivierHnt
    Member

    Not sure when this behavior was first introduced. Note that this is the same for mid(x, alpha).

    @dpsanders @Kolaru @lbenet

  3. Kolaru commented on Oct 5, 2026

    @Kolaru
    Member

    I'm not sure either, but a lot is wrong here, seemingly from two different sources:

    • mid for half-infinite intervals is wrong when alpha is not 0.5. Note that the behavior is specified in the standard only for alpha = 0.5
    • High bounds prevfloat(Inf) is displayed as infinite but it shouldn't
    julia> X = bareinterval(7.0, Inf)
    [7.0, ∞)
    
    julia> m = mid(X, 0.4)
    7.0  # This is wrong, should be prevfloat(Inf)
    
    julia> m2 = mid(X, 0.5) 
    1.7976931348623157e308  # Correct
    
    julia> X2 = IntervalArithmetic._unsafe_bareinterval(Float64, 7.0, m2)
    [7.0, ∞) # looks wrong, should be [7.0, 1.7976931348623157e308], but it is only a display thing
    
    julia> X2.hi
    1.7976931348623157e308  # The bound is correct
  4. nsajko commented on Oct 5, 2026

    @nsajko
    ContributorAuthor

    the display issue above is issue #780

  5. Kolaru commented on Oct 8, 2026

    @Kolaru
    Member

    As discussed in today JuliaInterval call, the behavior should be for an half infinite interval X = [a, Inf):

    • mid(X, alpha) == prevfloat(Inf) if 0 < alpha < 1
    • Disallow alpha == 0 or alpha == 1

    And similarly for -Inf bound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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