Ask Your Question
0

How to define *complex* symbolic variables

asked 1 year ago

endomorphisme59 gravatar image

updated 1 year ago

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')
T=Matrix([[0, w_2], [0,0]])
S=T*(T.H)
S.eigenvalues()

The output of this command is

[w_2^2, 0]

whereas the expected result was

[norm(w_2), 0]

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

Thanks in advance for your help !

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 1 year ago

eric_g gravatar image

updated 1 year ago

Like this:

var('w_2', domain='complex')

The output of your code then becomes:

[w_2*conjugate(w_2), 0]
Preview: (hide)
link

Comments

Thank you :)

endomorphisme59 gravatar imageendomorphisme59 ( 1 year ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 1 year ago

Seen: 560 times

Last updated: Oct 19 '23