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

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.