Python Python: inverse of a block matrix

Click For Summary
The discussion revolves around using Sympy to compute the inverse of a block matrix. The user shares code that creates a block matrix Z using a vector and a matrix, but seeks clarification on how to correctly compute its inverse. They mention using both Z.I and Z.inv(), noting that both yield the same result. A key point raised is the distinction between the vector used (a column matrix of ones) and an identity matrix, suggesting that to create an identity matrix, one should use the eye function. The conversation encourages checking the Sympy documentation for further examples and clarification on block matrices.
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.
 
Technology 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).
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

Replies
1
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
9K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K