JuliaDiff / JuliaDiff/ForwardDiff.jl
Support derivative(f, ::Complex)
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 1k
- Forks
- 160
- PR merge metrics
- No merged PRs in 30d
Description
I think the following should work:
julia> ForwardDiff.derivative(identity, 1+im)
ERROR: DimensionMismatch: derivative(f, x) expects that x is a real number (does not support Wirtinger derivatives). Separate real and imaginary parts of the input.
Stacktrace:
[1] derivative(f::Function, x::Complex{Int64})
@ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/derivative.jl:73
[2] top-level scope
@ REPL[35]:1
Note that https://github.com/JuliaDiff/ForwardDiff.jl/issues?q=is%3Aissue+is%3Aclosed+complex supports Complex{<:Dual} so the implementation would be really straightforward.
I was surprised not to see a discussion on this. Would a PR adding automatic support for complex differentiation be merged?
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 with the failing example in the issue and inspect derivative.jl around line 73, where complex inputs are rejected. Review the linked closed complex-support issues and existing Complex{Dual} handling before deciding the intended differentiation semantics. Done means the reported complex derivative case works with appropriate tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100