Anda di halaman 1dari 20

Dr.

Satish Shukla 1 of 20

Engg. Math. II (Unit-V)

Numerical Analysis

Syllabus. Numerical Solution of ODE & PDE: Eulers Method for Numerical
Solution of ODE; Modified Eulers Method; Runge-Kutta Method (RK2, RK4),
Error estimate; Multi-step Methods: Predictor-Corrector method, Adams-Moulton
Method; Boundary Value Problems and Shooting Method; finite difference meth-
ods, numerical solutions of elliptic, parabolic, and hyperbolic partial differential
equations.

A differential equation of the following form:


dy
= f (x, y), where y(x0 ) = y0 (1)
dx
is called an initial value problem. Here, we consider several methods which give the nu-
merical solution of the initial value problem (1).

Eulers method by geometric approach. Eulers method is one of the oldest and simplest
method used to solve the problem (1).
Suppose, we have to find the values of solution y at point x0 , x1 , , xn , where the
points are equally spaced, i.e., x1 = x0 + h, x2 = x1 + h, , xn = xn1 + h and h is the
interval. The values of y corresponding to these values are y0 , y1 , . . . , yn .
Suppose, the solution of problem (1) is y = g(x). Then, the slope of tangent at any
dy
point of this curve will be: = f (x, y).
dx
Y
x)
g(
=
y

y1

y10 J
y0 I

X
O x0 x1

Therefore, the slope of tangent at point I(x0 , y0 ) is:


 
dy
tan = = f (x0 , y0 ).
dx x=x0

Consider the line IJ, where the coordinates of the point J are (x1 , y1 ). Then, the slope
of line IJ will be:
y1 y0 y1 y0 y1 y0
tan = = = approximately.
x1 x 0 h h
y1 y0
Therefore, f (x0 , y0 ) = , i.e.,
h
y1 = y0 + hf (x0 , y1 ).
Dr. Satish Shukla 2 of 20

In general,
yi = yi1 + hf (xi1 , yi1 ), i = 1, 2, . . . , n.
The above formula is called the Eulers formula.
Remark 1. We use the value y1 for y1 in the above formula. It is obvious that, higher
is the difference h = x1 x0 , more is the difference y1 y1 , i.e., for large value of
h, y1 and y1 are quite different and there is a significant error in the approximation
of the value of y1 . Therefore, for batter results, the interval h should be takes as
small as possible.

Eulers method by Taylors series (analytic approach). By Taylors series we know that:

h2 00
y(x + h) = y(x) + hy 0 (x) + y (x) + .
2!
If h is sufficient small we can neglect the terms containing higher powers of h, and so, we
have
y(x + h) = f (x) + hy 0 (x) = f (x) + hf (x, y(x)).
Putting x = xi1 we obtain: y(xi1 + h) = y(xi1 ) + hf (xi1 , y(xi1 )), i.e.

yi = yi1 + hf (xi1 , yi1 ), i = 1, 2, . . . , n.

Example 1. Find y(2.2) using Eulers method from the equation:

dy
= xy 2 with y(2) = 1.
dx

Sol. Here f (x, y) = xy 2 , x0 = 2, y0 = 1. Choose h = 0.04, then x1 = x0 + h = 2.04, x2 =


x1 + h = 2.08, x3 = x2 + h = 2.12, x4 = x3 + h = 2.16, x5 = x4 + h = 2.2. By Eulers
formula we have:

y1 = y(x1 ) = y(2.04) = y0 + hf (x0 , y0 ) = 1 + h(x0 y02 ) = 1 (0.04)(2 12 )


= 0.92.
y2 = y(x2 ) = y(2.08) = y1 + hf (x1 , y1 ) = 1 + h(x1 y12 ) = 0.92 (0.04)(2.04 0.922 )
= 0.8509.
y3 = y(x3 ) = y(2.12) = y2 + hf (x2 , y2 ) = 1 + h(x2 y22 ) = 0.8509 (0.04)(2.08 0.85092 )
= 0.7907.
y4 = y(x4 ) = y(2.16) = y3 + hf (x3 , y3 ) = 1 + h(x3 y32 ) = 0.7907 (0.04)(2.12 0.79072 )
= 0.7377.
y5 = y(x5 ) = y(2.2) = y4 + hf (x4 , y4 ) = 1 + h(x4 y42 ) = 0.7377 (0.04)(2.16 0.73772 )
= 0.6907.

Eulers Modified Method. Integrating (1) from x = x0 to x = x1 we get:


Zx1 Zx1 Zx1
dy = f (x, y)dx = [y]xx10 = f (x, y)dx
x0 x0 x0
Zx1
i.e., y1 y0 = f (x, y)dx. (2)
x0
Dr. Satish Shukla 3 of 20

Suppose f (x, y) = g(x), then by Trapezoidal rule (for n = 1)we have


Zx1 Zx1
h h
f (x, y)dx = g(x)dx = [g(x0 ) + g(x1 )] = [f (x0 , y0 ) + f (x1 , y1 )] .
2 2
x0 x0

On putting this value in (2) we get:


h
y1 = y0 + [f (x0 , y0 ) + f (x1 , y1 )] .
2
(0)
The approximate value of y1 in R.H.S., say, y1 of the above equation is obtained by
Eulers formula, i.e.,
(0)
y1 = y0 + hf (x0 , y0 ).
Therefore, the modified Eulers formula is given by

hh 
(0)
i
y1 = y0 + f (x0 , y0 ) + f x1 , y1 .
2
Similarly, y2 , y3 and other ordinates can be obtain.

Remark 2. To find y1 by Eulers modified method, first find the value of y1 by


(0)
Eulers method and denote this value by y1 . Now apply the above formula and find
y1 . Apply a similar process to find y2 and further ordinates.

dy
Example 2. Using Eulers modified method find y at x = 0.5 such that = x + y2,
dx
given y(0) = 1.

Sol. Here f (x, y) = x + y 2 , x0 = 0 and y0 = 1. We have to find y(0.5). Suppose h = 0.25


so that x1 = 0.25 and x2 = 0.5. Thus, we have to find y(0.5) = y(x2 ) = y2 . By Eulers
formula, we have
(0)
y1 = y0 + hf (x0 , y0 ) = 1 + h x0 + y02 = 1 + 0.25 0 + 12 = 1.25.
 

By Eulers modified formula we have:


hh 
(0)
i 0.25 
0 + 12 + 0.25 + 1.252

y1 = y0 + f (x0 , y0 ) + f x1 , y1 =1+
2 2
= 1.3516.

Again, by Eulers formula, we have


(0)
y2 = y1 + hf (x1 , y1 ) = 1.3516 + h x1 + y12 = 1.3516 + 0.25 0.25 + 1.35162 = 1.8708.
 

By Eulers modified formula we have:


hh 
(0)
i 0.25 
0.25 + 1.35162 + 0.5 + 1.87082

y2 = y1 + f (x1 , y1 ) + f x2 , y2 = 1.3516 +
2 2
= 2.1112.

Thus, y(0.5) = 2.1112.

dy
Example 3. Solve by Eulers modified method = ln(x + y), given y(1) = 2 for
dx
x = 1.2 and x = 1.4.
Dr. Satish Shukla 4 of 20

Sol. Here f (x, y) = ln(x + y), x0 = 1 and y0 = 2. We have to find y(1.2) and y(1.4).
Suppose h = 0.2 so that x1 = 1.2 and x2 = 1.4. Thus, we have to find y(1.2) = y(x1 ) = y1
and y2 = y(x2 ) = y(1.4) By Eulers formula, we have
(0)
y1 = y0 + hf (x0 , y0 ) = 2 + h ln (x0 + y0 ) = 2 + 0.2 ln (1 + 2) = 2.2197.
By Eulers modified formula we have:
hh 
(0)
i 0.2
y1 = y0 + f (x0 , y0 ) + f x1 , y1 =2+ [ln(1 + 2) + ln(1.2 + 2.2197)]
2 2
= 2.2328.
Again, by Eulers formula, we have
(0)
y2 = y1 + hf (x1 , y1 ) = 2.2328 + h ln (x1 + y1 ) = 2.2328 + 0.2 ln (1.2 + 2.2328) = 2.4794.
By Eulers modified formula we have:
hh 
(0)
i 0.2
y2 = y1 + f (x1 , y1 ) + f x2 , y2 = 2.2328 + [ln(1.2 + 2.2328) + ln(1.4 + 2.4794)]
2 2
= 2.4917.
Thus, y(1.2) = 2.2328 and y(1.4) = 2.4917.

Runge-Kutta Method method of order 4. In this method, to calculate the value of


y1 = y(x1 ) we use the following formulae:
1
y = (k1 + 2k2 + 2k3 + k4 )
6
k1 = hf (x0 , y0 )
 
h k1
k2 = hf x0 + , y0 +
2 2
 
h k2
k3 = hf x0 + , y0 +
2 2
k4 = hf (x0 + h, y0 + k3 ) .
Now, y1 isobtained by the formula:
y1 = y0 + k.
Similarly, y2 , y3 , . . . can be obtained.
Example 4. Apply Runge-Kutta fourth order method to find an appropriate value
dy
of y when x = 0.2 in steps of 0.1, where = x + y 2 , given y = 1 when x = 0.
dx

Sol. Here f (x, y) = x + y 2 , x0 = 0, y0 = 1 and h = 0.1. Therefore, x1 = x0 + h = 0.1,


x2 = x1 + h = 0.2 and we have to find y2 = y(0.2). Hence, we find this value in two steps:
Step I: We have
k1 = hf (x0 , y0 ) = (0.1)(x0 + y02 ) = 0.1
  "  2 #
h k1 0.1 0.1
k2 = hf x0 + , y0 + = (0.1) 0 + + 1+ = 0.11525
2 2 2 2
  "  2 #
h k2 0.1 0.11525
k3 = hf x0 + , y0 + = (0.1) 0 + + 1+ = 0.11686
2 2 2 2
k4 = hf (x0 + h, y0 + k3 ) = (0.1) [0 + 0.1 + (1 + 0.11686)] = 0.1347.
Dr. Satish Shukla 5 of 20

Therefore
1 1
y = (k1 + 2k2 + 2k3 + k4 ) = (0.1 + 2 0.11525 + 2 0.11686 + 0.1347) = 0.1165.
6 6
Therefore, y(0.1) = y1 = y0 + k = 1 + 0.1165 = 1.1165.
Step II: Now

k1 = hf (x1 , y1 ) = (0.1)(x1 + y12 ) = 0.13466


  "  2 #
h k1 0.1 0.13466
k2 = hf x1 + , y1 + = (0.1) 0.1 + + 1.1165 + = 0.15514
2 2 2 2
  "  2 #
h k2 0.1 0.15514
k3 = hf x1 + , y1 + = (0.1) 0.1 + + 1.1165 + = 0.15758
2 2 2 2
k4 = hf (x1 + h, y1 + k3 ) = (0.1) [0.1 + 0.1 + (1.1165 + 0.15758)] = 0.18233.

Therefore
1 1
y = (k1 + 2k2 + 2k3 + k4 ) = (0.13466 + 2 0.15514 + 2 0.15758 + 0.18233) = 0.1571.
6 6
Therefore, y(0.2) = y2 = y1 + k = 1.1165 + 0.1571 = 1.2736.

Example 5. Apply Runge-Kutta fourth order method to find y when x = 0.4, where
dy yx
= , given y(0) = 1.
dx y+x
yx
Sol. Here f (x, y) = , x0 = 0, y0 = 1 and let h = 0.4. Therefore, x1 = x0 + h = 0.4,
y+x
and we have to find y1 = y(0.4). We have
y 0 x0
k1 = hf (x0 , y0 ) = (0.4) = 0.4
y 0 + x0
" #
y0 + k21 x0 + h2
 
h k1
k2 = hf x0 + , y0 + = (0.4)  = 0.28571
2 2 y0 + k21 + x0 + h2
" #
y0 + k22 x0 + h2
 
h k2
k3 = hf x0 + , y0 + = (0.4)  = 0.28085
2 2 y0 + k22 + x0 + h2
 
y0 + k3 x0 h
k4 = hf (x0 + h, y0 + k3 ) = (0.4) = 0.20962.
y0 + k3 + x0 + h
Therefore
1 1
y = (k1 + 2k2 + 2k3 + k4 ) = (0.4 + 2 0.28571 + 2 0.28085 + 0.20962) = 0.29046.
6 6
Therefore, y(0.4) = y1 = y0 + k = 1 + 0.29046 = 1.29046.

Milnes Predictor-Corrector Method:


4h
(I) Predictor formula: y4 = y0 + [2y10 y20 + 2y30 ] .
3
h 0
(II) Corrector formula: y4 = y2 + [y + 4y30 + y40 ] .
3 2
Dr. Satish Shukla 6 of 20

Remark 3. To apply Milnes method, first find the values of y1 , y2 , y3 and y10 , y20 , y30
by any other method (e.g., Taylor series). Now by Predictor formula find y4 and so
y40 , and then apply the corrector formula and find the corrected value of y4 . To find
the y5 , replace the subscript in the predictor and corrector formulae by 1.

Example 6. Apply Milnes method to find a solution of the differential equation


dy
= x y 2 at point x = 0.8 for the condition y = 0 at x = 0.
dx

Sol. Here f (x, y) = x y 2 , x0 = 0, y0 = 0. We have to find the values of y at point


x = 0.8, so, let h = 0.2. Therefore x1 = x0 + h = 0.2, x2 = x1 + h = 0.4, x3 = x2 + h =
0.6, x4 = x3 + h = 0.8. To find the values of y1 , y2 and y3 we will use Taylor series:
(x x0 )2 00 (x x0 )3 000 (x x0 )4 iv (x x0 )5 v
y(x) = y0 +(xx0 )y00 + y0 + y0 + y0 + y0 + . (3)
2! 3! 4! 5!
Given that:
dy
y0 = = x y2 = y00 = x0 y02 = 0
dx
y 00 = 1 2yy 0 = y000 = 1 2y0 y00 = 1
y 000 = 2yy 00 2(y 0 )2 = y0000 = 2y0 y000 2(y00 )2 = 0
y iv = 2yy 000 6y 0 y 00 = y0iv = 2y0 y0000 6y00 y000 = 0
y iv = 2yy iv 8y 0 y 000 6(y 00 )2 = y0iv = 2y0 y0iv 8y00 y0000 6(y000 )2 = 6
etc.. On putting these values and x0 = 0 in (3) we get:
x2 x5
y(x) = + . (4)
2 20
Putting x = 0.2, 0.4, 0.6 in the above equation we get:
y1 = y(0.2) = 0.02, y2 = y(0.4) = 0.0795, y3 = y(0.6) = 0.176.
Therefore, by given equation we have:
y10 = y 0 (0.2) = x1 y12 = 0.2 (0.02)2 = 0.1996
y20 = y 0 (0.4) = x2 y22 = 0.4 (0.0.0795)2 = 0.3937
y30 = y 0 (0.6) = x3 y32 = 0.6 (0.176)2 = 0.5690.
Now, by predictor formula
4h
y4 = y0 + [2y10 y20 + 2y30 ]
3
4 0.2
= y0 + [2 0.1996 0.3937 + 2 0.5690]
3
= 0.3049.
Therefore y40 = x4 (y4 )2 = 0.8 (0.3049)2 = 0.7070.
Now, by corrector formula
h 0
y4 = y2 + [y2 + 4y30 + y40 ]
3
0.2
= 0.0795 + [0.3937 + 4 0.5690 + 0.7070]
3
= 0.3046.
Dr. Satish Shukla 7 of 20

Thus, y(0.8) = y4 = 0.3046.

dy
Example 7. Using Milnes method to find y(0.3) from = x2 + y 2 ; y(0) = 1. Find
dx
the initial values y(0.1), y(0.1) and y(0.2) from the Taylor series method.

Sol. Here f (x, y) = x2 + y 2 , h = 0.1, and so, x1 = 0.1, x1 = 0, x2 = 0.2, x3 = 0.3 and
y0 = y(x0 ) = 1 (given). We have to find the values of y at point x = 0.6. To find the
values of y1 , y1 and y2 we will use Taylor series:

(x x0 )2 00 (x x0 )3 000 (x x0 )4 iv (x x0 )5 v
y(x) = y0 +(xx0 )y00 + y0 + y0 + y0 + y0 + . (5)
2! 3! 4! 5!
Given that:
dy
y0 = = x2 + y 2 = y00 = x20 + y02 = 1
dx
y 00 = 2x + 2yy 0 = y000 = 2x0 + 2y0 y00 = 2
y 000 = 2 + 2yy 0 + 2(y 0 )2 = y0000 = 2 + 2y0 y00 + 2(y00 )2 = 8.

etc.. On putting these values and x0 = 0 in (5) we get:


4
y(x) = 1 + x + x2 + x3 + . (6)
3
Putting x = 0.1, 0.1, 0.2 in the above equation we get:

y1 = y(0.1) = 0.9087, y1 = y(0.1) = 1.1113, y2 = y(0.2) = 1.2506.

Therefore, by given equation we have:

y00 = y 0 (0) = x20 + y02 = (0)2 + (1)2 = 1


y10 = y 0 (0.1) = x21 + y22 = (0.1)2 + (1.1113)2 = 1.2449
y20 = y 0 (0.2) = x22 + y32 = (0.2)2 + (1.2506)2 = 1.6040.

Now, by predictor formula


4h
y3 = y1 + [2y00 y10 + 2y20 ]
3
4 0.1
= 0.9087 + [2 1 1.2449 + 2 1.6040]
3
= 1.4371.

Therefore y30 = x23 + (y3 )2 = (0.3)2 + (1.4371)2 = 2.1552.


Now, by corrector formula
h 0
y3 = y1 + [y1 + 4y20 + y30 ]
3
0.1
= 1.1113 + [1.2449 + 4 1.6040 + 2.1552]
3
= 1.4385.

Thus, y(0.3) = y4 = 1.43585.


Dr. Satish Shukla 8 of 20

Exercise (Assignment)

dy
(Q.1) Apply Eulers method and solve for x = 0.6 from = 1 2xy, y(0) = 0, take
dx
h = 0.2.
Ans. y(0.6) = 0.5226.

(Q.2) Apply Eulers modified method to compute y for x = 0.3 correct up to four places
dy
of decimals. Given = x + y, x0 = 0, y0 = 1.
dx
Hint. Take h = 0.3 Ans. y(0.3) = 1.39.

(Q.3) Apply Eulers modified method to compute y for x = 0.1 correct up to four places
dy yx
of decimals. Given = , with y(0) = 1.
dx y+x
Hint. Take h = 0.1
dy
(Q.4) Apply Runge-Kutta method of fourth order to solve 10 = x2 + y 2 , with y(0) = 1
dx
for x = 0.1
dy x2 + y 2
Hint. Re-write the equation like: = = f (x, y) and take h = 0.1 Ans.
dx 10
1.0101345.

(Q.5) Apply Runge-Kutta method to obtain y when x = 1.1 given that y = 1.2 when
dy
x = 1 and = 3x + y 2 .
dx
Hint. Take h = 0.1 Ans. 1.727.
dy
(Q.6) The differential equation = 1 + y 2 satisfies the following set of values of x and
dx
y:

x: 0 0.2 0.4 0.6


y: 0 0.2027 0.4228 0.6841

Compute y(0.8), using Milnes method.


Hint. Here x0 = 0, x1 = 0.2, x2 = 0.4, x3 = 0.6, x4 = 0.8 and given that y0 =
0, y1 = 0.2027, y2 = 0.4228, y3 = 0.6841. Ans. y(0.8) = 1.0294.
dy
(Q.7) Apply Milnes method to find the solution of = x + y, given y(0) = 0, for
dx
0.4 x 1.0 with h = 0.1.
Hint. First find y1 , y2 , y3 by Taylor series and then y4 by Milnes method. Now
again apply Milnes method for y4 , y5 , y6 , y7 Ans. y4 = 0.3117, y5 = 0.4245, y6 =
0.5573, y7 = 0.7183.
Dr. Satish Shukla 9 of 20

Numerical solutions of partial differential equations

Finite Difference Approximation or Numerical Approximation Schemes of Partial Deriva-


tives: Suppose, we have to approximate the partial derivatives in a rectangular region R
of xy-plane, where the boundary values of u, i.e., the values of u at the boundary of the
region R are given. We divide the region R into smaller rectangular regions with sides h
and k as shown in figure.
Y R

(i, j + 1) (i + 1, j + 1)

(i, j 1) (i, j) (i + 1, j)

(i 1, j 1) (i, j 1)

k
X
O
h

The points of intersection of the small squares are called the mesh points or nodal points
or grid points. Note that, the grid point (i, j) represent the point (xi , yj ) = (ih, jk). Since
h and k are constants, there is no harm in writing u(ih, jk) = u(i, j) = ui,j .
Keeping y constant and treating u(x, y) as a function of x only, by Taylors series we
know that:
u h2 2 u h3 3 u h4 4 u
u(x + h, y) = u(x, y) + h + + + + (7)
x 2! x2 3! x3 4! x4
Replace h by h in the above series we get:

u h2 2 u h3 3 u h4 4 u
u(x h, y) = u(x, y) h + + + (8)
x 2! x2 3! x3 4! x4
Similarly, keeping y constant and treating u(x, y) as a function of x only, by Taylors
series we know that:
u k2 2u k3 3u k4 4u
u(x, y + k) = u(x, y) + k + + + + (9)
y 2! y 2 3! y 3 4! y 4
Replace k by k in the above series we get:

u k2 2u k3 3u k4 4u
u(x, y k) = u(x, y) k + + + (10)
y 2! y 2 3! y 3 4! y 4

If the interval h is sufficient small, then neglecting h2 and other higher powers in (7) we
get:

u u(x + h, y) u(x, y)
=
x h
u ui+1,j ui,j
= = . (11)
x h
Dr. Satish Shukla 10 of 20

u
Equation (11) gives the forward difference approximation for .
x
Similarly, from equation (9) we obtain the the forward difference approximation for
u
given by:
y
u ui,j+1 ui,j
= . (12)
y k

Again, adding (7) and (8) and neglecting h4 and the other higher powers we get:

2u u(x + h, y) 2u(x, y) + u(x h, y)


2
=
x h2
2u ui+1,j 2ui,j + ui1,j
= 2
= . (13)
x h2
2u
Equation (13) gives the forward difference approximation for .
x2
Similarly, from equation (9) and (10) we obtain the the forward difference approxima-
2u
tion for given by:
y 2

2u ui,j+1 2ui,j + ui,j1


= . (14)
y 2 k2
Equations (11), (12), (13) and (14) are the finite difference approximation or approxima-
tion schemes of partial derivatives.

u
Remark 4. By subtracting (8) from (7), we obtain another approximation for
x
u ui+1,j ui1,j u ui,j+1 ui,j1
given by = . Similarly, = .
x 2h y 2k

Solution of Laplaces equation

The following equation:


2u 2u
2 u = + =0 (15)
x2 y 2
is called the Laplaces equation. This equation aries in potential and study state flow
problems. Suppose, we have to solve the equation (15) in a square region R of xy-plane,
where the boundary values of u, i.e., the values of u at the boundary of the region R are
given. We divide the region R into smaller square regions with sides h and k.
On putting the values of derivatives from (13) and (14) in (15) we get:
ui+1,j 2ui,j + ui1,j ui,j+1 2ui,j + ui,j1
+ =0
h2 k2
If we choose h = k then the above equation becomes:
1
[ui+1,j 2ui,j + ui1,j + ui,j+1 2ui,j + ui,j1 ] = 0
h2
1 
ui,j = ui+1,j + ui1,j + ui,j+1 + ui,j1 . (16)
4
Dr. Satish Shukla 11 of 20

The above formula is called the Standard Five Point Formula.


A similar formula some times used is called the Diagonal Five Point Formula and it
is given by:
1 
ui,j = ui+1,j+1 + ui+1,j1 + ui1,j+1 + ui1,j1 . (17)
4
Actually, in the standard five point formula, ui,j is the avg. of the values of u situated
at the middle points of the sides of square with center at ui,j . While, in the diagonal five
point formula, ui,j is the avg. of the values of u situated at end points of the diagonals of
square with center at ui,j . The following figure help to remember these formulae:

ui,j+1 ui1,j+1 ui+1,j+1

ui1,j ui,j ui+1,j ui,j

ui,j1 ui1,j1 ui+1,j1

Standard Five Point Formula Diagonal Five Point Formula.

Remark 5. In the problems, when we apply these formula then initially we have
to guess some values of u. We choose a formula from these two so that we have to
guess the minimum number of values of u, which gives more preciseness.

Example 8. Find the values u1 , u2 , u3 , u4 of u which satisfies the equation 2 u = 0,


where u is known on the boundary as shown below:
1000 1000 1000
1000

u1 u2
2000 500

u3 u4
2000 0

1000 0
500 0

Sol. First we find the value of u1 . Note that, if we apply the standard five point formula,
then we have to guess two values, namely, u2 and u3 . While, if we use the diagonal five
point formula, then we have to guess only one value, namely, u4 . Therefore, we calculate
(0)
the value of u1 by diagonal five point formula. Suppose, the initial guess u4 = 0. Then,
by diagonal five point formula we have
(1) 1 
u1 = 1000 + 0 + 2000 + 1000 = 1000.
4
Since u1 and u4 are now known, to find the value of u2 we use standard five point formula:
(1) 1 
u2 = 1000 + 500 + 1000 + 0 = 625.
4
Dr. Satish Shukla 12 of 20

Again, by standard five point formula:


(1) 1 
u3 = 1000 + 500 + 2000 + 0 = 875.
4
(1) 1 
u4 = 625 + 0 + 875 + 0 = 375.
4
Now, we carry out the successive iterations, using the standard five point formulae:
(n+1) 1 (n) (n) 
u1 = 1000 + u3 + 2000 + u2
4
(n+1) 1  (n+1) (n) 
u2 = u1 + 500 + 1000 + u4
4
(n+1) 1  (n+1) (n) 
u3 = u1 + 500 + 200 + u4
4
(n+1) 1  (n+1) (n+1) 
u4 = u2 + 0 + u3 +0 .
4
Putting n = 1 we have:
(2) 1 (1) (1) 
u1 = 1000 + u3 + 2000 + u2 = 1125
4
(2) 1  (2) (1) 
u2 = u1 + 500 + 1000 + u4 = 750
4
(2) 1  (2) (1) 
u3 = u1 + 500 + 200 + u4 = 1000
4
(2) 1  (2) (2) 
u4 = u2 + 0 + u3 + 0 438.
4
Putting n = 2 we have:
(3) 1 (2) (2) 
u1 = 1000 + u3 + 2000 + u2 = 1188
4
(3) 1  (3) (2) 
u2 = u1 + 500 + 1000 + u4 = 782
4
(3) 1  (3) (2) 
u3 = u1 + 500 + 200 + u4 = 1032
4
(3) 1  (3) (3) 
u4 = u2 + 0 + u3 + 0 454.
4
Putting n = 3 we have:
(4) 1 (3) (3) 
u1 = 1000 + u3 + 2000 + u2 1204
4
(4) 1  (4) (3) 
u2 = u1 + 500 + 1000 + u4 789
4
(4) 1  (4) (3) 
u3 = u1 + 500 + 200 + u4 1040
4
(4) 1  (4) (4) 
u4 = u2 + 0 + u3 + 0 458.
4
Putting n = 4 we have:
(5) 1 (4) (4) 
u1 = 1000 + u3 + 2000 + u2 1208
4
(5) 1  (5) (4) 
u2 = u1 + 500 + 1000 + u4 792
4
(5) 1  (4) (4) 
u3 = u1 + 500 + 200 + u4 1042
4
(5) 1  (4) (4) 
u4 = u2 + 0 + u3 + 0 458.
4
Dr. Satish Shukla 13 of 20

Thus, u1 = 1208, u2 = 792, u3 = 1042 and u4 = 458.

Example 9. Find the values u1 , u2 , u3 , u4 , u5 , u7 , u8 and u9 of u which satisfies the


equation 2 u = 0, where u is known on the boundary as shown below:
500 1000 500
0 0

u1 u2 u3
1000 1000

u4 u5 u6
2000 2000

u7 u8 u9
1000 1000

0 0
500 1000 500

Sol. In this problem, observe that the given values of u are symmetric about the central
horizontal and vertical lines. Therefore, due to this symmetry we can assume u1 =
u3 + u9 = u7 , u4 = u6 and u2 = u8 . Thus, the grid reduced into the following:
500 1000 500
0 0

u1 u2 u1
1000 1000

u4 u5 u4
2000 2000

u1 u2 u1
1000 1000

0 0
500 1000 500

First we find the value of u5 by standard five point formula. Then, by diagonal five point
formula we have
(1) 1 
u5 = 1000 + 1000 + 2000 + 2000 = 1500.
4
Now by diagonal five point formula:

(1) 1 (1) 
u1 = 0 + u5 + 1000 + 2000 = 1125.
4
By standard five point formula:

(1) 1 (1) (1) (1) 


u2 = 1000 + u5 + u1 + u1 = 1188.
4
By standard five point formula:

(1) 1  (1) (1) (1) 


u4 = u1 + u1 + 2000 + u5 = 1438.
4
Dr. Satish Shukla 14 of 20

Now, we carry out the successive iterations, using the standard five point formulae:

(n+1) 1 (n) (n) 


u1 = 500 + u4 + 1000 + u2
4
(n+1) 1 (1) (n+1) (n+1) 
u2 = 1000 + u5 + u1 + u1
4
(n+1) 1  (n+1) (n+1) (n) 
u4 = u1 + u1 + 1000 + u5
4
(n+1) 1  (n+1) (n+1) (n+1) (n+1) 
u5 = u2 + u2 + u4 + u4 .
4
Putting n = 1 we have:

(2) 1 (1) (1) 


u1 = 500 + u4 + 1000 + u2 = 1031
4
(2) 1 (1) (2) (2) 
u2 = 1000 + u5 + u1 + u1 = 1141
4
(2) 1  (2) (2) (1) 
u4 = u1 + u1 + 1000 + u5 = 1391
4
(2) 1  (2) (2) (2) (2) 
u5 = u2 + u2 + u4 + u4 = 1266.
4
Putting n = 2 we have:

(3) 1 (2) (2) 


u1 = 500 + u4 + 1000 + u2 = 1008
4
(3) 1 (2) (3) (3) 
u2 = 1000 + u5 + u1 + u1 = 1071
4
(3) 1  (3) (3) (2) 
u4 = u1 + u1 + 1000 + u5 = 1321
4
(3) 1  (3) (3) (3) (3) 
u5 = u2 + u2 + u4 + u4 = 1196.
4
Putting n = 3 we have:

(4) 1 (3) (3) 


u1 = 500 + u4 + 1000 + u2 = 975
4
(4) 1 (3) (4) (4) 
u2 = 1000 + u5 + u1 + u1 = 1037
4
(4) 1  (4) (4) (3) 
u4 = u1 + u1 + 1000 + u5 = 1287
4
(4) 1  (4) (4) (4) (4) 
u5 = u2 + u2 + u4 + u4 = 1162.
4
Putting n = 4 we have:

(5) 1 (4) (4) 


u1 = 500 + u4 + 1000 + u2 = 956
4
(5) 1 (4) (5) (5) 
u2 = 1000 + u5 + u1 + u1 = 1019
4
(5) 1  (5) (5) (4) 
u4 = u1 + u1 + 1000 + u5 = 1269
4
(5) 1  (5) (5) (5) (5) 
u5 = u2 + u2 + u4 + u4 = 1144.
4
Dr. Satish Shukla 15 of 20

Putting n = 5 we have:
(6) 1 (5) (5) 
u1 = 500 + u4 + 1000 + u2 = 947
4
(6) 1 (5) (6) (6) 
u2 = 1000 + u5 + u1 + u1 = 1010
4
(6) 1  (6) (6) (5) 
u4 = u1 + u1 + 1000 + u5 = 1260
4
(6) 1  (6) (6) (6) (6) 
u5 = u2 + u2 + u4 + u4 = 1135.
4
(8) (9) (8) (9) (8) (9)
Proceeding in similar manner, we get u1 = u1 = 938, u2 = u2 = 1001, u4 = u4 =
(8) (9)
1251 and u5 = u5 = 1126.

Solution of Poisson equation


The Poisson equation is given by
2u 2u
2 u = + = f (x, y).
x2 y 2
This equation aries when dealing with problems in magmatism, electricity, fluid mechanics
etc.. Using equations (13) and (14), taking h = k (square mesh) and following a similar
process as used in obtaining the solution of Laplace equation we get:
ui1,j + ui+1,j + ui,j1 + ui,j+1 4ui,j = h2 f (ih, jk). (18)
We first find the formulae for various values of u from the above iteration scheme, and
then we use the iteration process as we do in solution of Laplace equation.
Example 10. Find the values u1 , u2 , u3 and u4 of u which satisfies the equation
2 u = 10(x2 + y 2 + 19) over the square with sides x = 0 = y and x = 3 = y where
u is zero on the boundary and mesh length is 1.

Sol. We first draw the square with given sides and u with given values as follows:
Y

0 0 0
0

u1 u2
0 0
(1, 2) (2, 2)

u3 u4
0 (1, 1) (2, 1) 0

X
0 0 0 0

Here h = k = 1 and f (x, y) = 10(x2 + y 2 + 10), therefore, the iteration scheme will be:
ui1,j + ui+1,j + ui,j1 + ui,j+1 4ui,j = h2 f (ih, jk). (19)
Since ui,j = u(i, j) and u1 = u(1, 2), therefore to find the value of u1 we put i = 1, j = 2
in equation (20) we get:
u0,2 + u2,2 + u1,1 + u1,3 4u1,2 = f (1, 2)
= 0 + u2 + u3 + 0 4u1 = 150
1
= u1 = [u2 + u3 + 150].
4
Dr. Satish Shukla 16 of 20

Since ui,j = u(i, j) and u2 = u(2, 2), therefore to find the value of u2 we put i = 2, j = 2
in equation (20) we get:
u1,2 + u3,2 + u2,1 + u2,3 4u2,2 = f (2, 2)
= u1 + 0 + u4 + 0 4u2 = 180
1
= u2 = [u1 + u4 + 180].
4
Since ui,j = u(i, j) and u3 = u(1, 1), therefore to find the value of u3 we put i = 1, j = 1
in equation (20) we get:
u0,1 + u2,1 + u1,0 + u1,2 4u1,1 = f (1, 1)
= 0 + u4 + 0 + u1 4u3 = 120
1
= u3 = [u1 + u4 + 120].
4
Since ui,j = u(i, j) and u4 = u(2, 1), therefore to find the value of u4 we put i = 2, j = 1
in equation (20) we get:
u1,1 + u3,1 + u2,0 + u2,2 4u2,1 = f (2, 1)
= u3 + 0 + 0 + u2 4u4 = 150
1
= u4 = [u2 + u3 + 150].
4
From the above relations we have u1 = u4 , and so, we have to find only u1 , u2 , u3 . Now,
we carry out the successive iterations, using the above formulae:
(n+1) 1  (n) (n) 
u1 = u2 + u3 + 150
4
(n+1) 1  (n+1) 
u2 = 2u1 + 180
4
(n+1) 1  (n+1) 
u3 = 2u1 + 120 .
4
(1) (1)
Suppose, the initial guess u2 = u3 = 0. Putting n = 1 we have:
(2) 1  (1) (1) 
u1 = u2 + u3 + 150 = 37.5
4
(2) 1  (2) 
u2 = 2u1 + 180 = 63.75
4
(2) 1  (2) 
u3 = 2u1 + 120 = 48.75.
4
Putting n = 2 we have:
(3) 1  (2) (2) 
u1 = u2 + u3 + 150 = 65.63
4
(3) 1  (3) 
u2 = 2u1 + 180 = 77.82
4
(3) 1  (3) 
u3 = 2u1 + 120 = 62.82.
4
Putting n = 3 we have:
(4) 1  (3) (3) 
u1 = u2 + u3 + 150 = 74.66
4
(4) 1  (4) 
u2 = 2u1 + 180 = 81.33
4
(4) 1  (4) 
u3 = 2u1 + 120 = 66.33.
4
Dr. Satish Shukla 17 of 20

Putting n = 4 we have:
(5) 1  (4) (4) 
u1 = u2 + u3 + 150 = 74.42
4
(5) 1  (5) 
u2 = 2u1 + 180 = 82.21
4
(5) 1  (5) 
u3 = 2u1 + 120 = 67.21.
4
Putting n = 5 we have:
(6) 1  (5) (5) 
u1 = u2 + u3 + 150 = 74.86
4
(6) 1  (6) 
u2 = 2u1 + 180 = 82.43
4
(6) 1  (6) 
u3 = 2u1 + 120 = 67.43.
4
Putting n = 6 we have:
(7) 1  (6) (6) 
u1 = u2 + u3 + 150 = 74.97
4
(7) 1  (7) 
u2 = 2u1 + 180 = 82.48
4
(7) 1  (7) 
u3 = 2u1 + 120 = 67.49.
4
Therefore, u1 = u4 75, u2 82.5 and u3 67.5.

Solution of one dimensional heat equation (Difference scheme for heat diffusion
equation with rectangular meshes)

The following equation:


u 2u
= c2 2 (20)
t x
is called the Laplaces equation, where c2 is a constant called the diffusivity constant and
u = u(x, t) is the function of position x and time t.
We know that
u u(x, t + k) u(x, t) ui,j+1 ui,j
= = ,
t k k
2u u(x + h, t) 2u(x, t) + u(x h, t) ui+1,j 2ui,j + ui1,j
2
= 2
= .
x h h2
On putting these values in (20) we obtain
ui,j+1 ui,j ui+1,j 2ui,j + ui1,j
= c2
k h2
= h ui,j+1 = kc ui+1,j + (h 2kc2 )ui,j + kc2 ui1,j
2 2 2

kc2 2kc2 kc2


 
= ui,j+1 = 2 ui+1,j + 1 2 ui,j + 2 ui1,j .
h h h
kc2
Putting = in the above equation we get:
h2
ui,j+1 = ui+1,j + (1 2) ui,j + ui1,j .
Dr. Satish Shukla 18 of 20

With the above formula we can find the various values of u given with some boundary
conditions.
A particular case: If h and k are chosen such that c2 k = h2 for some value of c, then we
kc2 1
have = 2 = . Therefore, the above formula reduced to:
h 2
1
ui,j+1 = (ui+1,j + ui1,j ) .
2

Solution of Wave Equation and the iteration scheme for it


The following equation:
2u 2
2 u
=c (21)
t2 x2
where c is a constant and u = u(x, t), is called the wave equation.
We know that
2u u(x, t + k) 2u(x, t) + u(x, t k) ui,j+1 2ui,j + ui,j1
2
= 2
= ,
t k k2
2u u(x + h, t) 2u(x, t) + u(x h, t) ui+1,j 2ui,j + ui1,j
2
= 2
= .
x h h2
On putting these values in (21) we get:
ui,j+1 2ui,j + ui,j1 ui+1,j 2ui,j + ui1,j
2
= c2
k h2
2 2 2 2

ck ck
= ui,j+1 = 2 1 2 ui,j + 2 (ui1,j + ui+1,j ) ui,j1 .
h h
k
Putting = , we get
h
ui,j+1 = 2 1 2 c2 ui,j + 2 c2 (ui1,j + ui+1,j ) ui,j1 .


With the above formula we can find the various values of u given with some boundary
conditions.
k 1
A particular case: If h and k are chosen so that = = , then the above equation
h c
reduces into the following form:

ui,j+1 = ui1,j + ui+1,j ui,j1 .

Example 11. Evaluate the pivotal values of the equation utt = 16uxx taking h = 1
up to t = 1.25. The boundary conditions are u(0, t) = u(5, t) = 0, ut (x, 0) = 0 and
u(x, 0) = x2 (5 x).

Sol. Here c2 = 16 and h = 1. Choose k such that


k 1 h 1
= = , i.e., k = = = 0.25.
h c c 4
Since, we have to find the values of u up to t = 1.25, the value of t will increase in five
steps. Then, the iteration scheme for the wave equation will be:

ui,j+1 = ui1,j + ui+1,j ui,j1 . (22)


Dr. Satish Shukla 19 of 20

By the given boundary condition u(0, t) = u(5, t) = 0, therefore,


u0,j = u5,j = 0 for j = 0, 1, 2, 3, 4, 5. (23)
The above equation shows that the first and fifth columns of the table given below are all
zero.
Since u(x, 0) = x2 (5 x) we have
u0,0 = 0, u1,0 = 4, u2,0 = 12, u3,0 = 18, u4,0 = 16, u5,0 = 0. (24)
The above equation gives the entries of the first row (row for j 0) of the table given
below. ui,j+1 ui,j
Now ut (x, 0) = 0 = = 0 at j = 0
h
ui,1 ui,0
= =0
h
= ui,1 = ui,0 . (25)
The above equation shows that the entries of the first and second rows in the table are
same. In the table given below, now we find the second row (row for j = 1), and so,
putting j = 1 in (22) we get
ui,2 = ui1,1 + ui+1,1 ui,0 .
Putting i = 1 in the above equation we get:
u1,2 = u0,1 + u2,1 u1,0
= u1,2 = 0 + 12 4 = 8.
Putting i = 2 we get:
u2,2 = u1,1 + u3,1 u2,0
= u2,2 = 4 + 18 12 = 10.
Putting i = 3 we get:
u3,2 = u2,1 + u4,1 u3,0
= u3,2 = 12 + 16 18 = 10.
Putting i = 4 we get:
u4,2 = u3,1 + u5,1 u4,0
= u4,2 = 18 + 0 16 = 2.
To obtain the third row of the table, putting j = 2 in (22) we get:
ui,3 = ui1,2 + ui+1,2 ui,1 .
Putting i = 1 in the above equation we get:
u1,3 = u0,2 + u2,2 u1,1
= u1,3 = 0 + 10 4 = 6.
Putting i = 2 we get:
u2,3 = u1,2 + u3,2 u2,1
= u2,3 = 8 + 10 12 = 6.
Similarly, we obtain u3,3 = 6, u4,3 = 6,
u1,4 = 2, u2,4 = 8, u3,4 = 10, u4,4 = 2
u1,5 = 14, u2,5 = 18, u3,5 = 0, u4,5 = 4.
Dr. Satish Shukla 20 of 20

ui,j i=0 i=1 i=2 i=3 i=4 i=5

j=0 u0,0 = 0 u1,0 = 4 u2,0 = 12 u3,0 = 18 u4,0 = 16 u5,0 = 0

j=1 u0,1 = 0 u1,1 = 4 u2,1 = 12 u3,1 = 18 u4,1 = 16 u5,1 = 0

j=2 u0,2 = 0 u1,2 = 8 u2,2 = 10 u3,2 = 10 u4,2 = 2 u5,2 = 0

j=3 u0,3 = 0 u1,3 = 6 u2,3 = 6 u3,3 = 6 u4,3 = 6 u5,3 = 0

j=4 u0,4 = 0 u1,4 = 2 u2,4 = 8 u3,4 = 10 u4,4 = 2 u5,4 = 0

j=5 u0,5 = 0 u1,5 = 14 u2,5 = 18 u3,5 = 0 u4,5 = 4 u5,5 = 0

Exercise (Assignment)

2u 2u
(Q.1) Solve the elliptic equation 2 + 2 = 0 for the square mesh with boundary values
x y
as shown in the figure:
60 60 60
60

u1 u2
40 50

u3 u4
20 40

0 10 20 30

Ans. u1 = 43.31, u2 = 46.66, u3 = 26.66, u4 = 33.33.


2u 2u
(Q.2) Solve + 2 = 0 for the square mesh with boundary values as shown in the
x2 y
figure:

0 0 1
u1 u2 u3
0 2
u4 u5 u6
0 A B 2
u7 u8 u9
0 2

0 0 1

Ans. u1 = 43.31, u2 = 46.66, u3 = 26.66, u4 = 33.33.

Anda mungkin juga menyukai