Python: inverse of a block matrix

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 4K views
sifatraquib
Messages
1
Reaction score
0
TL;DR
SymPy and NumPy are returning the BlockMatrix raised to negative one.
I am using the following code. It's returning the block matrix (Z) raised to negative one (think about inputting 22/7 in a Casio fx-991ES PLUS).

Python:
import sympy as sp

from IPython.display import display

X = sp.Matrix([[1, 1, 1], [2, 2, 2], [3, 3, 3]])

i = sp.Matrix([[1], [1], [1]])

Z = sp.BlockMatrix([[i.T*i, i.T*X], [X.T*i, X.T*X]])

Z_inv = Z.I

display(i, X, Z, Z_inv)

Could someone please tell how I can do this right now?

Note that I have used both Z.I and Z.inv(). They return the same thing.
 
Physics news on Phys.org
sifatraquib said:
I am using the following code.
Python:
i = sp.Matrix([[1], [1], [1]])
This isn't an identity matrix -- it's just the vector <1, 1, 1>^T.
To get the 3x3 identity matrix, use I = eye(3).