Skip to content

NaN partials and comparison #790

@aplavin

Description

@aplavin

Some operations generate Dual with NaN partials, and I'm not sure comparison operators are defined consistently for them...

julia> xs = Dual(0.0,NaN)

# it's not zero,
julia> iszero(xs)
false
# no, definitely not zero,
julia> xs  0
false

# it's a regular finite number:
julia> isnan(xs)
false
julia> isfinite(xs)
true

# moreover, it's a positive number
julia> xs > 0
true

# but adding this positive number, or multiplying it by anything still gives the same number back:
julia> xs + xs === xs
true
julia> xs * 1e100 === xs
true
# these are the defining properties of a zero
# shouldn't it be considered a zero really?

Intuitively I would say that the most natural thing is to compare equal to zero, but maybe there are other self-consistent choices as well.

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