NUMERICAL METHODS FOR FIRST ORDER DIFFERENTIAL EQUATIONS 463
I
A graph of the solution of
dy
dx
+y= 2 x, with initial
conditionsx=0 andy=1 is shown in Fig. 49.7.
0 0.2 0.4 0.6 0.8 1.0 x
0.5
1.0
y
Figure 49.7
Problem 3.
(a) Obtain a numerical solution, using
Euler’s method, of the differential equation
dy
dx
=y−x, with the initial conditions that
atx=0,y=2, for the rangex=0(0.1)0.5.
Draw the graph of the solution.
(b) By an analytical method (using the inte-
grating factor method of Chapter 48), the
solution of the above differential equation is
given byy=x+ 1 +ex.
Determine the percentage error atx= 0 .3.
(a)
dy
dx
=y′=y−x.
If initiallyx 0 =0 andy 0 =2,
then (y′) 0 =y 0 −x 0 = 2 − 0 = 2.
Hence line 1 of Table 49.3 is completed.
For line 2, wherex 0 = 0 .1:
y 1 =y 0 +h(y′) 0 , from equation (2),
= 2 +(0.1)(2)=2.2
and (y′) 0 =y 0 −x 0
= 2. 2 − 0. 1 =2.1
Table 49.3
x 0 y 0 (y′) 0
- 0 2 2
- 0.1 2.2 2.1
- 0.2 2.41 2.21
- 0.3 2.631 2.331
- 0.4 2.8641 2.4641
- 0.5 3.11051
For line 3, wherex 0 = 0 .2:
y 1 =y 0 +h(y′) 0
= 2. 2 +(0.1)(2.1)=2.41
and (y′) 0 =y 0 −x 0 = 2. 41 − 0. 2 =2.21
For line 4, wherex 0 = 0 .3:
y 1 =y 0 +h(y′) 0
= 2. 41 +(0.1)(2.21)=2.631
and (y′) 0 =y 0 −x 0
= 2. 631 − 0. 3 =2.331
For line 5, wherex 0 = 0 .4:
y 1 =y 0 +h(y′) 0
= 2. 631 +(0.1)(2.331)=2.8641
and (y′) 0 =y 0 −x 0
= 2. 8641 − 0. 4 =2.4641
For line 6, wherex 0 = 0 .5:
y 1 =y 0 +h(y′) 0
= 2. 8641 +(0.1)(2.4641)=3.11051
A graph of the solution of
dy
dx
=y−xwithx=0,
y=2 is shown in Fig. 49.8.
(b) If the solution of the differential equation
dy
dx
=y−xis given byy=x+ 1 +ex, then when
x= 0 .3,y= 0. 3 + 1 +e^0.^3 = 2 .649859.
By Euler’s method, whenx= 0 .3 (i.e. line 4 in
Table 49.3),y= 2 .631.
Percentage error
=
(
actual−estimated
actual
)
×100%
=
(
2. 649859 − 2. 631
2. 649859
)
×100%
=0.712%