Ask Your Question
1

How do I enter an imaginary number into a matrix

asked 2016-02-25 05:43:08 +0200

Chisx gravatar image

In a very simple example, I am created a 2 by 2 matrix like this

var('i')
ran40 = matrix(QQ,2,2,[[2*i,-2],[3,4]])
show(ran40)

I need to eventually call show(ran40.rref()) so that I can see the reduced row echelon form of the above matrix. But I get syntax errors in the creation of the matrix above.

How do I simply put the imaginary letter i into a matrix and then it actually be computed on. That is, the imaginart "part" is actually used in the RREF computation.

edit retag flag offensive close merge delete

Comments

See also the question (and answer) at http://stackoverflow.com/questions/35...

kcrisman gravatar imagekcrisman ( 2016-02-25 15:47:49 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-02-25 12:14:21 +0200

tmonteil gravatar image

updated 2016-02-25 12:14:38 +0200

When you write var('i'), you define i as a symbol. In particular, 2*i is an element of the symbolic ring, not the rationals, but you ask that 2*i be an entry of a matrix whose coefficients are rationals (because of the QQ at the beginnig).

If you want the imaginary number, you should use the already defined I, if you want a matrix over, say the algabraic numbers QQbar (so that I in an element), you should write:

sage: matrix(QQbar,2,2,[[2*I,-2],[3,4]])
[2*I  -2]
[  3   4]
edit flag offensive delete link more

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: 2016-02-25 05:43:08 +0200

Seen: 1,117 times

Last updated: Feb 25 '16