# Determinant of block matrices edit

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 close merge delete

Hey, are you from Germany?

( 2013-11-24 08:08:14 +0100 )edit

Sort by » oldest newest most voted
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?

more

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

more

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

( 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.

( 2013-11-23 06:12:40 +0100 )edit

yes, I agree.

( 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').

( 2013-11-23 08:11:51 +0100 )edit

ah.. thanks!

( 2013-11-24 06:20:15 +0100 )edit
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.21660351753234863, "perplexity": 10115.767284360998}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2023-14/segments/1679296945292.83/warc/CC-MAIN-20230325002113-20230325032113-00350.warc.gz"}