ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 23 Feb 2013 15:38:37 +0100Bug with absolute value of a complex variable?https://ask.sagemath.org/question/9838/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?ximegSat, 23 Feb 2013 15:38:37 +0100https://ask.sagemath.org/question/9838/