Numerical Methods
Numerical Methods
Substitute the derivatives in a system of ordinary differential equations with finite difference schemes.
The ordinary differential equation then becomes a linear/non-linear system of algebraic equations.
Solve the system of algebraic equations. Implement and debug the computer code.
(1)
x j p j x j q j x j rj
Copyright to IJIRSET
(2)
www.ijirset.com
5305
ISSN: 2319-8753
xj
x j 1 x j 1
2h
Now consider the second derivative of central difference formula equation
x(t j )
xj
x j 1 2 x j x j 1
h2
o( h 2 )
(3)
o( h 2 )
(4)
o( h 2 )
(5)
x j 1 2 x j x j 1
h
o(h2 ) p(t j )(
x j 1 x j 1
2h
(6)
) q(t j ) x j r (t j )
(7)
And introduce the notation pj = p(tj), qj= q(tj) and rj = r(tj) in equation (7).
This produces the difference equation
x j 1 2 x j x j 1
x j 1 x j 1
(8)
pj (
) q j x j rj
2
h
2h
this is used to compute numerical approximation to the differential equation. This is carried out by multiplying each side of (8)
by h2, and then collecting terms involving xj-1, xj and xj+1 and arraying them in a system of linear equations.
(7) multiply by h2 gives
x j 1 2 x j x j 1
h
)h 2 h 2 [ p j (
x j 1 2 x j x j 1
equation (9) multiply by -1
x j 1 2 x j x j 1
x j 1 x j 1
2h
) q j x j rj ]
h
h
p j x j 1 p j x j 1 h2 q j x j h 2rj
2
2
(9)
h
h
p j x j 1 p j x j 1 h2 q j x j h2 rj
2
2
h
h
p j 1) x j 1 (2 h2 q j ) x j ( p j 1) x j 1 h 2 rj
2
2
(10)
h
h
p1 1) x0 (2 h 2 q1 ) x1 ( p1 1) x2 h 2 r1
2
2
(11)
h
h
p1 1) (2 h2 q1 ) x1 ( p1 1) x2 h 2 r1
2
2
(2 h2 q1 ) x1 (
h
h
p1 1) x2 h 2 r1 ( p1 1)
2
2
(2 h 2 q1 ) x1 (
Copyright to IJIRSET
h
p1 1) x2 h 2 r1 eo
2
www.ijirset.com
(12)
5306
ISSN: 2319-8753
e0 (
h
p1 1)
2
when j = N-1
h
h
( pN 1 1) xN 2 (2 h2 qN 1 ) xN 1 ( pN 1 1) xN h2 rN 1
2
2
And xN = , then the equation (13) becomes
h
h
( pN 1 1) xN 2 (2 h 2 qN 1 ) xN 1 h 2 rN 1 [ pN 1 1]
2
2
h
h
2
2
( pN 1 1) xN 2 (2 h qN 1 ) xN 1 h rN 1 [1 pN 1 ]
2
2
(
h2 rN 1 eN
h
pN 1 1) xN 2 (2 h 2 qN 1 ) xN 1 h 2 rN 1 eN
2
(13)
h
where eN [1
pN 1 ]
2
The system in equation (10), (12), (13) shows how the familiar triangle is formed, which is more visible when displayed with
matrix notations
2 h 2 q1
h
p1 1
2
h
h
p2 1
p2 1 2 h 2 q2
2
2
h
0
p3 1 2 h 2 q3
2
0
h
p j 1
2
where e0 (
...
...
...
...
h
p3 1
2
...
...
2 h 2 qJ
h
p j 1
2
...
h
pN 2 1 2 h 2 qN 2
2
x1
x
2
x3
x
j
xN 2
xN 1
h
pN 2 1
0
2
h
... pN 1 1 2 h 2 qN 1
2
h 2 r1 e0
h r2
h 2 r
h 2 r
h 2 rN 2
h rN 1 eN
(14)
h
h
pN 1 1)
p1 1) and eN (
2
2
0
...
2t
2
x(t )
x(t )
x(t ) 1 with x(0) = 1.25 and x(4) = -0.95 over the interval [0,4].
2
1 t
1 t2
A.
Copyright to IJIRSET
x(t )
2t
2
x(t )
x(t ) 1
1 t2
1 t2
(15)
x j p j x j q j x j rj
www.ijirset.com
(16)
5307
ISSN: 2319-8753
h
h
p j 1) x j 1 (2 h 2 q j ) x j ( p j 1) x j 1 h 2 rj
2
2
The finite-difference method is used to construct numerical solutions {x j} using the system of equations (10).There are 41
terms in the sequence generated with h 2 = 0.1, and the sequence {x j, 2 } only includes every other term from these
computations; they correspond to the 21 values of {t j} given in Table 1. Similarly, the sequences {x j.3 } and {xj, 4 } are a
portion of the values generated with step sizes h 3 = 0.05 and h 4 = 0.025, respectively, and they correspond to the 21 values
of {t j } in Table 1.
B. ANALYTIC (OR) EXACT SOLUTION FOR THE BOUNDARY VALUE PROBLEM
Next compare numerical solutions in Table 1 with the analytic solution. Let consider the equation (15), integrating twice
with respect to t to the limit 0 to 4 .
x(t)= 1.25+0.486089652t 2.25t2+2tarctan(t) ln (1+t2) +t 2ln (1+t)
(17)
Put t=0 ,x(0)=1.25000. Continuing this process the values are presented in the below table. Comparing the values of x (t), in
Table 1 and Table 2. The numerical solutions have error of order o (h2).
C. ERRORS IN NUMERICAL APPROXIMATION USING FINITE DIFFERENCE METHOD
results in the error being reduced by about . For instance, at tj = 1.0 the errors
Hence reducing the step size by a factor of
incurred with step sizes h1=0.2, h2 =0.1, h3 =0.05, and h4 =0.025 are
ej.1 = x(tj) xj,1 = 1.056886 - 1.042106 = 0.014780, e j.1 = 0.014780
e j,2 = x(tj) exact xj,2 = 1.056886 - 1.053226 =0.003660, e j,2 = 0.003660
e j,3 = x(tj) xj,3 = 1.056886 - 1.055973 = 0.000913, e j,3 = 0.000913 and
e j,4 = x(tj) xj,4 = 1.056886 - 1.056658 = 0.000228, e j,4 = 0.000228
Their successive ratios
are approaching
and
.
. A careful scrutiny of Table 3 will reveal that this is happening. And FIGURE-I shows that the
Copyright to IJIRSET
www.ijirset.com
5308
ISSN: 2319-8753
(22)
Finally, the third extrapolation involves the terms zj,1 and z j,2 :
(23)
This last computation contains six decimal places of accuracy. The values at the other points are given in Table 4.
Copyright to IJIRSET
www.ijirset.com
5309
ISSN: 2319-8753
2t
2
x(t )
x(t ) 1
1 t2
1 t2
0.0
xj,1
h1=0.2
1.250000
xj,2
h2=0.1
1.250000
xj,3
h3=0.05
1.250000
xj,4
h4=0.025
1.250000
0.2
1.314503
1.316640
1.317174
1.317306
0.4
1.320607
1.325045
1.326141
1.326414
0.6
1.272755
1.279533
1.281206
1.281623
0.8
1.177399
1.1896438
1.188670
1.189227
1.0
1.042106
1.053226
1.055973
1.056658
1.2
0.874878
0.887823
0.891023
0.891821
1.4
0.683712
0.698181
0.701758
0.702650
1.6
0.476372
0.494027
0.495900
0.496865
1.8
0.260264
0.276749
0.280828
0.281846
2.0
0.042399
0.059343
0.063537
0.064583
2.2
-0.170616
-0.153592
-0.149378
-0.148327
2.4
-0.372557
-0.355841
-0.351702
-0.350669
2.6
-0.557565
-0.541546
-0.537580
-0.536590
2.8
-0.720114
-0.705188
-0.701492
-0.700570
3.0
-0.854988
-0.841551
-0.838223
-0.837393
3.2
-0.957250
-0.945700
-0.942839
-0.942145
3.4
-1.022221
-1.012958
-1.010662
-1.010090
3.6
-1.045457
-1.038880
-1.37250
-1.086844
3.8
-1.022727
-1.019238
-1.018373
-1.018158
4.0
-0.950000
-0.950000
-0.950000
-0.950000
tj
Copyright to IJIRSET
www.ijirset.com
5310
ISSN: 2319-8753
x (tj)
1.2500
1.317350
1.326505
1.28762
1.189412
1.056886
0.892086
0.702947
0.497187
0.282184
0.064931
-0.147977
-0.350325
-0.536261
-0.700262
-0.837116
-0.941888
-1.009899
-1.036709
-1.018086
-0.950000
TABLE III
ERRORS IN NUMERICAL APPROXIMATIONS USING THE FINITE-DIFFERENCE METHOD
tj
0.0
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6
1.8
2.0
h 1 =0.2
0.000000
0.002847
0.005898
0.009007
0.012013
0.014780
0.017208
0.019235
0.020815
0.021920
0.022533
h 2 = 0.1
0.000000
0.000704
0.001460
0.002229
0.002974
0.003660
0.004263
0.004766
0.005160
0.005435
0.005588
Copyright to IJIRSET
x (t j ) xj,3 = ej,3
h 3 = 0.05
0.000000
0.000176
0.000364
0.000556
0.000742
0.000913
0.001063
0.001189
0.001287
0.001356
0.001394
www.ijirset.com
x (t j ) xj,4=ej,4
h 4 =0.025
0.000000
0.000044
0.000091
0.000139
0.000185
0.000228
0.000265
0.000297
0.000322
0.000338
0.000348
5311
ISSN: 2319-8753
0.022639
0.022232
0.021304
0.019852
0.017872
0.015362
0.012322
0.008749
0.004641
0.000000
0.005615
0.001401
0.000350
0.005516
0.001377
0.000344
0.005285
0.001319
0.000329
0.004926
0.001230
0.000308
0.004435
0.001107
0.000277
0.003812
0.000951
0.000237
0.003059
0.000763
0.000191
0.002171
0.000541
0.000135
0.001152
0.000287
0.000072
0.000000
0.000000
0.000000
TABLE IV
EXTRAPOLATION OF THE NUMERICAL APPLICATIONS {XJ,1 }, {XJ,2 },{XJ,3 }
OBTAINED WITH THE FINITE DIFFERENCE METHOD.
tj
0.0
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6
1.8
2.0
2.2
2.4
2.6
2.8
3.0
3.2
3.4
3.6
3.8
4.0
0.0
Copyright to IJIRSET
1.250000
1.317360
1.326524
1.281792
1.189451
1.056932
0.892138
0.703003
0.497246
0.282244
0.064991
0.147918
0.350268
0.536207
0.700213
0.837072
0.941850
1.009870
1.036688
1.018075
0.950000
1.250000
1.250000
1.317351
1.326506
1.281764
1.189414
1.056889
0.892090
0.702951
0.497191
0.282188
0.064935
0.147973
0.350322
0.536258
0.700259
0.837113
0.941885
1.009898
1.036707
1.018085
0.950000
1.250000
1.250000
1.317350
1.326504
1.281762
1.189412
1.056886
0.892086
0.702947
0.497187
0.282184
0.064931
0.147977
0.350325
0.536261
0.700263
0.837116
0.941888
1.009899
1.036708
1.018086
0.950000
1.250000
www.ijirset.com
x (t j )
Exact solution
1.250000
1.317350
1.326505
1.281762
1.189412
1.056886
0.892086
0.702948
0.497187
0.282184
0.064931
0.147977
0.350325
0.536261
0.700262
0.837116
0.941888
1.009899
1.036708
1.018086
0.950000
1.250000
5312
ISSN: 2319-8753
x(t)
0.5
-0.5
-1
-1.5
0.5
1.5
2
t
2.5
3.5
Copyright to IJIRSET
www.ijirset.com
5313