1
Systems of Linear Equations
The purpose of computing is insight, not numbers. Richard Wesley Hamming
Systems of Linear Equations The purpose of computing is insight, not - - PowerPoint PPT Presentation
Systems of Linear Equations The purpose of computing is insight, not numbers. Richard Wesley Hamming 1 Problem Description: 1/2 Solving systems of linear equations is one of the most important tasks in numerical methods. The i -the
1
The purpose of computing is insight, not numbers. Richard Wesley Hamming
2
a11x1 + a12x2 + a13x3 + …… + a1nxn = b1 a21x1 + a22x2 + a23x3 + …… + a2nxn = b2
………………………………………
an1x1 + an2x2 + an3x3 + …… + annxn = bn
3
n n n n nn n n 11 12 1 21 22 2 1 2 1 2 1 2
4
5
6
×(-2)+ ×(-3)+
x is eliminated from equations 2 and 3
7
×(-5/3)+
y is eliminated from equation 3 Equation 2 only has z!
8
9
a a a a a a a a a a a a a
i i n i i i i i n i i i i i n n i n i n n 11 1 1 1 1 1 1 1 1 1 1
, , , , , , , , , ,
+ + + + + + +
×(-ai+1,i/ai,i)+ ×(-an,i/ai,i)+
10
a a a a a a a a a a
i i n i i i i i n i i i n n n 11 1 1 1 1 1 1 1 1
, , , , , , , + + + + +
i i i i i i i n n n , , ,
+ +
1 1
11
i i i i i i i n n n , , ,
+ +
1 1
x a b a x
i i i i i k k k i n
= − ⎛ ⎝ ⎜ ⎞ ⎠ ⎟
= +
1
1 , ,
DO i = n, 1, -1 ! Going backward S = b(i) ! Initial S to b(i) DO k = i+1, n ! Sum all terms to the right S = S – a(i,k)*x(k) ! of a(i,i) END DO x(i) = S/a(i,i) ! Compute x(i) END DO
12
DO i = 1, n-1 ! Using row i, i.e., a(i,i) DO k = i+1, n ! We want to eliminate a(k,i) S = -a(k,i)/a(i,i) DO j = i+1, n ! for each entry on row k a(k,j) = a(k,j) + S*a(i,j) ! update its value END DO a(k,i) = 0 ! kill a(k,i) b(k) = b(k) + S*b(i) END DO ! Don’t forget to update b(k) END DO
a a a a a a a a
i i i i i j i n k i k i k j k n , , , , , , , ,
+ +
1 1
13
14
Fixing i, the inner-most j loop executes n-i times, and uses n-i multiplications. One more is needed to update bk. Therefore, the total is n-i+1. Since k goes from i+1 to n and the inner-most j loop executes n-i times, there are (n-i)(n-i+1) multiplications. Since i goes from 1 to n-1, the total is
DO i = 1, n-1 DO k = i+1, n S = -a(k,i)/a(i,i) DO j = i+1, n a(k,j) = a(k,j) + S*a(i,j) END DO a(k,j) = 0 b(k) = b(k) + S*b(i) END DO END DO
( )( ) n i n i
i n
− − +
= −
1
1 1
15
1 2 1 2 1 + + = +
n
n n ( )
1 2 3 1 6 2 3
2 2 2 2 3 2
+ + + + = + +
n
n n n
i n i n i n
− − = − = −
2 1 1 3 1 1 1 1
16
( ) ( ) n i n n
i n
− = −
= −
1 1
1 2 1
17
, , ,
i i i j j j i n
= ≠
1
(for every i)
18
19
a a a a a a a a a a a a a
i i n i i i i i n i i i i i n n i n i n n 11 1 1 1 1 1 1 1 1 1 1
, , , , , , , , , ,
+ + + + + + +
find the maximum here followed by a swap
20
DO i = 1, n-1 ! Going through rows i+1 to n Max = i ! Assume |a(i,i)| is the max DO k = i+1, n ! Find the largest in Max IF (ABS(a(Max,i)) < ABS(a(k,i)) Max = k END DO DO j = i, n ! Swap row Max and row i swap a(Max,j) and a(i,j) END DO swap b(Max) and b(i) ! Don’t forget to swap b(i) … do the elimination step … END DO
21
1 -2 3 1 3
3 -2 1 5 7 1 -1 5 3 8 A b 3 -2 1 5 7
1 -2 3 1 3 1 -1 5 3 8 A b
×(2/3)+ ×(-1/3)+ ×(-1/3)+
3 -2 1 5 7 0 -1/3 -4/3 7/3 2/3 0 -4/3 8/3 -2/3 2/3 0 -1/3 14/3 4/3 17/3 A b
row swap elimination
22
3 -2 1 5 7 0 -1/3 -4/3 7/3 2/3 0 -4/3 8/3 -2/3 2/3 0 -1/3 14/3 4/3 17/3 A b 3 -2 1 5 7 0 -4/3 8/3 -2/3 2/3 0 -1/3 -4/3 7/3 2/3 0 -1/3 14/3 4/3 17/3 A b
×(-1/4)+ ×(-1/4)+
3 -2 1 5 7 0 -4/3 8/3 -2/3 2/3 0 0
0 0 4 3/2 11/2 A b
row swap elimination
23
3 -2 1 5 7 0 -4/3 8/3 -2/3 2/3 0 0
0 0 4 3/2 11/2 A b 3 -2 1 5 7 0 -4/3 8/3 -2/3 2/3 0 0 4 3/2 11/2 0 0
A b
×(1/2)+
3 -2 1 5 7 0 -4/3 8/3 -2/3 2/3 0 0 4 3/2 11/2 0 0 0 13/4 13/4 A b
row swap elimination x1 = x2 = x3 = x4 = 1
24
25
a a a a a a a a a a a a a
i i n i i i i i n i i i i i n n i n i n n 11 1 1 1 1 1 1 1 1 1 1
, , , , , , , , , ,
+ + + + + + +
row i row p
column i column q
26
27
28
29
×(-1/0.0003)+
exact arithmetic yields x = 1/3 and y = 2/3 elimination
30
Precision y x 4 0.6667 0 5 0.66667 0.3 6 0.666667 0.33 7 0.6666667 0.333 cancellation here, because 3×(6666/9999)≈2.0001!
inaccurate
31
1.0000x + 1.0000y = 1.0000 0.0003x + 3.0000y = 2.0001 1.0000x + 1.0000y = 1.0000 2.9997y = 1.9998
Precision y x 4 0.6667=2/3 0.3333 5 0.66667 0.33333 6 0.666667 0.333333 7 0.6666667 0.3333333
elimination Backward substitution
32
33
34
1,1 1,2 1, 1,1 1,2 1, 2,1 2,2 2, 2,1 2,2 2, ,1 ,2 , ,1 ,2 ,
1 1 1
n n n n n n n n n n n n
a a a u u u a a a l u u a a a l l u ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ =
⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦
upper triangular
35
36
1,1 1,2 1, 1, 1 1 2,2 2, 2, 2 2 , , , i n i n i i i n i i n n n n
u u u u x y u u u x y u u x y u x y ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦
37
1 1 2,1 2 2 ,1 ,2 ,1 ,2 ,
1 1 1 1
i i i i n n n i n n
y b l y b l l y b l l l y b ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦
1 ,2 2 , 1 1 i i i i i i i
− −
1 ,1 1 ,2 2 , 1 1 , 1 i i i i i i i i i i k k k
y b l y l y l y b l y
− − − =
= − + + + = −∑
38
1 ,1 1 ,2 2 , 1 1 , 1 i i i i i i i i i i k k k
y b l y l y l y b l y
− − − =
= − + + + = −∑
DO i = 2, n yi = bi DO k = 1, i-1 yi = yi – Li,k*yk END DO END DO This is an O(n2) method Do it yourself.
39
40
41
elimination is still needed
42
43
2,1 1,1 1,1 1,2 1,3 1, 1, 3,1 2,1 2,2 2,3 2, 2, 1,1 3,1 3,2 3,3 3, 3, ,1 ,2 ,3 , ,1 1,1 ,1 1,1
1 1 1 1 1
i n i n i n i i i i i i n
a a a a a a a a a a a a a a a a a a a a a a a a a a a a ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎣ ⎦
1,2 1,3 1, 1, 2,2 2,3 2, 2, 3,2 3,3 3, 3, , ,2 ,3 , , ,1 ,2 ,3 , , ,2 ,3 , , i n i n i n i n i i i i i n n n n n i n n n n n i n n
a a a a a a a a a a a a a a a a a a a a a a a a a a ⎡ ⎤ ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ ⎣ ⎦
1,1 ,1 1,1 i i
a a a a ⎛ ⎞ − × + ⎜ ⎟ ⎜ ⎟ ⎝ ⎠
new values row i
44
2,1 1,1 3,1 1,1 1 ,1 1,1 ,1 ,
i n n n
45
3,2 2,2 2 ,2 2,2 ,2 2,2
i n
46
1, , 2, , , ,
1 1 1 1
i i i i i i i i i n i i i
a a E a a a a
+ +
⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎣ ⎦
47
1,1 1, 1, 1 1, 2 1, 1, , , 1 , 2 , , 1, 1, 1 1, 2 1, 2, 2, 2, , , ,
1 1 1 1
i i i n i i i i i i i i i n i i i i i i i i i n i i i i i i i i n i i i
a a a a a a a a a a a a a a a a a a a a a
+ + + + + + + + + + + + + + +
⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎣ ⎦
1, 1, 1 1, 2 1, 2, , , 1 , 2 , 1, 1 1, 2 1, 1 2, 2 2, 2, 1 2, 2 2, , , 1 , 2 , , 1 , 2 , i i i n n i i i i i i i n i i i i i n i i i n i i i i i n n i n i n i n n n i n i n n
a a a a a a a a a a a a a a a a a a a a a a a a a
+ + + + + + + + + + + + + + + + + + + + +
⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦
⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦
Ei Ei-1⋅Ei-2⋅…⋅E2⋅E1⋅A Ei⋅Ei-1⋅Ei-2⋅…⋅E2⋅E1⋅A
48
49
1 1
1 1 1 1 1 1 1 1 1 1
i i n k k n n
m m I m m m m
+ +
⎡ ⎤ ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⋅ = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ ⎣ ⎦
column i column i
50
1 1, 1, , , , , , , , , , ,
1 1 1 1 1 1 1 1 1 1
i i i i i i i i k i k i i i i i n i n i i i i i
a a a a a a a a a a a a
− + +
⎡ ⎤ ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ ⎣ ⎦
51
1 1
n n n n n n
− −
52
E1
Verify this yourself!
2,1 1,1 3,1 3,2 1,1 2,2 ,1 ,2 1,1 2,2 1 1 1 1 2 1 1,1 1,2 1, 1,1 2,2 , ,1 ,2 , 1,1 2,2 , , ,1 ,2 , 1,1 2,2 , ,
1 1 1 1 1 1 1
i i n i i i i i i k k k i i i n j n n n i i i j j
a a a a a a a a a a E E E a a a a a a a a a a a a a a a a a a a a
− − − − + + +
⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎢ ⎢ ⎢ ⎢ = ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎦
ii
⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥
Note that the ai,j’s are not the
computed intermediate results in the elimination process
53
DO i = 1, n-1 ! Using row i, i.e., a(i,i) DO k = i+1, n ! We want to eliminate a(k,i) S = a(k,i)/a(i,i) DO j = i+1, n ! for each entry on row k a(k,j) = a(k,j) - S*a(i,j) ! update its value END DO a(k,i) = S ! Save this “multiplier” END DO ! Don’t forget to update b(k) END DO
54
1,1 1,2 1,3 1, 1, 2,1 2,2 2,3 2, 2, 3,1 3,2 3,3 3, 3, ,1 ,2 ,3 , , ,1 ,2 ,3 , , i n i n i n i i i i i i n n n n n i n n
matrix U
55
1,1 1,2 1,3 1, 1, 2,1 2,2 2,3 2, 2, 3,1 3,2 3,3 3, 3, ,1 ,2 ,3 , , ,1 ,2 ,3 , , i n i n i n i i i i i i n n n n n i n n
u u u u u l u u u u l l u u u A l l l u u l l l l u ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦
DO i = 2, n yi = bi DO k = 1, i-1 yi = yi – ai,k*yk END DO END DO ai,k is actually li,k
56
1,1 1,2 1,3 1, 1, 2,1 2,2 2,3 2, 2, 3,1 3,2 3,3 3, 3, ,1 ,2 ,3 , , ,1 ,2 ,3 , , i n i n i n i i i i i i n n n n n i n n
u u u u u l u u u u l l u u u A l l l u u l l l l u ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣ ⎦
S = yi DO k = i+1,n S = S - ai,k*yk END DO xi = S/ai,i END DO ai,k here is ui,k!
57
4 0 1 1 3 1 3 1 0 1 2 0 3 2 4 1
×(-3/4)+ ×(-0/4)+ ×(-3/4)+
4 0 1 1 ¾ 1 9/4 ¼ 1 2 0 ¾ 2 13/4 1/4
column 1
58
×(-1/1)+ ×(-2/1)+
4 0 1 1 ¾ 1 9/4 ¼ 1 2 0 ¾ 2 13/4 1/4
column 2
4 0 1 1 ¾ 1 9/4 ¼ 1
¾ 2
59
×(-5)+ column 3
4 0 1 1 ¾ 1 9/4 ¼ 1
¾ 2 5 1 4 0 1 1 ¾ 1 9/4 ¼ 1
¾ 2
60
61
62
63
4 0 1 1 3 1 3 1 0 1 2 0 3 2 4 1
×(-3/4)+ ×(-0/4)+ ×(-3/4)+
4 0 1 1 ¾ 1 9/4 ¼ 1 2 0 ¾ 2 13/4 1/4
column 1
1 2 3 4
index array
64
×(-1/2)+ ×(-1/2)+
4 0 1 1 ¾ 1 9/4 ¼ 1 2 0 ¾ 2 13/4 1/4
column 2
4 0 1 1 ¾ 2 13/4 ¼ ½ 3/8 -1/8 ¾ ½ 5/8 1/8 1 2 3 4
index array
4 0 1 1 ¾ 2 13/4 ¼ 1 2 0 ¾ 1 9/4 ¼ 1 4 3 2
index array
1 4 3 2
index array
65
×(-3/5)+ column 3
4 0 1 1 ¾ 1 9/4 ¼ ½ 5/8 1/8 ¾ ½ 3/5 -1/5 4 0 1 1 ¾ 2 13/4 ¼ ½ 3/8 -1/8 ¾ ½ 5/8 1/8 1 4 3 2
index array
4 0 1 1 ¾ 2 13/4 ¼ ½ 5/8 1/8 ¾ ½ 3/8 1/8 1 4 2 3
index array
1 4 2 3
index array
66
index array
67
68
69
70
Start with an initial guess x0 Plug this xi into the above equations to compute xi+1 Repeat this process until A•xk ≈ b for some k.
i i i i i i n n i , , , , 1 1 2 2
x a b a x a x a x a x a b a x
i i i i i i i i i i i i n n i i i i k k k k i n
= − + + + + + = − ⎡ ⎣ ⎢ ⎤ ⎦ ⎥
− − + + = ≠
1 1
1 1 1 1 1 1 1 , , , , , , , ,
71
2x + 6y - 3z = 2 2x + y + 7z = 32 x = -(1 + y - 2z)/5 y = (2 - 2x + 3z)/6 z = (32 - 2x - y)/7
x2 1 5 1 1 3 2 32 7 1 6 2 2 1 5 3 32 7 1 7 32 2 1 5 1 3 15619 2 6857 4 5810 = − + − × ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ − × − + × ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ − × − − ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ ⎡ ⎣ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ = − ⎡ ⎣ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ . . .
transformation Converge in approx. 10 iterations with x≈0.998, y≈1.997, z≈3.991
72
! Given system is A•x = b ! C(:,:) and d(:) are two ! working arrays DO i = 1, n DO j = 1, n C(i,j) = -A(i,j)/A(i,i) END DO C(i,i) = 0 d(i) = b(i)/A(i,i) END DO
C a a a a a a a a a a a a a a a a a a a a a a a a
n n n n n n n n n n n n
= − − − − − − − − − − − − ⎡ ⎣ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥
1 2 1 1 1 3 1 1 1 1 1 2 1 2 2 2 3 2 2 2 2 2 3 1 3 3 3 2 3 3 3 3 3 1 2 3 , , , , , , , , , , , , , , , , , , , , , , , ,
b a b a b a b a
n n n
= ⎡ ⎣ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎤ ⎦ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥
1 1 1 2 2 2 3 3 3 , , , ,
73
DO x_new = C*x + d IF (ABS(A*x_new - b) < Tol) EXIT x = x_new END DO
ABS(A*x_new-b) < Tol means the absolute value
You may just use the equations for computation instead of the above matrix form.
74
75
2x + 6y - 3z = 2 2x + y + 7z = 32 x = -(1 + y - 2z)/5 y = (2 - 2x + 3z)/6 z = (32 - 2x - y)/7
transformation
76
2x + 6y - 3z = 2 2x + y + 7z = 32 x = -(1 + y - 2z)/5 y = (2 - 2x + 3z)/6 z = (32 - 2x - y)/7
transformation
77
DO DO i = 1, n ! Update xi EQN_i = 0 DO j = 1, n EQN_i = EQN_i + C(i,j)*x(j) END DO x(i) = EQN_i + d(i) END DO IF (ABS(A*x – b) < Tol) EXIT END DO
78
, , ,
i i i j j j i n
= ≠
1
(for every i)
79
#1 #2
x0 x1 x2
80
3x+y=3 x+2y=2 x=1-y/3 y=1-x/2 #1 #2
X0 X1 X2
81
#1 #2
x0 x1 x2
82
3x+y=3 x+2y=2 x=1-y/3 y=1-x/2 #1 #2
X0 X1 X2
83
84
Make a copy of A to A’ and A” and b to b’ Use A” to compute A” = L*U Apply an elimination method to solve A’*x=b’ Let the solution be x DO r = b – A * x ! Compute residual IF (ABS(r) < Tol) EXIT Solve for ∆ from (L*U)*∆ = r ! Compute error x = x + ∆ END DO
85
86
1,1 1, 1, 1, ,1 , , , ,1 ,1 , ,
i n i i i i i n i i n n n n n i
87
1,1 1, 1, 1, ,1 , , , ,1 ,1 , ,
i n i i i i i n i i n n n n n i
88
89
90
row swap column swap ×(-1/6)+ row swap ×(-1/2)+
(-1)374=-74
3 swaps means (-1)3 product is 74
91