-
Notifications
You must be signed in to change notification settings - Fork 154
Open
Description
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
Labels
No labels