Ask Your Question
2

How can I invert matrix of matrices

asked 2018-11-09 00:19:59 +0200

Richard_L gravatar image

Consider:

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:

D.inverse()

results in

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

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
1

answered 2018-11-09 23:57:56 +0200

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()
True
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

Comments

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

Richard_L gravatar imageRichard_L ( 2018-11-12 23:42:52 +0200 )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

Stats

Asked: 2018-11-09 00:19:59 +0200

Seen: 8,669 times

Last updated: Nov 09 '18