In view of the large amount of linear algebra calculations in the recent review, and the 1800 answer often ignores some inverse matrix and determinant calculation answers, a simple calculation program for the matrix is written in Python to facilitate the checking of error steps.
1、 Determinant
You can change the order by yourself
from numpy import*
# Find the determinant,Suggestion: take the whole number before the decimal point
A =array([[3,1,1,1],[1,3,1,1],[1,1,3,1],[1,1,1,3]])
B = linalg.det(A)print(B)
# 48.000000000000014 Correct answer: 48
2、 Matrix multiplication
Pay attention to the same internal standard
from numpy import*
# Multiply matrices
A =array([[1,-1,1],[1,1,0],[-1,0,1]])
B =array([[3,0,0],[0,0,0],[0,0,0]])
# N=AB
N =dot(A, B)
# N=BA, then N=dot(B, A)print(N)
# correct answer:
# [300]
# [300]
# [-300]
3、 Inverse matrix
Judge for yourself |A|≠0, where A∗ = A−1 · |A|
from numpy import*
# Inverse matrix,Suggestion: take one digit after the decimal point and turn it into a fraction
A =mat([[1,-1,1],[1,1,0],[-1,0,1]])
B = A.I
print(B)
# [0.333333330.33333333-0.33333333]
# [-0.333333330.666666670.33333333]
# [0.333333330.333333330.66666667]
# 0.333 ≈ 1/3 ,0.667≈ 2/3
The above is the whole content of this article, I hope it will be helpful to everyone's study.
Recommended Posts