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/solving sqrt(-1) to a real numberhttps://ask.sagemath.org/question/8762/solving-sqrt-1-to-a-real-number/Here is what I am trying to do:
var('x')
A(x)=x/2+(4-x*x)^(1/2)
assume(0<x<2)
maximum = (derivative(A)==0).maxima_methods().rootscontract().simplify()
view(maximum)
view(solve(maximum,x))
A.plot(A,0,2)
and get i multiplied by the root of x^2... if I put the same equation into wolfram, it gives me a real number 2/sqrt(5) (which is correct and makes sense).
How can I make SageMath solve those? I tried simplify() and full_simplify(), maxima_methods() and rootscontract() gives an error in combination with solve().
I guess it's just some syntax error, sorry for that :(
For now I do most in the Sage - Cell Server, which is great.disiThu, 01 Mar 2012 09:26:06 +0100https://ask.sagemath.org/question/8762/