Ask Your Question
0

Determinant of block matrices

asked 2013-11-23 02:45:41 +0100

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 08:08:14 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-11-23 05:17:00 +0100

tmonteil gravatar image

updated 2013-11-23 06:17:19 +0100

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-23 05:39:25 +0100 )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-23 06:12:40 +0100 )edit

yes, I agree.

gundamlh gravatar imagegundamlh ( 2013-11-23 06:18:32 +0100 )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 08:11:51 +0100 )edit

ah.. thanks!

gundamlh gravatar imagegundamlh ( 2013-11-24 06:20:15 +0100 )edit
0

answered 2013-11-23 05:35:14 +0100

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-23 02:45:41 +0100

Seen: 1,039 times

Last updated: Nov 23 '13