JuliaDiff / JuliaDiff/ForwardDiff.jl
Directional derivatives
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 1k
- Forks
- 160
- PR merge metrics
- No merged PRs in 30d
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))
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing ForwardDiff.jacobian API and the proposed ForwardDiff.directionalderivative call, including the comparison with DualNumbers and the current workaround. Done means providing a documented directional-derivative API for vector-valued functions that returns the derivative at x in direction y, with behavior and performance validated for the described inputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100