JuliaDiff / JuliaDiff/Diffractor.jl
Incorrect Jacobian calculation
Open
Nobody has claimed this yet.
bug
- Dominant language
- Julia
- Stars
- 453
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
using ForwardDiff
using Diffractor: DiffractorForwardBackend
import AbstractDifferentiation as AD
function test(z0)
z = Vector{eltype(z0)}(undef, length(z0))
L = 0.5
k1 = 0.36
z[1] = cos(sqrt(k1)*L)*z0[1]+1/sqrt(k1)*sin(sqrt(k1)*L)*z0[2]
z[2] = -sqrt(k1)*sin(sqrt(k1)*L)*z0[1]+cos(sqrt(k1)*L)*z0[2]
return z
end
m(z) = test([z[1], z[2]])
Then:
julia> j = AD.jacobian(DiffractorForwardBackend(), m, zeros(2)) |> only
2×2 Matrix{Float64}:
0.29552 0.492534
-0.177312 0.29552
julia> j = AD.jacobian(AD.ForwardDiffBackend(), m, zeros(2)) |> only
2×2 Matrix{Float64}:
0.955336 0.492534
-0.177312 0.955336
ForwardDiff.jl's Jacobian was also cross-checked with GTPSA.jl
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 running the Julia reproducer in the issue and compare DiffractorForwardBackend's Jacobian with AD.ForwardDiffBackend and the GTPSA.jl cross-check. Trace the Diffractor Jacobian path for the test function and determine why its first diagonal entries differ; done means the Diffractor result matches the cross-checked Jacobian.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100