Skip to content

Directional derivatives #428

@briochemc

Description

@briochemc

It would be great to have the API for directional derivatives for functions from ℝⁿ to ℝⁿ. I keep coming back to this problem and I can only guess that I'm not the only one.

I would like to suggest adding a directionalderivative function, such that for a function f(x::Vector) that returns another Vector of the same size,

ForwardDiff.directionalderivative(f, x, y)

gives the derivative of f at x in the y direction.

Right now my solution is to do something like

directionalderivative(f, x, y) = ForwardDiff.jacobian-> f(x + λ .* y), [0.0])

But this feels a bit hacky and I'm sure there are some issues with it... But maybe that's OK? (I @btime'd it on vectors of size ~200'000 and it seemed to perform similar to using DualNumbers' dualpart.(f(x .+ ε * y))

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