1 simultaneous linear equations gaussian elimination
TRANSCRIPT
Gaussian Elimination
One of the most popular techniques for solving simultaneous linear equations of the form
Consists of 2 steps
1. Forward Elimination of Unknowns.
2. Back Substitution
CXA
Forward Elimination
The goal of Forward Elimination is to transform the coefficient matrix into an Upper Triangular Matrix
7.000
56.18.40
1525
112144
1864
1525
Forward EliminationLinear Equations
A set of n equations and n unknowns
11313212111 ... bxaxaxaxa nn
22323222121 ... bxaxaxaxa nn
nnnnnnn bxaxaxaxa ...332211
. . . . . .
3
2
1
3
2
1
333231
232221
131211
x
x
x
b
b
b
aaa
aaa
aaa
Forward Elimination
Transform to an Upper Triangular Matrix
Step 1: Eliminate x1 in 2nd equation using equation 1 as the pivot equation
)1(11
21 Eqna
a
Which will yield
111
211
11
21212
11
21121 ... b
a
axa
a
axa
a
axa nn
11313212111 ... bxaxaxaxa nn
22323222121 ... bxaxaxaxa nn
Forward Elimination
Zeroing out the coefficient of x1 in the 2nd equation.
Subtract this equation from 2nd equation
111
2121
11
212212
11
2122 ... b
a
abxa
a
aaxa
a
aa nnn
Pivot = (a(2,1)/a(1,1))For i=1:var+1 i:all element in the same equation
a(2,i) = a(2,i) - (pivot * a(1,i) )
end
This procedure is repeated for the remaining equations to reduce the set of equations as
11313212111 ... bxaxaxaxa nn '2
'23
'232
'22 ... bxaxaxa nn
'3
'33
'332
'32 ... bxaxaxa nn
''3
'32
'2 ... nnnnnn bxaxaxa . . .
. . .For j=1+1:var j: all equations
1: to eleminate x1
Pivot = (a( j,1)/a(1,1))
For i=1:var+1a( j ,i) = a( j ,i) - (pivot * a(1,i) )
End
end
Forward EliminationStep 2: Eliminate x2 in the 3rd equation.
Equivalent to eliminating x1 in the 2nd equation using equation 2 as the pivot equation.
)(2
3 3222
aa
EqnEqn
This procedure is repeated for the remaining equations to reduce the set of equations
Forward Elimination
Continue this procedure by using the third equation as the pivot equation and so on.
For nx=1:var-1 xn:all the x in all equations
For j=nx+1:var j: all equations
Pivot = (a( j,nx)/a(nx, nx))
For i=1:var+1 i:all element in the same equation
a( j ,i) = a( j ,i) - (pivot * a(nx,i) )
End
End
end
At the end of (n-1) Forward Elimination steps, the system of equations will look like:
'2
'23
'232
'22 ... bxaxaxa nn
"3
"3
"33 ... bxaxa nn
11313212111 ... bxaxaxaxa nn
11 nnn
nnn bxa
. . . . . .
Forward Elimination
At the end of the Forward Elimination steps
)-(nnn
3
2
1
nnn
n
n
n
b
b
b
b
x
x
x
x
a
aa
aaa
aaaa
1
"3
'2
1
)1(
"3
"33
'2
'23
'22
1131211
Back Substitution
The goal of Back Substitution is to solve each of the equations using the upper triangular matrix.
3
2
1
3
2
1
33
2322
131211
x
x
x
00
0
b
b
b
a
aa
aaa
Example of a system of 3 equations
Back Substitution
Start with the last equation because it has only one unknown
nn
nn a
bx
Solve the second from last equation using xn solved for previously.
This solves for xn-1.
nnnn bxa
Back Substitution
Representing Back Substitution for all equations by formula
ii
n
ijjiji
i a
xabx
1
For i=n-1, n-2,….,1
and
nn
nn a
bx
11313212111 ... bxaxaxaxa nn
3
2
1
x
x
x
ii
n
ijjiji
i a
xabx
1
For z= var : -1 : 1
sum= 0For w=z+1 : 1 : var
Sum =sum+(a(z,w)*x(w))
End
X(z)= (a(z,4)- sum) / a(z,z)
end
3
2
1
x
x
x
Example: Rocket Velocity
The upward velocity of a rocket is given at three different times
Time, t Velocity, v
s m/s
5 106.8
8 177.2
12 279.2
2.279
2.177
8.106
112144
1864
1525
3
2
1
a
a
a
322
1 atatatv
Example: Rocket Velocity
Forward Elimination: Step 1
)64(
25
12
RowRow
Yields
2.279
21.96
81.106
a
a
a
112144
56.18.40
1525
3
2
1
Example: Rocket Velocity
)144(
25
13
RowRow
0.336
21.96
8.106
a
a
a
76.48.160
56.18.40
1525
3
2
1
Yields
Forward Elimination: Step 1
Example: Rocket Velocity
Yields
)8.16(8.4
23
RowRow
735.0
21.96
8.106
a
a
a
7.000
56.18.40
1525
3
2
1
This is now ready for Back Substitution
Forward Elimination: Step 2
Example: Rocket Velocity
Back Substitution: Solve for a3 using the third equation
735.07.0 3 a
70
7350
.
.a 3
0501. a 3
Example: Rocket Velocity
Back Substitution: Solve for a2 using the second equation
21.9656.18.4 32 aa
8.4
56.121.96 32
aa
84
05015612196
.-
...-a 2
7019.a 2
Example: Rocket Velocity
Back Substitution: Solve for a1 using the first equation
8.106525 321 aaa
25
58.106 32
1
aaa
25
050.170.1958.1061
a
2900.01 a
Example: Rocket Velocity
Solution:The solution vector is
050.1
70.19
2900.0
3
2
1
a
a
a
The polynomial that passes through the three data points is then:
322
1 atatatv
125 ,050.170.192900.0 2 ttt