`conj` of `Expression` silently ignored
baggepinnen opened this issue · 9 comments
Hello! I found a potential bug when calling conj
on a complex expression
julia> b[1]*im
im*b₁
julia> conj(b[1]*im)
im*b₁
the expected result would be
julia> conj(b[1]*im)
-im*b₁
This is intentional (see also #402). Complex conjugation is not algebraic and by defining it correctly we could not use any of the default linear algebra methods like dot
I'm not sure I understand, if the package doesn't support conj
, wouldn't an error be more appropriate than returning the wrong result?
Yes I'm not sure I understand, why does this not error?
Yes I'm not sure I understand, why does this not error?
Hi @ChrisRackauckas, the motivation for this is that on computational algebraic geometry one often encounters expressions like dot(f,g)
.
Furthermore, even if we defined conj( x* im) = -im * x
, dot(f,g)
will still not give the Hermitian inner product of f
and g
, because variables are not conjugated. This is, in fact, not possible to implement, since complex conjugation is not algebraic and so this case would not be covered by our algorithms.
Nevertheless, I see your point that it can cause confusion. In what context do you encounter this issue?
I'm seeing reports of HomotopyContinuation giving wrong values. It seems if there's an issue with supporting complex numbers due to this that you should just error if complex conjugation is used, rather than giving the wrong result.
Erroring if complex conjugation is used is not an option, because then we would not be able to use dot
. A warning could be an option.
Can you specify where the errors are reported? I'm sure users wanted to use Hermitian inner product, but this is not algebraic and can't be solved (this is a theoretical obstruction!)
Erroring if complex conjugation is used is not an option, because then we would not be able to use dot. A warning could be an option.
That's unrelated. Why not make the error dispatch only for Complex?
This might work when implementing dot
directly (note that Expression
is <: Number
). But, let me check if this would break anything else...
A warning message would not be a solution?
By the way, if you receive errors reports please invite people to send me an email. There could also be other reasons fpr errors and I am happy to help.