Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 results 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?

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 results 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?

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?

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?