Course Solutions Uncategorized (Solved) : Check Python Code Whether Todo 1 2 3 Work Correctly Change Linear Algbra 2018 Assignment Q32731102 . . . .

(Solved) : Check Python Code Whether Todo 1 2 3 Work Correctly Change Linear Algbra 2018 Assignment Q32731102 . . . .

 

Check my python code below whether “TODO 1,2,3” canwork correctly.If not,change it for me.

#Linear Algbra 2018 Assignment 2
from hw2_105000120_myfun import mydet, mysolve_cramer,mysolve_adj

import numpy as np
from datetime import datetime

A = np.array([[1,-1,-1,0,0,0,0,0,0,0],
[0,0,1,-1,-1,0,0,0,0,0],
[0,0,0,0,1,-1,-1,0,0,0],
[0,0,0,0,0,0,1,-1,-1,0],
[2,6,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,-1],
[0,-2,2,2,0,0,0,0,0,0],
[0,0,0,-2,2,2,0,0,0,0],
[0,0,0,0,0,-2,2,2,0,0],
[0,0,0,0,0,0,0,-2,2,2]])

b = np.array([[0],[0],[0],[0],[10],[0],[0],[0],[0],[0]])
n = A.shape[0]

# compute the determinant of A using numpy
print(np.linalg.det(A))

# compute the determinant of A using mydet
### your code write in hw2_StudentID_myfun.py (“mydet” function)###
print(mydet(A))

# solve the linear system and measure the execution time
tStart = datetime.now()
x = np.linalg.solve(A, b)
tEnd = datetime.now()
print(“Time to solve Ax=b is “, tEnd-tStart, ” seconds.”)

# check the correctness
res = np.subtract(np.dot(A, x), b)
print(res)

# TODO 1. solve Ax=b using adjoint matrix (using mydet)
### your code write in hw2_StudentID_myfun.py

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post