Numerical methods for first order differential equations 463
This step by step Euler’s method can be continued
and it is easiest to list the results in a table, as shown
in Table 49.1. The results for lines 1 to 3 have been
produced above.
Table 49.1
x 0 y 0 (y′) 0
- 1 4 2
- 1.2 4.4 2.2
- 1.4 4.84 2.36
- 1.6 5.312 2.488
- 1.8 5.8096 2.5904
- 2.0 6.32768
For line 4,wherex 0 = 1 .6:
y 1 =y 0 +h(y′) 0
= 4. 84 +( 0. 2 )( 2. 36 )=5.312
and (y′) 0 = 3 ( 1 + 1. 6 )− 5. 312 =2.488
For line 5,wherex 0 = 1 .8:
y 1 =y 0 +h(y′) 0
= 5. 312 +( 0. 2 )( 2. 488 )=5.8096
and (y′) 0 = 3 ( 1 + 1. 8 )− 5. 8096 =2.5904
For line 6,wherex 0 = 2 .0:
y 1 =y 0 +h(y′) 0
= 5. 8096 +( 0. 2 )( 2. 5904 )
=6.32768
(As the range is 1.0 to 2.0 there is no need to calculate
(y′) 0 in line 6). The particular solution is given by the
value ofyagainstx.
A graph of the solution of
dy
dx
= 3 ( 1 +x)−ywith initial
conditionsx=1andy=4 is shown in Fig. 49.6.
In practice it is probably best to plot the graph as
each calculation is made, which checks that there is a
smooth progression and that no calculation errors have
occurred.
y
x
6.0
5.0
4.0
1.0 1.2 1.4 1.6 1.8 2.0
Figure 49.6
Problem 2. Use Euler’s method to obtain a
numerical solution of the differential equation
dy
dx
+y= 2 x, given the initial conditions that at
x=0,y=1, for the rangex= 0 ( 0. 2 ) 1 .0. Draw the
graph of the solution in this range.
x= 0 ( 0. 2 ) 1 .0 means thatxranges from 0 to 1.0 in equal
intervals of 0.2 (i.e.h= 0 .2 in Euler’s method).
dy
dx
+y= 2 x,
hence
dy
dx
= 2 x−y, i.e.y′= 2 x−y
If initiallyx 0 =0andy 0 =1, then
(y′) 0 = 2 ( 0 )− 1 =− 1.
Hence line 1 in Table 49.2 can be completed with
x= 0 ,y=1andy′( 0 )=−1.
Table 49.2
x 0 y 0 (y′) 0
- 0 1 − 1
- 0.2 0.8 −0.4
- 0.4 0.72 0.08
- 0.6 0.736 0.464
- 0.8 0.8288 0.7712
- 1.0 0.98304