Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Computer Methods in Civil Eng.

48

2/24/2006

# $

!"

%!

"

& $
!

%) !* +
.

' (

,/)
A11 x1 + A12 x2 + A13 x3 = b1
A21 x1 + A22 x2 + A23 x3 = b2
A31 x1 + A32 x2 + A33 x3 = b3

"

12 3
+

Mathcad Basics

Computer Methods in Civil Eng.

49

2/24/2006

A11

A12

A13

A 21
A 31

A 22
A 32

A 23 b2
A33 b3

A11

A12

A13

b1

'
22

'
23
"
33

b2'

A
A

b1

b3"

After forward elmination is completed,


we have an upper triangular system.

x3 = b3" / A"33
'
x2 = (b2' A '23 x3 ) / A 22

x1 = (b1 A12 x2 A13 x3 ) / A11


Back-Substitution

& $

*
!+

3A11 46

+
$

%!
%)

6
$
+
34 ,

$
1$ %

factor

%)'
6

A 21
A11

+
3 44

3
%4

53
1$ %

A 21 A 21 factor*A11
Elimination of
the 1st column
of the 2nd row

+
Mathcad Basics

Computer Methods in Civil Eng.

50

2/24/2006

A 22 A 22 factor*A12
A 23 A 23 factor*A13

3
/4

12
b2 b2 factor*b1
+%6

$!
34 ,

1$ /

factor

3
%4

A 31
A11

1$ /
A 31 A 31 factor*A11
Elimination of
the 1st column
of the 3rd row

A 32 A 32 factor*A12
A 33 A 33 factor*A13
3
/4
12
b3 b3 factor*b1

Mathcad Basics

+%

Computer Methods in Civil Eng.

51

2/24/2006

Part I : Forward Elimination


Iteration #1
Fiteration01( A , b ) :=

pivot A

1, 1

for i 2 .. rows ( A )
factor

i, 1

pivot

for k 1 .. cols ( A )
A

i, k

i, k

factor A

b b factor b
i

1, k

out ( A b )

2 3 1

A := 0 1 3

b := 5

4 5 2

10

result01 := Fiteration01( A , b )
A01 := result01

1, 1

2 3 1
A01 = 0 1 3
0 1 0

result01 = ( {3,3} {3,1})

b01 := result01

1, 2

7
b01 = 5
4

77777777777777777777777777777777777777777777777
77777777
+ 0& $
,
+
!

Mathcad Basics

Computer Methods in Civil Eng.

52

2/24/2006

0!!
0A 22 6

[A]

{b}
A 22

b012

b2

A0122

"

A 22

A0122

"

b012

+
54

%!

$
!, +
factor

b2

1$ /
A 32
A
(or 32 )
pivot
A 22

1$ /

A 32 A 32 factor*A 22
Elimination of
the 2nd column
in the 3rd row

+
3

6
3 4 8/4

A 33 A 33 factor*A 23

12

b3 b3 factor*b2

Mathcad Basics

3 40

5
0

Computer Methods in Civil Eng.

53

2/24/2006

iteration#2
Fiteration02( A , b ) :=

pivot A

2, 2

for i rows ( A )
factor

i, 2

pivot

for k 1 .. cols ( A )
A

i, k

i, k

factor A

b b factor b
i

2, k

out ( A b )

result02 := Fiteration02( A01 , b01)

result02 = ( {3,3} {3,1})

2 3 1
result02

1, 1

= 0 1 3

result02

1, 2

0 0 3

A02 := result02

1, 2

2 3 1

b02 = 5

A02 = 0 1 3

0 0 3

+
%!
$

Mathcad Basics

9
+

b02 := result02

1, 1

= 5

+
& $

Computer Methods in Civil Eng.

%!
%*+

54

2/24/2006

% &'(

[A]

A0233

{b}

!
A 22

b023

b2

"

A 22

b2

A0122

b012

( $
x3

$3
1 $ /4

b3
A 33

x3

%!' ()
i2
6#
$3

()
3) 4

sum 0.0
3
#

$4

5 3)%4

[A]

$
bi
xi =

A ij * x j

n
j = i +1

{b}

' ()

j = i +1

$!

:+

3
1
n

$ +4

1$ %

;i <

%) !"

53

Aij * x j

Aii

* 8 = 0 =% !
!
6
* [A]

34
+

$*

sum sum + A 2 j * x j 3 sum sum + Aij * x j 4

3
#
$
"
+

%)%

Mathcad Basics

; <
A ij * x j !" 0*
$
!2 $

*
0
!* >"0+
< x2 (or xi )

+
$
9
+

!
; <
+ %0
!*$
(
4

Computer Methods in Civil Eng.


x2

55

2/24/2006

b2 sum
b sum
(or xi i
)
A 22
A ii
A 23 * x3

6$

; <
&>1) +!
$ 6

+
+

Part II : Back-Substitution
ORIGIN 1

Iteration #1
These are the matrices resulted from
Forward Elimination
2 3 1

A := 0 1 3

b := 5

0 0 3

Biteration01( A , b ) :=

x
3

b
A

3, 3

i2
sum 0.0
for j i + 1 , i + 2 .. cols ( A )
sum sum + A
x
i

i, j j

b sum
2

i, i

unknown_x01 := Biteration01( A , b )
0
unknown_x01 = 4
3

77777777777777777777777777777777777777777777777
+ 0$
$
( $ x3 , x2
+
!

Mathcad Basics

Computer Methods in Civil Eng.

56

2/24/2006

!
$

( $ x1
5
43
$
5

/?/
+

$3
0

5
4

x3 , x2

0' ()

1$

i 1 6
1$
sum 0.0

%!"

[A]

{b}
' ()

6
bi

n
j = i +1

A ij * x j

xi =

* 8 = 0 =% !
! 34
6
* [A]

n
j = i +1

A ij * x j

A ii

$*

sum sum + A 2 j * x j 3 sum sum + A ij * x j 4

3
#
+

; <
A ij * x j 4

!
x1

<3
8A12 * x2 + A13 * x3 4

x2 (or xi )

b1 sum
b sum
(or xi i
)
A11
A ii

$
; <
; <
) +!

Mathcad Basics

A12 * x2 + A13 * x3

Computer Methods in Civil Eng.

57

2/24/2006

Iteration #2
x and x were computed in iteration #1. However, to develop the
3

Biteration02 as a continuation from Biteration01, I re-compute these


two variables herein

Biteration02( A , b ) :=

x
3

b
A

3, 3

b A
2

2, 3 3

2, 2

i1
sum 0.0
for j i + 1 , i + 2 .. cols ( A )
sum sum + A
x

i, j j

b sum
1

i, i

unknown_x02 := Biteration02( A , b )
1
unknown_x02 =

4
3

*
#

+
%!
$

Mathcad Basics

9
+

+
' ()

Computer Methods in Civil Eng.

58

2/24/2006

5 +
62 $
++

V2 = 0

i2

R1 = 20

R4 = 10

i1

V1 = 0

R3 = 25

i3

R2 = 10

R5 = 30

V3 = 200
+

$ (
3
/

( $
@

+
i

$
+

!"
+
!

($
($ !

%!"

$
0

"

Mathcad Basics

+ 9
+

Computer Methods in Civil Eng.

59

2/24/2006

"

0$

! #
& ># 1>B -

+A

&" >> 620(i1 i2 ) + 10(i1 i3 ) = 0


11* 2" >> 625 i2 + 10(i2 i3 ) + 20(i2 i1 ) = 0

& ># 1>B -B

& ># 1>B & ># 11* 2" >> 630 i3 + 10(i3 i2 ) + 10(i3 i1 ) = 200
"

20(i1 i2 ) + 10(i1 i3 ) = 0

30 i1 20 i2 10 i3 = 0

25 i2 + 10(i2 i3 ) + 20(i2 i1 ) = 0

20 i1 + 55 i2 10 i3 = 0

30 i3 + 10(i3 i2 ) + 10(i3 i1 ) = 200

10 i1 10 i2 + 50 i3 = 200

+30 i1 20 i2 10 i3 = 0
20 i1 + 55 i2 10 i3 = 0
10 i1 10 i2 + 50 i3 = 200

20 10

30

20 55 10
10 10 50
&

0+

$ /8) D
/@*
*
*
)

8/C0

i1

i2 = 0
i3
200
$ % 8)%D
/@*
*
)

E
*
0

E
*
30
0
0

20

10

(125 / 3) (50 / 3) 0
(50 / 3) (140 / 3) 200
After 1st iteration is completed

@*
*
*
)
%D
F

Mathcad Basics

E
*
*$

83%FD
/40

$ /8)

Computer Methods in Civil Eng.

60

2/24/2006

30
20
10
0
0 (125 / 3) (50 / 3) 0
0
0
40
200
Since 2nd iteration was completed,
the system has been transformed into
an upper triangular system

' ()
40 * i3 = 200

i3 = 5

(125 / 3) * i2 (50 / 3) * i3 = 0
30* i1 20* i2 10* i3 = 0

"

i1

i2 = 2
i3
5

Mathcad Basics

i2 = 2
i1 = 3

You might also like