Compute pivoted LU decomposition of a Matrix
LU decomposition is a method that reduce matrix into constituent parts that helps in easier calculation of complex matrix operations. The decomposition methods are also called matrix factorization methods, are base of linear algebra in computers, even for basic operations such as solving systems of linear equations, calculating the inverse, and calculating the determinant of a matrix. The decomposition is: A = P L U where P is a permutation matrix, L lower triangular with unit diagonal elements, and U upper triangular.
Python3
P, L, U = linalg.lu(A) print (P) print (L) print (U) # print LU decomposition print (np.dot(L,U)) |
Output:
[[0. 1. 0.]
[0. 0. 1.]
[1. 0. 0.]]
[[1. 0. 0. ]
[0.14285714 1. 0. ]
[0.57142857 0.5 1. ]]
[[7. 8. 8. ]
[0. 0.85714286 1.85714286]
[0. 0. 0.5 ]]
[[0.14285714 1. 0. ]
[0.57142857 0.5 1. ]
[1. 0. 0. ]]
Data Analysis with SciPy
Scipy is a Python library useful for solving many mathematical equations and algorithms. It is designed on the top of Numpy library that gives more extension of finding scientific mathematical formulae like Matrix Rank, Inverse, polynomial equations, LU Decomposition, etc. Using its high-level functions will significantly reduce the complexity of the code and helps better in analyzing the data.
In this article, we will explore What is SciPy, the Installation of SciPy, and How Data Analysis with SciPy works and Compute pivoted LU decomposition.
Table of Content
- What is SciPy?
- Installation of SciPy
- How does Data Analysis work with SciPy?
- Import SciPy
- Linear Algebra
- Compute pivoted LU decomposition of a Matrix
- Eigen values and Eigen vectors of this matrix
- Sparse Linear Algebra
- Linear Algebra for Sparse Matrices