线性回归方程式与线性系统

Gaussian Elimination - rref()

高斯消元解方程组

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
>> A = [1 2 1;2 6 1; 1 1 4]

A =

1 2 1
2 6 1
1 1 4

>> b = [2; 7; 3]

b =

2
7
3

>> R = rref([A b])

R =

1 0 0 -3
0 1 0 2
0 0 1 1

>>

LU Factorization

LU解法,将A拆解为一个下三角矩阵和一个上三角矩阵乘积

1

下三角矩阵对角线都为1 上半三角都为0

上三角矩阵对角线无所谓,下半三角都为0

1

How to Obtain L and U?

  • the matrices L and U are obtained by using a serious of left-multiplication

1

LU Factorization - lu()

1
2
A = [1 1 1; 2 3 5; 4 6 8];
[L, U, P] = lu(A);

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
2
3
A = [1 2 1; 2 6 1; 1 1 4];
b = [2; 7; 3];
x = inv(A)*b

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])
Donate? comment?