Repository navigation
Conversation
real, imag and conj are real-linear, so they act on every part of a hyperdual whose parts are complex (the derivatives of a complex function of real parameters). real and imag of a real hyperdual are h and 0. sincos computes sin and cos from one sincos of the value, sharing b*c. Closes JuliaDiff#38. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #38.
real,imag,conjforHyper{<:Complex}, applied to every part. A hyperdual with complex parts holds the value and the first and second derivatives of a complex function of real parameters: the ε₁ and ε₂ directions are real perturbations. These three maps are real-linear, so ∂(real f)/∂x = real(∂f/∂x), and the same forimagandconj. That they are not holomorphic in the complex argument does not matter here, because that is not what the ε parts differentiate. The comment that explained their absence is replaced by one onabsandangle, which stay undefined.realandimagforHyper{<:Real}:handzero(h), so generic code that calls them works on real hyperduals too.Base.sincos(h::Hyper): previously the generic fallback calledsinandcosseparately, each with its ownsincosof the value. Now onesincosof the value gives both results, and the productb*cis shared.sinandcosare unchanged.Tests in
test/test_complex_parts.jl:real,imagandconj;real(h) + im*imag(h) == h;real ∘ ffor a complexfof a real argument, against finite differences;sincosagainst the derivative formulas, on real and complex hyperduals.The full suite passes locally (Julia 1.13).
Motivation: FinancialFFT.jl differentiates Fourier pricing methods generically over number types, and currently carries these overloads as hooks in its HyperDualNumbers extension.
🤖 Generated with Claude Code