Skip to content

Incorrect answer for binary division involving two TaylorScalars #87

@facusapienza21

Description

@facusapienza21

Hi!

I encounter this undesirable behaviour as I was doing some TaylorDiff:

derivative(x -> 1 + 1/x, 1.0, Val(1)) 
# returns -1.0, correct answer

derivative(x -> (x+1)/x, 1.0, Val(1))
# returns -2.0, should return -1.0

# If we change the order of the operations, this last example works
derivative(x -> 1/x*(x+1), 1.0, Val(1))
# returns -1.0

It seems that TaylorDiff.jl cannot handle very well the division of TaylorScalars, which is even more evident by looking at the following example:

derivative(x -> x/x, 1.0, Val(1))
# returns -1.0, should return 0.0

This behaviour is the same as when operating directly with TaylorScalars:

x_ty = TaylorScalar((1.0, 1.0))
# TaylorScalar{Float64, 1}(1.0, (1.0,))

x_ty / x_ty
# TaylorScalar{Float64, 1}(1.0, (-1.0,))

I tried to find the origin of this bug but I couldn't find it... I checked on the definition of the ration between TaylorScalars and it seems right, although it is difficult to debug with the @immutable macro in the definition.

Happy to help debugging this! Definitively something that needs to be solved soon!

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