Ask Your Question

How can I invert matrix of matrices

asked 2018-11-08 17:19:59 -0600

Richard_L gravatar image


A = matrix(SR, 2, var('a1,b1,c1,d1'))
B = matrix(SR, 2, var('a2,b2,c2,d2'))
C = matrix(SR, 2, var('a3,b3,c3,d3'))
D = matrix(2,2, [A, B, B.T, C])
D; D.is_invertible()

This gives the matrix D as a matrix of (fully expanded) matrices, and confirms that D is invertible. However:


results in

Traceback (click to the left of this block for traceback) 
AttributeError: 'MatrixSpace_with_category' object has no attribute

Seemingly, one cannot build after all a matrix of matrices, but only of basic ring elements.

Even better, I would prefer to construct a matrix of the (non-commutative, invertible) symbolic variables A, B, C, so as to eliminate the clutter of their constituent elements.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-11-09 16:57:56 -0600

dan_fulea gravatar image

Use block_matrix to insure the result is an element of $M_{4\times 4}$ (over the ring SR) and not of $M_{2\times 2}$ with entries in a matrix ring, which is a non-commutative ring, and where strictly speaking the inverse is not implemented.

For instance:

sage: D = block_matrix( 2, 2, [A, B, B.T, C] )
sage: D
[a1 b1|a2 b2]
[c1 d1|c2 d2]
[a2 c2|a3 b3]
[b2 d2|c3 d3]
sage: D.is_invertible()
sage: DI = D.inverse()

So DI could be computed and we have:

sage: (DI*D).simplify_full()
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
edit flag offensive delete link more


Thanks. Too bad inverse is not implemented for matrices over the (invertible) matrix ring.

Richard_L gravatar imageRichard_L ( 2018-11-12 16:42:52 -0600 )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

1 follower


Asked: 2018-11-08 17:19:59 -0600

Seen: 79 times

Last updated: Nov 09