Python | Sign and Natural Logarithm of Determinant of a Matrix

Here, we are going to learn about the sign and natural logarithm of determinant of a matrix and their Python implementation.
Submitted by Anuj Singh, on July 17, 2020

In this article, we are going to find the natural logarithm and sign of the Determinant of a Matrix using a single function numpy.linalg.slogdet(a). It returns a tuple in order of (sign and log(det)).

Example: The determinant of a 2-D array [[a, b], [c, d]] is ad - bc

Python code for sign and natural logarithm of determinant of a matrix

# Linear Algebra Learning Sequence
# Sign and Log of Determinant

import numpy as np

a = np.array([[1, 2], [3, 4]])
(sign, logdet) = np.linalg.slogdet(a)

print('Matrix : ', a)
print('Sign of Determinant : ', sign)
print('Logarithm of Determinant : ', logdet)

Output:

Matrix :  [[1 2]
 [3 4]]
Sign of Determinant :  -1.0
Logarithm of Determinant :  0.6931471805599455


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.