Skip to content

derivative(xlogx, 0.) gives 0 (should be -Inf) #365

Closed
@cossio

Description

@cossio

Consider the definition of xlogx:

https://github.com/JuliaStats/StatsFuns.jl/blob/7473d0d8f7c5b2f4a53f0625ada5f2323c84ffe4/src/basicfuns.jl#L14

xlogx(x::Real) = x > zero(x) ? x * log(x) : zero(log(x))

Then derivative(xlogx, 0.) returns 0.. The correct answer is -Inf.

I understand this is due to the singular branch at x=0, and I'm not even sure if there is any way that ForwardDiff can handle this.

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