Ask Your Question
0

How to define *complex* symbolic variables

asked 2023-10-19 10:12:14 +0100

endomorphisme59 gravatar image

updated 2023-10-19 10:49:10 +0100

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 !

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-10-19 11:06:04 +0100

eric_g gravatar image

updated 2023-10-19 11:08:32 +0100

Like this:

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

The output of your code then becomes:

[w_2*conjugate(w_2), 0]
edit flag offensive delete link more

Comments

Thank you :)

endomorphisme59 gravatar imageendomorphisme59 ( 2023-10-19 13:56:35 +0100 )edit

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: 2023-10-19 10:12:14 +0100

Seen: 425 times

Last updated: Oct 19 '23