0.0 Overall Note PDF
0.0 Overall Note PDF
1. Graphical Methods
Graphical methods provide visual insight into techniques.
Graphical approach.
c
gm t
f (c ) (1 e m ) v, v 40 @ t 10 sec
c
9.8 68.1
c
10
f (c ) (1 e 68.1 ) 40
c
c 4 8 12 16 20
40
35
30
25
20
Function
15
10
5
0
-5
-10
-15
4 6 8 10 12 14 16 18 20
Drag Coefficient
14.75
667.38 10
f (14.75) (1 e 68.1
) 40 0.059 close to zero
14.75
2. Bracketing Methods.
Start with guesses that bracket, the root and then systematically reduce the width of the
bracket. It is based on the principle that Function changes its sign in the vicinity of root.
Both method assume Upper and lower value.
Bisection
False Position.
Bisection Method
1) xL , xu are lower and upper bounds.
x L xu
2) xc
2
If f ( xL ) f ( xc ) 0 Root xc
Problem1
667.38
f (c ) (1 e 0.14684c ) 40
c
xL 12 xu 16
f (12) 6.066936 and f (16) 2.26876
f (12) f (16) 0
12 16
xc 14, f (14) 1.568699
2
f (12). f (14) 0. Set xL 14.
14 16
xc 15 f (15) 0.42484
2
f (14) f (15) 0 Set xu 15.
14 15
xc 14.5 f (14.5) 0.552319
2
f (14). f (14.5) 0. Set xL 14.5
14.5 15
xc 14.75 f (14.75) 0.058954
2
f (14.5). f (14.75) 0. Set xL 14.75
14.75 15
xc 14.875 f (14.875) 0.18413
2
f (14.75). f (14.875) 0. Set xu 14.875
14.75 14.875
xc 14.8125 f (14.8125) 0.06288
2
f (14.75). f (14.8125) 0. Set xu 14.8125
14.75 14.78125
xc 14.8125 f (14.78125) 0.00204
2
ITR XL XU XC f X C a
1 12.00000 16.00000 14.00000 1.56870 100.00000
2 14.00000 16.00000 15.00000 -.42484 6.66667
3 14.00000 15.00000 14.50000 .55232 3.44828
4 14.50000 15.00000 14.75000 .05895 1.69492
5 14.75000 15.00000 14.87500 -.18413 .84034
6 14.75000 14.87500 14.81250 -.06288 .42194
7 14.75000 14.81250 14.78125 -.00204 .21142
8 14.75000 14.78125 14.76563 .02844 .10582
9 14.76563 14.78125 14.77344 .01320 .05288
10 14.77344 14.78125 14.77734 .00558 .02643
11 14.77734 14.78125 14.77930 .00177 .01322
12 14.77930 14.78125 14.78027 -.00014 .00661
Re ad xL & xu
Calculate f ( xL ) & f ( xu )
If f ( xL ) f ( xu ) 0 Then ( If N 0)
( If Yes)
x xu
xc L , Calculate f ( xc )
2
If f ( xL ) f ( xc ) 0 xu xc
If f ( xL ) f ( xc ) 0 xL xc , f ( xL ) f ( xc )
Problem 2
f ( x) x 3 4 x 2 10 has root in 1,2
ITR XL XU XC f X C a
1 1.00000 2.00000 1.50000 2.37500 100.00000
2 1.00000 1.50000 1.25000 -1.79688 20.00000
3 1.25000 1.50000 1.37500 .16211 9.09091
4 1.25000 1.37500 1.31250 -.84839 4.76190
5 1.31250 1.37500 1.34375 -.35098 2.32558
6 1.34375 1.37500 1.35938 -.09641 1.14943
7 1.35938 1.37500 1.36719 .03236 .57143
8 1.35938 1.36719 1.36328 -.03215 .28653
9 1.36328 1.36719 1.36523 .00007 .14306
Root 1.36523438
False Position Method
In bisection method no account is taken of the magnitude of f ( xL ) & f ( xu ). From similar triangles
f ( xL ) f ( xu )
xc x L xu x c
f ( x L )( xu xc ) f ( xu )( xc x L )
xu f ( x L ). xc . f ( x L ) xc . f ( xu ) x L f ( xu )
xc { f ( x L ) f ( xu )} . xu f ( x L ) x L f ( xu )
x . f ( x L ) x L f ( xu ) xu f ( x L ) xu f ( xu ) xu f ( xu ) x L f ( xu )
xc u
f ( x L ) f ( xu ) f ( xl ) f ( xu )
( x x L ) f ( xu )
x c xu u
f ( xl ) f ( xu )
( xu x L )
x c xu f ( xu )
f ( xu ) f ( x L )
f ( xu )( xu x L )
For x L & xu find f ( x L ). & f ( xu ) Then x c xu
f ( xu ) f ( x L )
Problem 1
ITR XL XU XC f X C a
1 12.00000 16.00000 14.91130 -.25428 100.00000
2 12.00000 14.91130 14.79419 -.02726 .79160
3 12.00000 14.79419 14.78170 -.00291 .08455
4 12.00000 14.78170 14.78036 -.00031 .00901
Problem 2
ITR XL XU XC f X C a
1 1.00000 2.00000 1.26316 -1.60227 100.00000
2 1.26316 2.00000 1.33883 -.43036 5.65196
3 1.33883 2.00000 1.35855 -.11001 1.45144
4 1.35855 2.00000 1.36355 -.02776 .36677
5 1.36355 2.00000 1.36481 -.00698 .09229
6 1.36481 2.00000 1.36512 -.00176 .02320
7 1.36512 2.00000 1.36520 -.00044 .00583
PROGRAM ROOT
REAL*8 XL, XU, XC, FXL, FXU, FXC
OPEN(5,FILE='INPUT',STATUS='UNKNOWN')
OPEN(6,FILE='OUT',STATUS='UNKNOWN')
READ(5,*) MODE ! MODE = 1 Bisection, MODE = 2 False Position
READ(5,*) XL, XU
FXL = FUN(XL) ; FXU = FUN(XU); ITR = 0
PROD = FXL * FXU
IF ( PROD > 0.0 ) THEN
WRITE(*,*) 'TRY DIFFERENT SET'
STOP
ENDIF
10 ITR = ITR +1
IF ( MODE == 1 ) XC = (XL + XU)/2.0
IF ( MODE == 2 ) XC = XU - (XU - XL)*FXU /(FXU -FXL)
FXC = FUN(XC)
TERM = 100.0 * ABS( (XC-XCOLD)/XC )
WRITE(6,'(I3,5(1X,F10.5))')ITR, XL, XU, XC, FXC, TERM
FUNCTION FUN(X)
REAL*8 X
FUN = 667.38 * ( 1.0 - EXP(-X/6.81) )/X - 40.0
RETURN
END
Open Methods Iteration X
Newton Raphson Method 1 0.5 1.3
2 51.65 1.17943
f ( x)
xi 1 xi 3 46.485 1.084131
f ' ( x) 4 41.8365 1.024053
F 5 37.65285 1.002389
F ( x) e x x e x 1
x 6 33.88757 1.000025
7 30.49881 1
Iteration X F(X) F'(X)
8 27.44893 1
1 0 1 -2
9 24.70403
2 0.5 0.106531 -1.60653
10 22.23363
3 0.566311 0.001305 -1.56762
11 20.01027
4 0.567143 1.96E-07 -1.56714
12 18.00924
5 0.567143 4.44E-15 -1.56714
13 16.20832
6 0.567143 0 -1.56714
14 14.58749
7 0.567143 0 -1.56714
15 13.12874
16 11.81586
17 10.63428
F
F ( x) x10 1 10 x 9 18 9.570849
x 19 8.613764
Newton Raphson Method 20 7.752388
X F(X) F'(X) 21 6.977149
1.3 12.7858492 106.045 22 6.279434
1.17943 4.20860657 44.16207 23 5.651491
1.084131 1.24293636 20.6888 24 5.086342
1.024053 0.2683079 12.38518 25 4.577708
1.002389 0.02415311 10.21712 26 4.119937
1.000025 0.00025472 10.00229 27 3.707944
1 2.9188E-08 10 28 3.33715
1 0 10 29 3.003437
Computation with Guess value 1.3 30 2.703098
31 2.432801
Determine the highest real root of 32 2.189555
f ( x) x 3 6 x 2 11x 6.1 33 1.970686
Using the Newton Raphson method, perform four 34 1.77384
iteration with starting value 3.5. 35 1.597031
36 1.438808
f ( x) x 3 6 x 2 11x 6.1 37 1.298711
f ' ( x) 3x 2 12 x 11 38 1.178355
39 1.08335
X F(X) F'(X) Error 40 1.023665
3.5 1.775 5.75 41 1.002316
3.191304 0.399402 3.257618 9.673025 42 1.000024
3.068699 0.05188 2.426352 3.995359 43 1
3.047317 0.001456 2.290617 0.701669
3.046681 1.27E-06 2.286624 0.020864
3.046681 9.68E-13 2.28662 1.82E-05
3.046681 0 2.28662 1.39E-11
F ( x) x 3 5 x 2 7 x 3
F 2F
3x 2 10 x 7 6 x 10
x x 2
Compare two approach
x 3 5x 2 7 x 3
1. x New x ( )
3x 2 10 x 7
2.
( x 3 5 x 2 7 x 3)(3x 2 10 x 7)
x New x
(3x 2 10 x 7) 2 ( x 3 5 x 2 7 x 3)(6 x 10)
Iteration X App Error True Error Iteration X True Error
0 0 100 0 0 100
1 0.42857143 100 57.14286 1 1.105263 10.52632
2 0.68571429 37.5 31.42857 2 1.003082 0.308166
3 0.8328654 17.66805 16.71346 3 1.000002 0.000238
4 0.91332989 8.810014 8.667011 4 1 3.73E-09
5 0.95578329 4.441739 4.421671
6 0.9776551 2.23717 2.23449
7 0.98876617 1.12373 1.123383
8 0.99436744 0.5633 0.563256
9 0.99717977 0.282028 0.282023
10 0.99858889 0.141111 0.141111
11 0.9992942 0.07058 0.07058
12 0.99964704 0.035296 0.035296
13 0.9998235 0.01765 0.01765
14 0.99991175 0.008825 0.008825
15 0.99995587 0.004413 0.004413
16 0.99997794 0.002206 0.002206
17 0.99998897 0.001103 0.001103
18 0.99999448 0.000552 0.000552
19 0.99999724 0.000276 0.000276
20 0.99999862 0.000138 0.000138
21 0.99999931 6.89E-05 6.9E-05
22 0.99999966 3.45E-05 3.45E-05
Systems of Nonlinear Equation
Linear simultaneous equations in next
chapter.
f ( x) a1 x1 a2 x2 ... an xn b 0
Where a & b are constants.
Algebraic and transcendental equations that
do not fit this formate are called non linear
equations.
f1 ( x1 , x 2 ,...., x n ) 0
f 2 ( x1 , x 2 ,...., x n ) 0
.
.
f n ( x1 , x 2 ,....., x n ) 0
Locate the roots of a set simultaneous
equations.
u x 2 xy 10 v y 3xy 2 57
57 y
x 10 xy y
3x
Iteration X Y
0 1.5 3.5
1 2.17944947 2.860506
2 1.94053388 3.049551
3 2.02045629 2.983405
4 1.99302813 3.005704
5 2.00238524 2.998054
6 1.99918491 3.000666
7 2.00027865 2.999773
8 1.99990475 3.000078
9 2.00003256 2.999973
10 1.99998887 3.000009
11 2.0000038 2.999997
12 1.9999987 3.000001
13 2.00000044 3
14 1.99999985 3
15 2.00000005 3
16 1.99999998 3
17 2.00000001 3
18 2 3
Newton Raphson Method
Taylor’s Series
u i u
u i 1 u i ( xi 1 xi ) ( yi 1 yi ) i
x y
v v
vi 1 vi ( xi 1 xi ) i ( yi 1 yi ) i
x y
Root estimate corresponds to the value of x and y where ui 1 and vi 1 are equal to zero.
u l u u u
xi 1 l yi 1 u i xi i yi i
x y x y
vl v v v
xi 1 l yi 1 vi xi i yi i
x y x y
1
u i u i vi u
x i
y 1 y y
vi vi u i vi u i vi vi
u i
x y x y y x x x
1 v u v u v u u v u v
xi 1 {ui i xi i i yi i i vi i xi i i yi i i }
ui vi ui vi y x y y y y y x y y
x y y x
v u
u l 1 vl l
y y
xl 1 xl
u l v1 u l v1
x y y x
1 v u v u v u u v u v
yl 1 [u l 1 xl l 1 yl l 1 vl l xl l 1 yl l 1 ]
u l v1 u l v1 x x x y x x x x x y
x y y x
u v
vl 1 u l l
yl 1 yl x x
u v u v
( l 1 l 1)
x y y x
v u u v
v u u
v
y y x x
xN x and yN y
u v u v u v u v
x y y x x y y x
u u v v
2x y x 3y2 1 6 xy
x y x y
X Y U V U'x U'y V'x V'y Determin.
1.5 3.5 -2.5 1.625 6.5 1.5 36.75 32.5 156.125
2.036029 2.8438751 -0.06437 -4.75621 6.915933 2.036029 24.26288 35.74127 197.7843
1.998701 3.00228856 -0.00452 0.049571 6.99969 1.998701 27.04121 37.00406 204.9696
2 2.99999941 -1.3E-06 -2.2E-05 6.999999 2 26.99999 36.99999 204.9999
2 3 0 2.24E-12 7 2 27 37 205
Polynomial Evaluation and Differentiation
Evaluation by Deflation
f ( x) a0 a1 x a 2 x 2 a3 x 3
f ( x) a0 x[a1 x(a 2 xa 3 )]
f ' ( x) a1 2a 2 x 3a3 x 2
f ' ( x) a1 x(2a 2 3a3 x)
Do I n,0,1
Df Df * x p
p p * x ai
EndDo
an
a n x a n 1
a n x 2 a n 1 x a n 2
Let n 3, P a3 I 3
a3 x a 2 I 2
a3 x 2 a 2 x a1 I 1
a3 x a 2 x a1 x a0
3 2
I 0
Df 0 I 3
Df a3 I 2
Df a3 x a3 x a 2 2a3 x a 2 ; I 1
Df (2a3 x a 2 ) x a3 x 2 a 2 x a1
Df 3a3 x 3 2a 2 x a1
Muller’s Method
Projects a parabola through three points.
f 2 ( x ) a ( x x 2 ) 2 b( x x 2 ) c
f ( x 0 ) a ( x 0 x 2 ) 2 b( x 0 x 2 ) c
f ( x1 ) a( x1 x 2 ) 2 b( x1 x 2 ) c
f ( x 2 ) a ( x 2 x 2 ) 2 b( x 2 x 2 ) c
c f ( x2 )
f ( x 0 ) f ( x 2 ) a ( x 0 x 2 ) 2 b( x 0 x 2 )
f ( x1 ) f ( x2 ) a( x1 x 2 ) 2 b( x1 x2 )
f ( x0 ) f ( x 2 )
0 a ( x0 x 2 ) b
( x0 x 2 )
f ( x1 ) f ( x 2 )
1 a( x1 x 2 ) b
( x1 x 2 )
f ( x0 ) f ( x 2 ) f ( x1 ) f ( x 2 )
a( x0 x1 )
( x0 x 2 ) x1 x 2
x1 f ( x0 ) x1 f ( x 2 ) x 2 f ( x0 ) x 2 f ( x 2 ) x0 f ( x1 ) x0 f ( x 2 ) x 2 f ( x1 ) x 2 f ( x 2 )
a
( x0 x1 )( x0 x 2 )( x1 x 2 )
( x1 x 2 ) f ( x0 ) ( x 2 x0 ) f ( x1 ) ( x0 x1 ) f ( x 2 )
a
( x0 x1 )( x0 x 2 )( x1 x 2 )
a( x0 x1 ) 0 1
0 1 ( x0 x 2 )
a , b 0 a( x0 x 2 ) 0 ( 0 1 )
x0 x1 ( x0 x1 )
Problem
f ( x) x 3 13x 12
x0 4.5, x1 5.5, x 2 5
f ( x0 ) f (4.5) 20.625
f ( x1 ) f (5.5) 82.875
f ( x 2 ) f (5) 48
0 a( x0 x 2 ) b
1 a( x1 x 2 ) b
f ( x0 ) f ( x 2 ) 20.625 48
0
x0 x 2 45 5.0
270375
0 54.75
0 .5
f ( x1 ) f ( x 2 ) 82.875 48 34.875
1
x1 x 2 5.5 5 0.5
1 69.75
54.75 a(4.5 5) b
69.75 a(5.5 5) b
( 0 1 ) a( x0 x1 ) a 15
69.75 7.5 b, b 62.25
c 48
15( x x 2 ) 2 62.25( x x 2 ) 48 0
2c
x3 5
b b 2 4ac
96
5 3.976
62.25 62.25 2 4 15 48
Repeat with 5.5, 5, 3.976
X0 X1 X2 F(x0) F(x1) C=F(x2) D0 D1 a b
4.5 5.5 5 20.625 82.875 48 54.75 69.75 15 62.25
5.5 5 3.976487 82.875 48 -0.81633 54.93313 47.69488 14.47649 32.87801
5 3.97648704 4.00105 48 -0.81633221 0.036781 48.01366 34.73098 12.97754 35.04975
3.976487 4.0010505 4.000001 -0.816332211 0.036780702 2.47E-05 34.71841 35.01262 11.97754 35.00004
4.00105 4.00000071 4 0.036780702 2.46845E-05 1.74E-11 35.01261 35.00001 12.00105 35
4.000001 4 4 2.46845E-05 1.74083E-11 0 35.00001 35 11.99937 35
Bairstow’s Method r 1 C2 C3 b1
2 C
f ( x) a0 a1 x a2 x an x C 2 b0
2 n.
s C 2 C1C3 1
Divide by (x-t).
r 1 b0 C3 b1C 2
f n1 ( x) b1 b2 x b3 x 2 bn x n1 . 2
s C 2 C1C3 b1C1 b0 C 2
remainder R b0
bn a n bn a n
bi ai bi 1t bn 1 a n 1 r bn
For i n 1 to 0
C n bn
To permit, Evaluation of complex roots,
C n 1 bn 1 r bn
Division by x 2 r x s
do i n 2, 0, 1
bi ai r bi 1 s bi 2
f n2 ( x) b2 b3 x bn1 x n3 bn x n2 . C i bi r Ci 2 s C i 2
End do.
Remainder R b0 b1 ( x r ) Problem
Synthetic division. f ( x) x 5 3.5x 4 2.75x 3 2.125x 2 3.875x 1.25
bn a n
a5 a4 a3 a2 a1 a0
bn1 a n 1 r bn .
1 -3.5 2.75 2.125 -3.875 1.25
bi al r bi 1 s bi 2 First Iteration
For i n 1 to 0 Start with r s 1,
For remainder to be zero b1 and b0 must be b5 1, b4 4.5, b3 6.25, b2 0.375,
zero. b1 10.5, b0 11.375
To modify our guess, use Taylor’s series. C5 1, C4 , 5.5, C3 10.75, C2 4.875,
b b
b1 (r r , s s) b1 1 r 1 s C1 16.375
r s
Det 199.7969, r 0.35583, s 1.138109
b b
b 0 (r r , s s) b0 0 r 0 s.
r s
x 5 3.5 x 4 2.75 x 3 2.125 x 2 3.875 1.25 0
For exact guess, LHS is equal to zero.
b1 b ( x 2 0.5 x 0.5)( x 3 4 x 2 5.25 x 2.5) 0
r 1 s b1 .
r s ( x 2 0.5 x 0.5) 0
b0 b 0.5 0.52 4 1 (0.5) 0.5 1.5
r 0 s b0 . Roots
r s 2 2
If the partial derivatives of the b’s can be 0.5,1
determined, then solve above two equations
can be solved simultaneously for r & s.
C n bn
C n1 bn1 rCn .
Ci bi r Ci 1 s Ci 2
b0 b b b
C1 , 0 C 2 , 1 C 2 , 1 C3 .
r s r s
C 2 r C3 s b1
C1r C3 s b0
C 2 C3 r b1
C
1 C 2 s b0
f ( x) x 5 3.5x 4 2.75x 3 2.125x 2 3.875x 1.25
f ( x) x 5 3.5x 4 2.75x 3 2.125x 2 3.875x 1.25
R s b5 b4 b3 b2 b1 b0 c5 c4 c3 c2 c1 Det dr ds
-1 -11 -4.5 6.25 0.375 -10.5 11.375 1 -5.5 10.75 -4.875 -16.375 199.7969 0.35583 1.138109
-0.64417 0.1381091 -4.14417 5.557658 -2.02742 -1.80143 2.130423 1 -4.78834 8.780271 -8.34472 4.786621 27.60656 0.133057 0.331625
-0.51111 0.4697341 -4.01111 5.269866 -2.45265 -0.14598 0.172521 1 -4.52223 8.050969 -8.69185 8.078345 10.50975 0.011427 0.030469
-0.49969 0.5002021 -3.99969 5.248792 -2.4984 -0.00112 0.000855 1 -4.49937 7.99727 -8.74513 8.36895 9.548493 -0.00031 -0.0002
-0.5 0.51 -4 5.25 -2.5 4.88E-07 -4.6E-07 1 -4.5 8.000001 -8.75 8.375002 9.562502 6.53E-08 1.04E-08
-0.5 0.51 -4 5.25 -2.5 3.91E-14 -5.6E-14 1 -4.5 8 -8.75 8.375 9.5625 -1.1E-14 -1.7E-14
x 3 4 x 2 5.25x 2.5 0
a3 a2 a1 a0
1 -4 5.25 -2.5
R s b3 b2 b1 b0 c3 c2 c1 Det dr ds
-0.5 0.5 1 -4.5 8 -8.75 1 -5 11 14 2.232143 3.160714
1.732143 3.660714 1 -2.26786 4.982462 -2.17164 1 -0.53571 7.715242 -7.42825 -0.06698 -5.01834
1.665164 -1.35763 1 -2.33484 0.004486 0.677311 1 -0.66967 -2.46826 2.916716 0.233247 0.151713
1.898411 -1.20592 1 -2.10159 0.054404 0.137621 1 -0.20318 -1.53723 1.578508 0.094187 -0.03527
1.992598 -1.24118 1 -2.0074 0.008871 0.009231 1 -0.0148 -1.26181 1.262029 0.007418 -0.00876
2.000017 -1.24994 1 -1.99998 5.5E-05 -2.1E-05 1 3.32E-05 -1.24982 1.249824 -1.7E-05 -5.5E-05
2 -1.25 1 -2 2.75E-10 2.38E-09 1 -3.8E-09 -1.25 1.25 1.9E-09 -2.8E-10
2 -1.25 1 -2 0 0 1 0 -1.25 1.25 0 0
x 3 4 x 2 5.25 x 2.5 0
( x 2 2 x 1.25)( x 2) 0
x 2 2 x 1.25 0
2 45 2i
Roots 1 0.5 i
2 2
LINEAR ALGEBRAIC EQUATION
Gauss Elimination Method (Direct method)
7 x1 2 x 2 3x3 12
2 x1 5 x 2 3x3 20
x1 x 2 6 x3 26
Example 1
7 x1 2 x 2 3x3 12
2 x1 5 x 2 3x3 20
x1 x 2 6 x3 26
Gauss Elimination
7 2 -3 -12
2 5 -3 -20
1 -1 -6 -26
7 2 -3 -12
0 4.428571 -2.14286 -16.5714
0 -1.28571 -5.57143 -24.2857
7 2 -3 -12
0 4.428571 -2.14286 -16.5714
0 0 -6.19355 -29.0968
X3= 4.697917
X2= -1.46875
X1= 0.71875
LU Decomposition method
Example 1
A LU
1 0 0 u11 u12 u13
21 1 0 0 u22 u23
31 32 1 0 0 u33
The U matrix is the same as found at the end of the forward elimination of Naï
ve
Gauss elimination method, that is
25 5 1
U 0 4.8 1.56
0 0 0.7
To find 21 and 31 , find the multiplier that was used to make the a 21 and a 31
elements zero in the first step of forward elimination of the Naï ve Gauss elimination
method. It was
64
21
25
2.56
144
31
25
5.76
To find 32 , what multiplier was used to make a32 element zero? Remember a 32
element was made zero in the second step of forward elimination. The A matrix at
the beginning of the second step of forward elimination was
25 5 1
0 4.8 1.56
0 16.8 4.76
So
16.8
32
4.8
3.5
Hence
1 0 0
L 2.56 1 0
5.76 3.5 1
Confirm LU A .
1 00 25 5 1
LU 2.56 1
0 0 4.8 1.56
5.76 3.5 1 0 0 0.7
25 5 1
64 8 1
144 12 1
Example 2
Use the LU decomposition method to solve the following simultaneous linear
equations.
25 5 1 a1 106.8
64 8 1 a 177.2
2
144 12 1 a3 279.2
Solution
Recall that
AX C
and if
A LU
then first solving
LZ C
and then
U X Z
gives the solution vector X .
Now in the previous example, we showed
A LU
1 0 0 25 5 1
2.56 1 0 0 4.8 1.56
5.76 3.5 1 0 0 0.7
First solve
LZ C
1 0 0 z1 106.8
2.56 1 0 z 177.2
2
5.76 3.5 1 z 3 279.2
to give
z1 106.8
2.56z1 z2 177.2
5.76z1 3.5z2 z3 279.2
Forward substitution starting from the first equation gives
z1 106.8
z2 177.2 2.56z1
177.2 2.56 106.8
96.208
z3 279.2 5.76z1 3.5z2
279.2 5.76 106.8 3.5 96.208
0.76
Hence
z1
Z z 2
z 3
106.8
96.208
0.76
This matrix is same as the right hand side obtained at the end of the forward
elimination steps of Naï ve Gauss elimination method. Is this a coincidence?
Now solve
U X Z
25 5 1 a1 106.8
0 4.8 1.56 a 96.208
2
0 0 0.7 a3 0.76
25a1 5a2 a3 106.8
4.8a2 1.56a3 96.208
0.7a3 0.76
From the third equation
0.7a3 0.76
0.76
a3
0.7
1.0857
Substituting the value of a3 in the second equation,
4.8a2 1.56a3 96.208
96.208 1.56a3
a2
4.8
96.208 1.56 1.0857
4.8
19.691
Substituting the value of a 2 and a3 in the first equation,
25a1 5a2 a3 106.8
106.8 5a 2 a3
a1
25
106.8 5 19.691 1.0857
25
0.29048
Hence the solution vector is
a1 0.29048
a 19.691
2
a3 1.0857
25 5 1 b11 1
64 8 1 b 0
21
144 12 1 b31 0
First solve
LZ C ,
that is
1 0 0 z1 1
2.56 1 0 z 0
2
5.76 3.5 1 z 3 0
to give
z1 1
2.56 z1 z 2 0
5.76 z1 3.5z 2 z3 0
Forward substitution starting from the first equation gives
z1 1
z2 0 2.56z1
0 2.561
2.56
z3 0 5.76 z1 3.5z 2
0 5.761 3.5 2.56
3.2
Hence
z1
Z z 2
z 3
1
2.56
3.2
Now solve
U X Z
that is
25 5 1 b11 1
0 4.8 1.56 b 2.56
21
0 0 0.7 b31 3.2
25b11 5b21 b31 1
4.8b21 1.56b31 2.56
0.7b31 3.2
Backward substitution starting from the third equation gives
3.2
b31
0.7
4.571
2.56 1.56b31
b21
4.8
2.56 1.56(4.571)
4.8
0.9524
1 5b21 b31
b11
25
1 5(0.9524) 4.571
25
0.04762
Hence the first column of the inverse of A is
b11 0.04762
b 0.9524
21
b31 4.571
Similarly by solving
25 5 1 b12 0 b12 0.08333
64 8 1 b 1 gives b 1.417
22 22
144 12 1 b32 0 b32 5.000
and solving
25 5 1 b13 0 b13 0.03571
64 8 1 b 0 gives b 0.4643
23 23
144 12 1 b33 1 b33 1.429
Hence
0.04762 0.08333 0.03571
A 0.9524 1.417 0.4643
1
The first step is to solve the first equation for x1, the second for x2, and the
third for x3 when the system becomes:
.
xl = 0, x2 = 0 and x3 = 0.
Inserting these values into the right-hand side of Equation (1) yields xl = 1.3.
This value for xl is used immediately together with the remainder of the initial
solution (i.e., x2 = 0 and x3 = 0) in the right-hand side of Equation (2) and
yields x2 =1.3 - 0.2 x 1.3 - 0 = 1.04. Finally, the values xl = 1.3 and x2 = 1.04
are inserted into Equation (3) to yield x3 = 0.936. This second approximate
solution (1.3, 1.04, 0.936) completes the first iteration.
Convergence
The sequence of solutions produced by the iterative process for the above
numerical example are shown in the table:
The student should check that the exact solution for this system is (1,1,1). It
is seen that the Gauss-Seidel solutions are rapidly approaching these values;
in other words, the method is converging.
Example 2
10x1 − x2 + 2x3 =6
− x1 + 11x2 − x3 + 3x4 = 25
2x1 − x2 + 10x3 − x4 = − 11
3x2 − x3 + 8x4 = 15
x1 = x2 / 10 − x3 / 5 + 3 / 5
x2 = x1 / 11 + x3 / 11 − 3x4 / 11 + 25 / 11
x3 = − x1 / 5 + x2 / 10 + x4 / 10 − 11 / 10
x4 = − 3x2 / 8 + x3 / 8 + 15 / 8
Suppose we choose (0,0,0,0) as the initial approximation, then the first approximate
solution is given by
x1 = 3 / 5 = 0.6,
x2 = (3 / 5) / 11 + 25 / 11 = 3 / 55 + 25 / 11 = 2.3272,
x3 = − (3/5)/5 + (2.3272) /10 − 1/10 = − 3 /25+0.23272−1.1= − 0.9873,
x4 = − 3(2.3272) / 8 + ( − 0.9873) / 8 + 15 / 8 = 0.8789.
Using the approximations obtained, the iterative procedure is repeated until the desired
accuracy has been reached. The following are the approximated solutions after four
iterations.
x1 x2 x3 x4
Initial
value 0.0 0.0 0.0 0.0
Cramer’s Rule
Determinants can be used to solve a linear system of equations using Cramer’s Rule.
where
When solving a system of equations using Cramer’s Rule, remember the following:
1. Three different determinants are used to find x and y. The determinants in the
denominators are identical.
2. The elements of D, the determinant in the denominator, are the coefficients of the
variables in the system; coefficients of x in the first column and coefficients of y in the
second column.
5x – 4y = 2
6x – 5y = 1
Solution. We begin by setting up and evaluating the three determinants
:
Cramer’s Rule does not apply if D = 0. When D = 0, the system is either inconsistent or
dependent. Another method must be used to solve it.
3x + 6y = -1
2x + 4y = 3
Since D = 0, Cramer’s Rule does not apply. We will use elimination to solve the
system.
3x + 6y = -1
2x + 4y = 3
6x + 12y = -2 Simplify
-6x – 12y = -9
Cramer’s Rule can be generalized to systems of linear equations with more than two
variables. Suppose we are given a system with the determinant of the coefficient matrix
D. Let denote the determinant of the matrix obtained by replacing the column
containing the coefficients of "n" with the constants from the right sides of the
equations. Then we have the following result:
the formulas
4x - y + z = -5
2x + 2y + 3z = 10
5x – 2y + 6z = 1
= 72 – 3 – 14
= 55
= -5(18)+1(57) + 1(-22)
= -90 + 57 – 22
= -55
= 228 - 15 – 48
= 165
= 88 – 48 + 70
= 110
Substitute these four values into the formula from Cramer’s Rule:
First Order
( x x1 ) ( x x0 )
f 1 ( x) f ( x0 ) f ( x1 )
( x0 x1 ) ( x1 x 0 )
(4 5) (4 3)
f 1 (4) 5.25 19.75 12.5
(3 5) (5 3)
Second Order
( x x1 )( x x 2 ) ( x x0 )( x x 2 ) ( x x0 )( x x1 )
f 2 ( x) f ( x0 ) f ( x1 ) f ( x2 )
( x0 x1 )( x0 x 2 ) ( x1 x0 )( x1 x 2 ) ( x 2 x0 )( x 2 x1 )
(4 3)(4 5) (4 2)(4 5) (4 2)(4 3)
f 2 (4) 4.0 5.25 19.75
(2 3)(2 5) (3 2)(3 5) (5 2)(5 3)
4 19.75
f 2 (4) 5.25 10.5
3 3
Third Order
( x x1 )( x x2 )( x x3 ) ( x x0 )( x x2 )( x x3 )
f 3 ( x) f ( x0 ) f ( x1 )
( x0 x1 )( x0 x2 )( x0 x3 ) ( x1 x0 )( x1 x2 )( x1 x3 )
( x x0 )( x x1 )( x x3 ) ( x x0 )( x x1 )( x x2 )
f ( x2 ) f ( x3 )
( x2 x0 )( x2 x1 )( x2 x3 ) ( x3 x0 )( x3 x1 )( x3 x2 )
(4 3)(4 5)(4 6) (4 2)(4 5)(4 6)
f 3 (4) 4.0 5.25
(2 3)(2 5)(2 6) (3 2)(3 5)(3 6)
(4 2)(4 3)(4 6) (4 2)(4 3)(4 5)
19.75 36
(5 2)(5 3)(5 6) (6 2)(6 3)(6 5)
2 39.5
f 3 (4) 3.5 6 10
3 3
Numerical Integration
Trapezoidal Rule
ba
I f (a) 2 f (a1 ) 2 f (a2 ) 2 f (a3 ) ... 2 f (an1 ) f (b)
2n
Simpson’s Rule
ba
I f (a) 4 f (a1 ) 2 f (a2 ) 4 f (a3 ) ... 2 f (an1 ) f (b)
3n
Gauss-Legendre Formula
x a0 a1 x d
ba ba
a0 and a1
2 2
ba
dx dx d
2
Two Point
1 1
w0 w1 1 x0 and x1
3 3
Three Point
5 8
w0 w2 w1 x0 0.6 x1 0 and x2 0.6
9 9
Four Point
w0 w3 0.3478548 w1 w2 0.6521452
x0 0.861136312 x1 0.339981044
x2 0.339981044 x3 0.861136312
n=2 Rule
where
n=3 Rule
where
n=4 Rule
where
n=5 Rule
where
Problem
Integrate the following function both analytically and numerically. Use both the
trapezoidal and Simpson’s 1/3 rules to numerically integrate the function. For
both cases, use the multiple application version, with n = 4.
3
xe
2x
dx
0
Two Point
1 1
c 0 c1 1 x0 and x1
3 3
1
1 3 1 3 1 3 1 3
1
I 2.25 1 e 1 e 406.2950216
3 3
504.5359919 406.2950216
Error 100 19.47154848
504.5359919
Three Point
5 8
c0 c 2 c1 x 0 0.6 x1 0 and x 2 0.6
9 9
5
I 2.25 1 0.6 e 31 0.6 e 3 1 0.6 e 31 0.6 495.8203637
8 5
9 9 9
504.5359919 495.8203637
Error 100 1.727454197
504.5359919
Four Point
c0 c3 0.3478548 c1 c2 0.6521452
x0 0.861136312 x1 0.339981044
x2 0.339981044 x3 0.861136312
I 2.25 c0 1 x0 e 31 x0 c1 1 x1 e 31 x1 c2 1 x2 e 31 x2 c3 1 x3 e 31 x3
I 504.1305
504.5359919 504.1305
Error 100 0.080369264
504.5359919
Ordinary Differential Equation
f x, y
dy
dx
When the function involves one independent variable the equation is called ODE
When it involves two or more independent variable the equation is called PDE
Differential equation are also classified as to their order. The above equation is called
a first order equation because the highest derivative is the first derivative.
One simple approach to solve the given differential equation by numerical technique is
to predict new value based on slope f x, y , old value and step size.
In mathematical form
This formula can be applied step by step to compute the trajectory of the solution.
Euler’s Method
Problem 1
dy
f ( x, y) 2 x 3 12 x 2 20 x 8.5, y(0) 1 Compute y(o.5)
dx
Analytical Solution y 0.5x 4 4 x 3 10 x 2 8.5x 1
xi 0 yi 1 h 0.5
f xi , yi f 0,1 8.5
y 0.5 1 8.5 0.5 5.25
f xi , yi f 0.5,5.25 1.25
y1 5.25 1.25 0.5 5.875
Problem 2
dy
(1 x) y , y (0) 1
dx
Analytical Solution y
16
1 2
x 2x 4
2
xi 0 yi 1 h 0.5
k1 f (0,1) 1
This value is used to calculate y and slope at midpoint.
1
y 0.25 1 1 0.5 1.25
2
k 2 f (0.25,1.25) (1 0.25) 1.25 1.397542486
This slope in turn is used to compute another value of y and another slope at
midpoint.
1
y 0.25 1 1.397542486 0.5 1.349385621
2
k 3 f (0.25,1.349385621) (1 0.25) 1.349385621 1.452038234
This slope is used to compute the value of y and slope at the end of interval.
y 0.5 1 1.452038234 0.5 1.726019117
k 4 f (0.5,1.726019117) (1 0.25) 1.726019117 1.970670701
Finally four slope estimates are combined to yield an average slope. This
average slope is used to make the final prediction at the end of interval.
1
(k1 2k 2 2k 3 k 4 )
6
1
(1 2(1.397542486 1.452038234) 1.970670701) 1.444972024
6
X Y k1 k2 k3 k4 Y-Analytical Error
0 1 1 1.397542 1.452038 1.970671 1
0.5 1.722486 1.968653 2.604297 2.696114 3.504593 1.72265625 0.009882
1 3.061992 3.499709 4.464376 4.599082 5.788746 3.0625 0.016601
1.5 5.346606 5.780682 7.166785 7.34734 9.010132 5.34765625 0.019641
2 8.998195 8.999097 10.89985 11.12771 13.35609 9 0.020059
Problem 3
dy
f ( x, y ) 4e0.8 x 0.5 y,
dx
y (0) 2 Compute y (o.5)
Analytical Solution y
1
13
40e 0.8 x 14e 0.5 x
xi 0 yi 2 h 0.5
k1 f (0,2) 4 1 0.5 2 3
This value is used to calculate y and slope at midpoint.
1
y0.25 2 3 0.5 2.75
2
k2 f (0.25,2.75)
k2 4 e0.80.25 0.5 2.75 3.510611033
This slope in turn is used to compute another value of y and another slope at midpoint.
1
y0.25 2 3.510611033 0.5 2.877652758
2
k3 f (0.25,2.877652758)
k3 4 e0.80.25 0.5 2.877652758 3.446784654
This slope is used to compute the value of y and slope at the end of interval.
y0.5 2 3.446784654 0.5 3.723392327
k4 f (0.5,3.723392327)
k4 4 e0.80.5 0.5 3.723392327
k4 4.105602627
Finally four slope estimates are combined to yield an average slope. This average slope is used
to make the final prediction at the end of interval.
1
(k1 2k 2 2k 3 k 4 )
6
1
(3 2(3.510611033 3.446784654) 4.105602627) 3.503399
6