Python: inverse of a block matrix

Click For Summary
SUMMARY

The discussion focuses on calculating the inverse of a block matrix using SymPy, specifically with the code provided for creating a block matrix Z from matrices X and a vector i. The user highlights that both Z.I and Z.inv() yield the same result for the inverse. A crucial point raised is the distinction between the vector <1, 1, 1>^T and the 3x3 identity matrix, which can be created using the eye(3) function in SymPy. The discussion emphasizes the importance of understanding block matrix structures and their inverses in matrix computations.

PREREQUISITES
  • Familiarity with SymPy 1.10 for symbolic mathematics in Python
  • Understanding of block matrices and their properties
  • Knowledge of matrix inversion techniques
  • Basic Python programming skills
NEXT STEPS
  • Explore the SymPy documentation on block matrices for advanced usage
  • Learn about matrix inversion methods in linear algebra
  • Investigate the implications of using identity matrices in matrix operations
  • Practice creating and manipulating block matrices in SymPy
USEFUL FOR

Mathematicians, data scientists, and Python developers interested in advanced matrix operations and symbolic computation using SymPy.

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).
 

Similar threads

Replies
1
Views
6K
  • · 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
10K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K