Ask Your Question

Revision history [back]

How to define *complex* symbolic variables

Hello,

I am quite new with SageMath, and I don't succeed in defining complex symbolic variables.

In the following example, SageMath seems to compute as if the variables were real (and not complex) :

 var('w_2, w_3')
T=Matrix([[norm(w_3)*(1-norm(w_2)), -conjugate(w_3)*sqrt(1-norm(w_2))*sqrt(1-norm(w_3))], [-w_3*sqrt(1-norm(w_2))*sqrt(1-norm(w_3)), 1-norm(w_3)]])
T.eigenvalues()

The output of this command is

[-w_2^2*w_3^2 + 1, 0]

whereas the expected result was

[1-norm(w_2)*norm(w_3), 0]

How can I tell SageMath that my symbolic variables are complex ones ?

Thanks in advance for your help !

How to define *complex* symbolic variables

Hello,

I am quite new with SageMath, and I don't succeed in defining complex symbolic variables.

In the following example, SageMath seems to compute as if the variables were real (and not complex) :

 var('w_2, w_3')
T=Matrix([[norm(w_3)*(1-norm(w_2)), -conjugate(w_3)*sqrt(1-norm(w_2))*sqrt(1-norm(w_3))], [-w_3*sqrt(1-norm(w_2))*sqrt(1-norm(w_3)), 1-norm(w_3)]])
T.eigenvalues()
var('w_2')
T=Matrix([[0, w_2], [0,0]])
S=T*(T.H)
S.eigenvalues()

The output of this command is

[-w_2^2*w_3^2 + 1, [w_2^2, 0]

whereas the expected result was

[1-norm(w_2)*norm(w_3), [norm(w_2), 0]

How can I tell SageMath that my symbolic variables are complex ones ?

Thanks in advance for your help !