Skip to content

Interval comparisons may make other packages functions behave unexpectedly #165

@Kolaru

Description

@Kolaru

Comparisons (==, >, <, etc.) between intervals or comparisons between intervals and numbers are possible, and run smoothly and silently, but they may behave in ways that may not make sense for the algorithm used.

As a simple illustration, a decent implementation of sinus cardinal (sin(x)/x) may be

function sinc(x)
    if x == 0
        return one(x)
    else
        return sin(x)/x
    end
end

But

julia> X = -0.001..0.001
[-0.00100001, 0.00100001]

julia> sin(X)/X
[-∞, ∞]

because X != 0 (correct result is [0.999998355066745, 1]).

In particular this makes many functions of SpecialFunctions.jl behave incorrectly, and it may be the reason behind this issue.

A possible way to mitigate it, beyond documenting it, may be to implement a debug mode that raise a warning whenever such comparison is performed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.0Planned for the major 1.0 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions