Gaussian Elimination - rref()
高斯消元解方程组
1 | >> A = [1 2 1;2 6 1; 1 1 4] |
LU Factorization
LU解法,将A拆解为一个下三角矩阵和一个上三角矩阵乘积
下三角矩阵对角线都为1 上半三角都为0
上三角矩阵对角线无所谓,下半三角都为0
How to Obtain L and U?
- the matrices L and U are obtained by using a serious of left-multiplication
LU Factorization - lu()
1 | A = [1 1 1; 2 3 5; 4 6 8]; |
Matrix Left Division: \ or mldivide()
- Solving systems of linear equations Ax = b using factorization methods:
一定要用左除1
2
3
4
5
6
7
8
9
10
11
12
13
14
15>> A = [1 2 1;2 6 1;1 1 4];
b = [2; 7; 3];
x = A\b
x =
-3.0000
2.0000
1.0000
>> x = b/A
错误使用 /
矩阵维度必须一致。
>>
Cramer’s(Inverse) Method
1 | A = [1 2 1; 2 6 1; 1 1 4]; |
Singular
- The inverse matirx does not exist
当矩阵的解有无限多或者无解时候,那么这个矩阵就不存在逆inv(A)
同时,det(A) = 0
Problem with Cramer’s Method
- the accuracy is low when the determinant is very close to zero(det(A) ~ 0)
Eigenvalues and Eigenvectors
eig()
- Find the eigenvalues and eigenvectors:
1 | [v, d] = eig([2 -12; 1 -5]) |