Ask Your Question
0

Determinant of block matrices

asked 2013-11-22 19:45:41 -0600

kautschuk gravatar image

I need to calculate the determinant of a symbolic 4x4 matrix M, where each cell itself is a matrix itself.

Is that possible?

I did a beginner's check, and it did not seem to work:

mq=matrix(SR, 2, 2, 'a b c d'.split(' '))
MQ=matrix(SR, 2, 2, [mq, mq, mq, mq])
MQ.det()

Traceback (click to the left of this block for traceback)
...
TypeError: mutable matrices are unhashable
edit retag flag offensive close merge delete

Comments

Hey, are you from Germany?

gundamlh gravatar imagegundamlh ( 2013-11-24 01:08:14 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-11-22 22:17:00 -0600

tmonteil gravatar image

updated 2013-11-22 23:17:19 -0600

You are not defining a block matrix, but a 2 by 2 matrix whose entries are 2 by 2 martices over the symbolic ring. Indeed:

sage: MQ.parent()
Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring

Moreover, there is a kind of contradiction, since you ask the base ring to be SR but your entries are in the set of 2 by 2 martices over SR. If you remove this contradiction, you get:

sage: MQ=matrix(2, 2, [mq, mq, mq, mq])
sage: MQ.parent()
Full MatrixSpace of 2 by 2 dense matrices over Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring
sage: MQ.det()
[0 0]
[0 0]

To define a block matrix (so that sage understands that it is a 4 by 4 matrix over SR), you should do:

sage: MQ=matrix.block(2,2,[mq, mq, mq, mq])
sage: MQ
[a b|a b]
[c d|c d]
[---+---]
[a b|a b]
[c d|c d]
sage: MQ.parent()
Full MatrixSpace of 4 by 4 dense matrices over Symbolic Ring
sage: MQ.det()
0
edit flag offensive delete link more

Comments

>mq = matrix(SR, 2, 2, 'a b c d'.split(' '))<, the variables "a, b, c, d" do not appear in workspace, why?

gundamlh gravatar imagegundamlh ( 2013-11-22 22:39:25 -0600 )edit

There is no reason to inject the symbolic variable `a` in the python variable `a`. If i write `print('a')`, this will not inject the string `'a'` into the python variable `a`.

tmonteil gravatar imagetmonteil ( 2013-11-22 23:12:40 -0600 )edit

yes, I agree.

gundamlh gravatar imagegundamlh ( 2013-11-22 23:18:32 -0600 )edit

By the way, if you want to deal with a symbolic variable `a` but not inject it in the python variable `a`, you can do `SR.var('a')` instead of `var('a')`.

tmonteil gravatar imagetmonteil ( 2013-11-23 01:11:51 -0600 )edit

ah.. thanks!

gundamlh gravatar imagegundamlh ( 2013-11-23 23:20:15 -0600 )edit
0

answered 2013-11-22 22:35:14 -0600

gundamlh gravatar image
sage: mq = matrix(SR, 2, 2, 'a b c d'.split(' '))
sage: MQ = block_matrix(SR, 2, 2, [mq, mq, mq, mq]); MQ
[a b|a b]
[c d|c d]
[---+---]
[a b|a b]
[c d|c d]
sage: MQ.det()
0

Is it what you want?

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: 2013-11-22 19:45:41 -0600

Seen: 425 times

Last updated: Nov 22 '13