-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error trying to differentiate through a Complex
#239
Comments
Crossref: #157 f(z) = z*z*z -1
const g = realify(f)
g(SVector(1.0, 2.0))
using ForwardDiff
ForwardDiff.jacobian(g, SVector(1.0, 2.0)) that works. |
Thanks. What's the issue with |
z = ForwardDiff.Dual{ForwardDiff.Tag{nothing,0xb81c941840f92fc0}}(1.0,1.0,0.0) +
ForwardDiff.Dual{ForwardDiff.Tag{nothing,0xb81c941840f92fc0}}(2.0,0.0,1.0)*im
z^3 is an MWE, but it was surprisingly uninformative. More informative is: z = ForwardDiff.Dual{ForwardDiff.Tag{nothing,0xb81c941840f92fc0}}(1.0,1.0,0.0) +
ForwardDiff.Dual{ForwardDiff.Tag{nothing,0xb81c941840f92fc0}}(2.0,0.0,1.0)*im
a = 3
z^Complex(a) is doing zz,aa = (promote(z,a)...)
convert(Integer, aa) which errors. So the "true MWE" is: aa = ForwardDiff.Dual{ForwardDiff.Tag{nothing,0xb81c941840f92fc0}}(3.0,0.0,0.0) + ForwardDiff.Dual{ForwardDiff.Tag{nothing,0xb81c941840f92fc0}}(0.0,0.0,0.0)*im
convert(Integer, aa) It's the promotion then the conversion to an integer which fails. |
z = ForwardDiff.Dual{ForwardDiff.Tag{nothing,0xb81c941840f92fc0}}(1.0,1.0,0.0)
z^a
@which z^a brings me here: https://github.com/JuliaDiff/ForwardDiff.jl/blob/master/src/dual.jl#L100 So it looks like in the real case they had to work around this with: https://github.com/JuliaDiff/ForwardDiff.jl/blob/master/src/dual.jl#L367 That would need to be extended to complex. |
The This is a problem with Base's The While in practice this problem can just be solved by fixing While such an assumption may seem naively sensible, it is untenable in practice for a language where subtype relations are purely nominal set relations (at least until we can define types like Of course, this issue is a poster child for why you shouldn't use argument-based overloading to inject/propagate metadata through native Julia code. Time to get back to work on Cassette.jl... 😄 |
Not sure if it's related or not, but I tried a complexification of the example in the manual:
That gives me a StackOverflow
This is because
|
Do I understand correctly that this is the same issue which prevents me using JuMP minimizer involving complex functions? In the code below, I look for zeros of the complex function minimizing abs value.
Error:
Is there any workaround? |
I need to treat a complex function
f: C → C
as a function from R^2 to R^2. I am doing this as follows:When I try to differentiate this, I get the following error:
The text was updated successfully, but these errors were encountered: