Complex Differentiation
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
Bắt đầu bằng việc xem xét các entry point ForwardDiff derivative, can_dual và Partials được đề cập, cùng với các test case hiện có. Điều tra xem việc thay thế các ràng buộc Real bằng Number có hỗ trợ các hàm phức giải tích đồng thời từ chối các phép toán không giải tích hay không. Được xem là hoàn thành khi các test hiện có đều pass và các test được thêm cho hàm phức bao quát cả các đạo hàm thành công lẫn các lỗi được mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I'd really like to be able to differentiate complex functions with ForwardDiff. For almost all analytic functions, the derivative can be taken in the same way as in the real case, so Julia's dynamic type system should make complex diferentiation work out of the box. It seems to me that the only reason it doesn't is because many functions in ForwardDiff accept Real arguments, but if we simply changed these to accept Numbers then we should be most of the way there. Functions that are not analytic such as real, imag, abs, conj, abs2, reim should all return errors when their derivatives are taken at a complex input. For example, consider these two functions:
f(z) = z^2
g(z) = Complex(real(z)^2 - imag(z)^2, 2 * real(z) * imag(z))
These functions are equal and both analytic, but it is not obvious by looking at g that it is analytic. In my opinion, it would be acceptable if derivative(f, im) worked while derivative(g, im) threw an error.
I already started experimenting with this. I copied the definitions of several functions in ForwardDiff and just replaced Real with Complex, like so:
ForwardDiff.can_dual(::Type{Complex{T}}) where {T<:Real} = true
@inline function ForwardDiff.derivative(f::F, x::R) where {F,R<:Complex}
T = typeof(Tag(f, R))
return extract_derivative(T, f(Dual{T}(x, one(x))))
end
@inline function Base.:*(partials::Partials, x::Complex)
return Partials(scale_tuple(partials.values, x))
end
@inline function Base.:/(partials::Partials, x::Complex)
return Partials(div_tuple_by_scalar(partials.values, x))
end
@inline Base.:*(x::Complex, partials::Partials) = partials * x
@inline Base.:*(partials::Partials{0,V}, x::Complex) where {V} = Partials{0,promote_type(V, typeof(x))}(tuple())
@inline Base.:*(x::Complex, partials::Partials{0,V}) where {V} = Partials{0,promote_type(V, typeof(x))}(tuple())
@inline Base.:/(partials::Partials{0,V}, x::Complex) where {V} = Partials{0,promote_type(V, typeof(x))}(tuple())
This was enough for me to correctly differentiate sin. I expect that if we just do this throughout ForwardDiff (and replace the Real definitions with Number, instead of adding Complex definitions like I did here), then we'll be most of the way there. Here's my plan:
- Find and replace
RealwithNumberthroughout the repository - Tweak things until all the test cases pass
- Add test cases for complex functions
I'm tempted to actually do this and make a pull request as soon as I have some time to do so.
- Ngôn ngữ chính
- Julia
- Star
- 80
- Fork
- 28
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JuliaDiff/DualNumbers.jl
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
JuliaDiff/DualNumbers.jl#94 · 2 bình luận ·
-
div() and rem()Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
JuliaDiff/DualNumbers.jl#93 ·
-
bitmix not definedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
JuliaDiff/DualNumbers.jl#88 ·
-
Should we export ϵ ≡ ε?Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
JuliaDiff/DualNumbers.jl#87 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
JuliaDiff/DualNumbers.jl#81 ·
Tất cả issue của JuliaDiff/DualNumbers.jl
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Sienna-Platform/InfrastructureSystems.jl#675 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
TargetEncoder reuses the first level's shrinkage factor for all levels when m > 0Có thể đã có người làm @parth-patel010 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
JuliaAI/MLJTransforms.jl#95 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
SciML/RecursiveArrayTools.jl#687 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
SciML/Corleone.jl#179 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Setup Aqua.jlĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
JuliaUQ/UncertaintyQuantification.jl#363 ·
Maintainer thường phản hồi trong vòng 1 ngày