Download presentation
Presentation is loading. Please wait.
Published byMarvin Phillips Modified over 9 years ago
1
數值方法, Applied Mathematics NDHU 1 Linear system
2
數值方法, Applied Mathematics NDHU 2 Linear system
3
數值方法, Applied Mathematics NDHU 3 m=n If A is invertible
4
數值方法, Applied Mathematics NDHU 4 inv >> A=rand(5,5);b=rand(5,1); >> x=inv(A)*b x = -2.2355 9.2038 -7.0138 -2.8158 13.3273
5
數值方法, Applied Mathematics NDHU 5 Naive Gaussian elimination Direct method Analytic approach Naive Gaussian elimination Iterative method Jacobi method Gauss-Seidel method SOR method
6
數值方法, Applied Mathematics NDHU 6 Forward elimination r1*(-2)+r2 r1*(-1/2)+r3 r1+r3 r2*(-3)+r3 r2*(1/2)+r4 r3*(-2)+r4
7
數值方法, Applied Mathematics NDHU 7 Triangular linear system
8
數值方法, Applied Mathematics NDHU 8 Backward substitution
9
數值方法, Applied Mathematics NDHU 9 Procedure : Naive forward elimination Input a square matrix A,b Set n to the row number of A B=[A b] for i=1 to n for j = i+1 to n Set c to the ratio B(j,i) / B(i,i) Set v to the product of c and the ith row of B Subtract v from the jth row of B Return B
10
數值方法, Applied Mathematics NDHU 10 B=Gauss_eli(A,b) for i=1:n-1 for j=i+1:n n=length(b); B=[A b]; exit c=B(j,i)/B(i,i) B(j,:)=B(j,:)-c*B(i,:)
11
數值方法, Applied Mathematics NDHU 11 Procedure : Backward substitution input an upper triangle matrix U and a column vector b set n to the row number of U for i = n to 1 set v to b(i) for j = n to i+1 subtract the product of U(i,j) and x(j) from v set x(i) to v/U(i,i)
12
數值方法, Applied Mathematics NDHU 12 x=backward_sub(U,b) for i=n:-1:1 for j=n:-1:i+1 n=length(b); exit v=v-U(i,j)*x(j) v=b(i) x(i)=v/U(i,i)
13
數值方法, Applied Mathematics NDHU 13 Exercise Implement naive forward elimination and backward substitution for solving a linear system Give two examples to test your matlab codes
14
數值方法, Applied Mathematics NDHU 14 m > n The size of unknowns in a linear system is less than the number of linear constraints.
15
數值方法, Applied Mathematics NDHU 15
16
數值方法, Applied Mathematics NDHU 16 A = 0.9501 0.6154 0.0579 0.2311 0.7919 0.3529 0.6068 0.9218 0.8132 0.4860 0.7382 0.0099 0.8913 0.1763 0.1389 0.7621 0.4057 0.2028 0.4565 0.9355 0.1987 0.0185 0.9169 0.6038 0.8214 0.4103 0.2722 0.4447 0.8936 0.1988 b = 0.7273 -0.7687 0.1832 -0.4946 1.5690 0.9155 -0.7593 -1.1930 1.0945 -0.6991
17
數值方法, Applied Mathematics NDHU 17 Least square errors
18
數值方法, Applied Mathematics NDHU 18 Minimization
19
數值方法, Applied Mathematics NDHU 19 Derivation
20
數值方法, Applied Mathematics NDHU 20
21
數值方法, Applied Mathematics NDHU 21
22
數值方法, Applied Mathematics NDHU 22
23
數值方法, Applied Mathematics NDHU 23
24
數值方法, Applied Mathematics NDHU 24 Solving linear systems with m>n Input paired data Form matrix A and vector b Set x1 to pinv(A)*b Set x2 to
25
數值方法, Applied Mathematics NDHU 25 >> A=rand(30,2);b=rand(30,1); >> x1=pinv(A)*b; >> x2=inv(A'*A)*(A'*b); >> sum(abs(x1-x2)) ans = 1.0547e-015
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.