Determinant of a Matrix | Linear Algebra using Python

Linear Algebra using Python | Determinant of a Matrix: Here, we are going to learn about the determinant of a matrix and its implementation in Python.
Submitted by Anuj Singh, on May 29, 2020

In linear algebra, the determinant is a scalar value that can be computed for a square matrix and represents certain properties of the matrix. The determinant of a matrix A is denoted det(A) or det A or |A|. Python library numpy provides a wide range of functions that can be used to manipulate matrices. One of such functions is numpy.linalg.det(A), which allows us to directly return the value of the determinant of a matrix A.

Following is a python code for demonstrating how to use numpy.linalg.det(A)

Python code for demonstrating how to use numpy.linalg.det(A)?

# Linear Algebra Learning Sequence
# Finding determinant

import numpy as np 

M = np.array([[2,3,4], [3,45,8], [4,8,78]])
print("---Matrix A---\n", M)

det_A = np.linalg.det(M)

print("The determinant of matrix A : ", det_A)

M = np.array([[2,3,4], [3,14,8], [14,8,7]])
print("\n\n---Matrix B---\n", M)

det_B = np.linalg.det(M)

print("The determinant of matrix B : ", det_B)

Output:

---Matrix A---
 [[ 2  3  4]
 [ 3 45  8]
 [ 4  8 78]]
The determinant of matrix A :  5661.9999999999945


---Matrix B---
 [[ 2  3  4]
 [ 3 14  8]
 [14  8  7]]
The determinant of matrix B :  -347.00000000000006





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.