Bug with absolute value of a complex variable?
I perform some analytic calculations involving complex number, in particular complex electric field amplitude. I was quite shocked when I discovered how SAGE handles complex variables. So, I define a new variable "A" and explicitly say that it is complex. Then I want to find the absolute value of this variable, which is $AA^* = |A|^2$.
sage: var("A", domain="complex")
sage: A*A.conjugate()
A*conjugate(A) # not bad
sage: _.simplify()
A^2 # THIS IS WRONG!
Furthermore we check, if $AA = |A|^2 = AA^*$, and it does!
sage: A*A.conjugate() - A*A # Substract squared A from absolute value of A
-A^2 + A*conjugate(A)
sage: _.simplify()
0 # So SAGE assumes that they are equal
But this is obviously WRONG, since if I assign some number to $A$, then the last test does not result in zero:
sage: A=3+4*i
sage: A*A.conjugate() - A*A
-24*I + 32 # It's not ZERO anymore!
Am I understanding/doing something wrong?
Thanks for asking this question. I had a similar problem in the latest release and this problem persists. Fortunately the workaround suggested by calc314 works.