Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

T-Mobile Wi-Fi 11:50 PM blackboard.ncat.eduu #-The following code imports a matr

ID: 3586233 • Letter: T

Question

T-Mobile Wi-Fi 11:50 PM blackboard.ncat.eduu #-The following code imports a matrix from the file mat.npy and stores it as mat1. #-lt also imports a vector from vect.npy and stores it as vect1. mat 1 = np. load( ' mat . npy ' ) mat1 = vect 1 = np. load( ' vect. npy ' ) vect1 = vect1.astype(np. float 64) print('This is a positive definite matrix A matl, 'In and this is a vector b ',vectl) mat1.astype (np.float64) def determinant (A, nargout-1): #Replace this comment with code #-write a recursive function to compute the #_ https://www.python- #-the function should work for sau are matrice determinnat of an nxn matrix A course.eu/recursive functions.php of any slze return(d)

Explanation / Answer

import numpy as np
import math

def determinant(A,nergout=1):
    d = 0;

    if (nergout==1):
       return A[0,0]

    B1=np.copy(A)
    B1=np.delete(B1, (0), axis=0)
    for i in range(0,nergout):
        B=np.copy(B1)
        B=np.delete(B, (i), axis=1)
        d += pow(-1,i)*A[0,i]*determinant(B,nergout-1)

    return d

x = np.array([[6,1,1],
        [4,-2,5],
        [2,8,7]])

print(determinant(x,3))