ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 03 Dec 2013 20:45:25 +0100symbolic 2x2 block matrix inversionhttps://ask.sagemath.org/question/10799/symbolic-2x2-block-matrix-inversion/Is it possible in SAGE to get the 2x2 block matrix inversion described in [Wikipedia](https://en.wikipedia.org/wiki/Block_matrix_pseudoinverse#Block_matrix_inversion)?
I looked at [this question](http://ask.sagemath.org/question/3245/determinant-of-block-matrices) about the determinant of block matrices, and at [this question](http://ask.sagemath.org/question/505/symbolic-matrices) about symbolic matrices, and tried the following code on the [cloud](http://www.sagenb.org/):
A = matrix(SR, 2, 2, 'a1 a2 a3 a4'.split(' '))
B = matrix(SR, 2, 2, 'b1 b2 b3 b4'.split(' '))
C = matrix(SR, 2, 2, 'c1 c2 c3 c4'.split(' '))
D = matrix(SR, 2, 2, 'd1 d2 d3 d4'.split(' '))
M = block_matrix(SR, 2, 2, [A, B, C, D])
Mi = M.inverse()
Mi.simplify_rational()
But it doesn't seem to be able to exactly reproduce the Wikipedia formula (it returns a horrible formula full of a1, a2, etc). Any idea?Tue, 03 Dec 2013 17:05:46 +0100https://ask.sagemath.org/question/10799/symbolic-2x2-block-matrix-inversion/Answer by kcrisman for <p>Is it possible in SAGE to get the 2x2 block matrix inversion described in <a href="https://en.wikipedia.org/wiki/Block_matrix_pseudoinverse#Block_matrix_inversion">Wikipedia</a>?</p>
<p>I looked at <a href="http://ask.sagemath.org/question/3245/determinant-of-block-matrices">this question</a> about the determinant of block matrices, and at <a href="http://ask.sagemath.org/question/505/symbolic-matrices">this question</a> about symbolic matrices, and tried the following code on the <a href="http://www.sagenb.org/">cloud</a>:</p>
<pre><code>A = matrix(SR, 2, 2, 'a1 a2 a3 a4'.split(' '))
B = matrix(SR, 2, 2, 'b1 b2 b3 b4'.split(' '))
C = matrix(SR, 2, 2, 'c1 c2 c3 c4'.split(' '))
D = matrix(SR, 2, 2, 'd1 d2 d3 d4'.split(' '))
M = block_matrix(SR, 2, 2, [A, B, C, D])
Mi = M.inverse()
Mi.simplify_rational()
</code></pre>
<p>But it doesn't seem to be able to exactly reproduce the Wikipedia formula (it returns a horrible formula full of a1, a2, etc). Any idea?</p>
https://ask.sagemath.org/question/10799/symbolic-2x2-block-matrix-inversion/?answer=15508#post-id-15508I think the whole point is that you are asking for a full inverse. So Sage is trying to invert all the individual A, B, etc. Sage's block matrices don't behave differently from regular matrices in this regard, presumably. Perhaps someone else will have other ideas, though.Tue, 03 Dec 2013 20:45:25 +0100https://ask.sagemath.org/question/10799/symbolic-2x2-block-matrix-inversion/?answer=15508#post-id-15508