Time for action – calculating the determinant of a matrix

To calculate the determinant of a matrix, perform the following steps:

  1. Create the matrix as follows:
    A = np.mat("3 4;5 6")
    print "A
    ", A

    The matrix we created is shown as follows:

    A
    [[ 3.  4.]
     [ 5.  6.]]
    
  2. Compute the determinant with the det function.
    print "Determinant", np.linalg.det(A)

    The determinant is shown as follows:

    Determinant -2.0
    

What just happened?

We calculated the determinant of a matrix with the det function from the numpy.linalg module (see determinant.py).

import numpy as np

A = np.mat("3 4;5 6")
print "A
", A

print "Determinant", np.linalg.det(A)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.134.29