Ask Your Question

How to define *complex* symbolic variables

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

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


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) :

T=Matrix([[0, w_2], [0,0]])

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

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

eric_g gravatar image

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

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


Thank you :)

endomorphisme59 gravatar imageendomorphisme59 ( 2023-10-19 13:56:35 +0200 )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


Asked: 2023-10-19 10:12:14 +0200

Seen: 140 times

Last updated: Oct 19 '23