Euler
Euler
DIFFERENTIAL EQUATIONS
dy y
1. Use Euler’s method to obtain a numerical solution of the differential equation = 3 – , with
dx x
the initial conditions that x = 1 when y = 2, for the range x = 1.0 to x = 1.5 with intervals of 0.1.
dy y
= y '= 3 −
dx x
2
If initially x 0 = 1 and y0 = 2, (and h = 0.1), then (y') 0 = 3 − =1
1
Line 1 in the table below is completed with x = 1.0 and y = 2
y0 2.1
and (y') 0 = 3 – =3– = 1.0909
x0 1.1
y0 2.209091
and (y') 0 = 3 – =3– = 1.159091
x0 1.2
1 dy
2. Obtain a numerical solution of the differential equation + 2y = 1, given the initial
x dx
1 dy dy
Since + 2y = 1 then = x(1 – 2y) or y´ = x(1 – 2y)
x dx dx
x y (y') 0
0 1 0
0.2 1 –0.2
0.4 0.96 –0.368
0.6 0.8864 –0.46368
0.8 0.793664 –0.469824
1.0 0.699692
1 dy
Hence a numerical solution to the differential equation + 2y = 1 is given by the first two
x dx
columns in the above table.
dy y
3. (a) The differential equation + 1 = – has the initial conditions that y = 1 at x = 2. Produce a
dx x
4 x
(b) If the solution of the differential equation by an analytical method is given by y = – ,
x 2
dy y dy y
(a) + 1 =− i.e. =y ' =−1 −
dx x dx x
1
If initially x 0 = 2.0 and y 0 = 1 (and h = 0.1), then (y') 0 = −1 − = –1.5
2.0
Line 1 in the table below is completed with x = 2.0 and y = 1
y0 0.85
and (y') 0 = –1 – = –1 – = –1.40476
x0 2.1
4 x
(b) If y = − then when x = 2.2, y = 0.718182
x 2
From the Euler method, when x = 2.2, y = 0.709524
= 1.206%
dy 2y
4. Use Euler’s method to obtain a numerical solution of the differential equation =x– ,
dx x
x2
If the solution of the differential equation is given by y = , determine the percentage error by
4
dy 2y
(a) = y '= x −
dx x
2(1)
If initially x 0 = 2.0 and y 0 = 1, (and h = 0.2), then (y') 0 = 2.0 − = 1.0
2.0
Line 1 in the table below is completed with x = 2.0 and y = 1
2(1.2)
and (y') 0 = 2.2 – = 1.109091
2.2
x2
(b) If y = , then when x = 2.8, y = 1.96
4
From the Euler method, when x = 2.8, y = 1.928718
= 1.596%
dy y
1. Apply the Euler–Cauchy method to solve the differential equation =3– for the range
dx x
dy y
= y '= 3 −
dx x
x 0 = 1, y 0 = 2 and h = 0.1
y0 2
(y ′) 0 = 3 − =3 − =1
x0 1
x 1 = 1.1 and from equation (3), page 836, y P1 = y 0 + h(y′) 0 = 2 + 0.1(1) = 2.1
1 1 yP
y C1 = y 0 + h [ (y′) 0 + f(x 1 , y P1 ) ] = y0 + h [ (y′) 0 + 3 − 1 ]
2 2 x1
1 2.1
=2+ (0.1) [ 1 + 3 − ]
2 1.1
= 2.10454546
yC1 2.10454546
(y′) 1 =−
3 =−
3 = 1.08677686
x1 1.1
Thus the first two lines of the table below have been completed
x y y′
1.0 2 1
1.1 2.10454546 1.08677686
1.2 2.216666672 1.152777773
1.3 2.33461539 1.204142008
1.4 2.457142859 1.244897958
1.5 2.5883333335
1 yP
y C1 = y 0 + h [ (y′) 0 + 3 − 1 ]
2 x1
yC1 2.216666672
(y ′) 1 =−
3 =−
3 = 1.152777773
x1 1.2
2. Solving the differential equation in Problem 1 by the integrating factor method gives
3 1
y= x+ . Determine the percentage error, correct to 3 significant figures, when x = 1.3 using
2 2x
3 1
If y = x+ then when x = 1.3, y = 2.334615385
2 2x
2.334615385 − 2.3250
Percentage error = ×100% = 0.412%
2.334615385
2.334615385 − 2.33461539
Percentage error = ×100% = 0.000000214%
2.334615385
dy
3. (a) Apply the Euler–Cauchy method to solve the differential equation – x = y for the range
dx
(b) The solution of the differential equation in part (a) is given by y = 2e x – x – 1. Determine the
dy
(a) = y' = y + x
dx
x 0 = 0, y 0 = 1 and h = 0.1
(y′) 0 = 1 + 0 = 1
x 1 = 0.1 and from equation (3), page 836, y P1 = y 0 + h(y ′) 0 = 1 + 0.1(1) = 1.1
1236 © 2014, John Bird
1 1
y C1 = y 0 + h [ (y ′) 0 + f(x 1 , y P1 ) ] = y0+ h [ (y′) 0 + y P1 + x 1 ]
2 2
1
=1+ (0.1) [ 1 + 1.1 + 0.1 ]
2
= 1.11
Thus the first two lines of the table below have been completed
1
y C1 = y 0 + h [ (y′) 0 + y P1 + x 1 ]
2
1
= 1.11 + (0.1) [ 1.21 + 1.231 + 0.2 ] = 1.24205
2
1.583649395 − 1.581804
Hence, the percentage error = ×100% = 0.117%
1.583649395
method in the range x = 0(0.2)1.0, given the initial conditions that x = 0 when y = 1
1 dy dy
Since + 2y = 1 then = x(1 – 2y) or y′ = x(1 – 2y)
x dx dx
x y (y') 0
0 1 0
0.2 0.98 – 0.192
0.4 0.925472 – 0.3403776
0.6 0.84854666 – 0.41825599
0.8 0.76433779 – 0.42294046
1.0 0.68609380
For line 2, x 1 = 0.2, and from equation (3), page 836, y P1 = y 0 + h(y′) 0 = 1 + 0.2(0) = 1
1 1
y C1 = y 0 + h [ (y′) 0 + f(x 1 , y P1 ) ] = y0+ h [ (y′) 0 + x 1 (1 – 2y P1 ) ]
2 2
1
=1+ (0.2) [ 0 + 0.2(1 – 2(1)) ]
2
= 0.98
For line 3, x 1 = 0.4, and from equation (3), page 836, y P1 = y 0 + h(y′) 0 = 0.98 + 0.2(– 0.192)
= 0.9416
1 1
y C1 = y 0 + h [ (y′) 0 + f(x 1 , y P1 ) ] = y0+ h [ (y ′) 0 + x 1 (1 – 2y P1 ) ]
2 2
1
= 0.98 + (0.2) [ – 0.192 + 0.4(1 – 2(0.9416)) ]
2
= 0.925472
For line 4, x 1 = 0.6, and from equation (3), page 836, y P1 = y 0 + h(y′) 0
= 0.925472 + 0.2(–0.3403776)
= 0.85739648
1 1
y C1 = y 0 + h [ (y′) 0 + f(x 1 , y P1 ) ] = y0+ h [ (y′) 0 + x 1 (1 – 2y P1 ) ]
2 2
1
= 0.925472 + (0.2) [ – 0.3403776 + 0.6(1 – 2(0.85739648)) ]
2
= 0.84854666
For line 5, x 1 = 0.8, and from equation (3), page 836, y P1 = y 0 + h(y′) 0
= 0.84854666 + 0.2(–0.41825599)
= 0.764895461
1 1
y C1 = y 0 + h [ (y′) 0 + f(x 1 , y P1 ) ] = y0 + h [ (y′) 0 + x 1 (1 – 2y P1 ) ]
2 2
1
= 0.84854666 + (0.2) [ –0.41825599 + 0.8(1 – 2(0.764895461)) ]
2
= 0.76433779
For line 6, x 1 = 1.0, and from equation (3), page 836, y P1 = y 0 + h(y′) 0
= 0.76433779 + 0.2(–0.42294046)
= 0.679749698
1 1
y C1 = y 0 + h [ (y′) 0 + f(x 1 , y P1 ) ] = y0+ h [ (y′) 0 + x 1 (1 – 2y P1 ) ]
2 2
= 0.68609380
dy y
1. Apply the Runge–Kutta method to solve the differential equation: = 3 − for the range
dx x
dy y
= 3−
dx x
= =
x1 1.1, =
x2 1.2, =
x3 1.3, =
x4 1.4 and x5 1.5
Let n = 0 to determine y1 :
dy y 2
2. k1 = f ( x0 , y0 ) = f (1, 2); since = 3 − , f (1, 2) = 3 – = 1
dx x 1
h h 0.1 0.1 2.05
3. k2 =f x0 + , y0 + k1 =f 1 + , 2+ (1) =f (1.05, 2.05 ) = 3 – = 1.047619
2 2 2 2 1.05
h h 0.1 0.1
4. k3 =f x0 + , y0 + k2 =f 1 + , 2+ (1.047619) = f (1.05, 2.05238095 )
2 2 2 2
2.05238095
=3– = 1.045351476
1.05
5. k4 = f ( x0 + h, y0 + hk3 ) = f (1 + 0.1, 2 + 0.1(1.045351476) ) = f (1.1, 2.1045351476)
2.1045351476
=3– = 1.086786229
1.1
h
6. yn +1 = yn + {k1 + 2k2 + 2k3 + k4 } and when n = 0:
6
h 0.1
y1 = y0 + {k1 + 2k2 + 2k3 + k4 } = 2 + { 1 + 2(1.047619) + 2(1.045351476) + 1.086786229}
6 6
0.1
=2+ { 6.272727181 } = 2.10454545
6
n xn yn
0 1.0 2.0
1 1.1 2.104545
2 1.2 2.216667
3 1.3 2.334615
4 1.4 2.457143
5 1.5 2.533333
1241 © 2014, John Bird
Lines 1 and 2 have now been completed in the above table
Let n = 1 to determine y2 :
dy y 2.104545
2. k1 = f ( x0 , y0 ) = f (1.1, 2.104545); since = 3 − , f (1.1, 2.104545) = 3 –
dx x 1.1
= 1.08677727
h h 0.1 0.1
3. k2 = f x0 + , y0 + k1 = f 1.1 + , 2.104545 + (1.08677727) = f (1.15, 2.15888386 )
2 2 2 2
2.15888386
=3– = 1.1227097
1.15
h h 0.1 0.1
4. k3 = f x0 + , y0 + k2 = f 1.1 + , 2.104545 + (1.1227097) = f (1.15, 2.1606805 )
2 2 2 2
2.1606805
=3– = 1.1211474
1.15
5. k4 = f ( x0 + h, y0 + hk3 ) = f (1.1 + 0.1, 2.104545 + 0.1(1.1211474) ) = f (1.2, 2.2166597)
2.2166597
=3– = 1.15278355
1.2
h
6. yn +1 = yn + {k1 + 2k2 + 2k3 + k4 } and when n = 0:
6
h
y1 = y0 + {k1 + 2k2 + 2k3 + k4 }
6
0.1
= 2.104545 + { 1.08677727 + 2(1.1227097) + 2(1.1211474) + 1.15278355}
6
0.1
= 2.104545 + { 6.72727045 } = 2.216667
6
Line 3 has now been completed in the above table. In a similar manner y3 , y4 and y5 can be
calculated.
1dy
2. Obtain a numerical solution of the differential equation: + 2y =
1 using the Runge–Kutta
x dx
method in the range x = 0(0.2)1.0, given the initial conditions that x = 0 when y = 1
1dy 1dy dy
If + 2y =
1 then = 1− 2 y and = x(1 − 2 y )
x dx x dx dx
Let n = 0 to determine y1 :
dy
2. k1 = f ( x0 , y0 ) = f (0, 1); since = x(1 − 2 y ) , f (0, 1) = 0(1 – 2) = 0
dx
h h 0.2 0.2
3. k2 =f x0 + , y0 + k1 =f 0+ , 1+ (0) =f ( 0.1, 1) = 0.1(1 – 2) = –0.1
2 2 2 2
h h 0.2 0.2
4. k3 = f x0 + , y0 + k2 = f 0 + , 1+ (−0.1) = f ( 0.1, 0.99 )
2 2 2 2
= 0.1(1 – 1.98) = –0.098
5. k4 = f ( x0 + h, y0 + hk3 ) = f ( 0 + 0.2, 1 + 0.2(−0.098) ) = f (0.2, 0.9804)
Let n = 1 to determine y2 :
dy
2. k1 = f ( x1 , y1 ) = f (0.2, 0.980395); since = x(1 – 2y),
dx
f (0.2, 0.980395) = 0.2(1 – 2(0.980395)) = –0.192158
h h 0.2 0.2
3. k2 = f x1 + , y1 + k1 = f 0.2 + , 0.980395 + (−0.192158) = f ( 0.3, 0.9611792 )
2 2 2 2
= 0.3(1 – 2(0.9611792) = –0.27670752
h h 0.2 0.2
4. k3 = f x1 + , y1 + k2 = f 0.2 + , 0.980395 + (−0.27670752)
2 2 2 2
= f ( 0.3, 0.952724248 ) = 0.3(1 – 2(0.952724248)) = –0.271634548
This completes the third row of the table below. In a similar manner y3 , y4 and y5 can be
calculated.
dy y
3. (a) The differential equation: + 1 =− has the initial conditions that y = 1 at x = 2.
dx x
Produce a numerical solution of the differential equation, correct to 6 decimal places, using
4 x
(b) If the solution of the differential equation by an analytical method is given by: y= − ,
x 2
dy y dy y y
(a) If + 1 =− then =− − 1 =− + 1
dx x dx x x
1. x0 = 2, y0 = 1 and since h = 0.1, and the range is from x = 2.0 to x = 2.5, then
= =
x1 2.1, =
x2 2.2, =
x3 2.3, =
x4 2.4 and x5 2.5
Let n = 0 to determine y1 :
dy y 1
2. k1 = f ( x0 , y0 ) = f (2, 1); since, =
− + 1 , f (2, 1) = − + 1 = –1.5
dx x 2
h h 0.1 0.1 0.925
3. k2 = f x0 + , y0 + k1 = f 2.0 + ,1.0 + (−1.5) = f ( 2.05, 0.925 ) = − + 1
2 2 2 2 2.05
= –1.451219512
0.854759072
= − + 1 = –1.40702813
2.1
h
6. yn +1 = yn + {k1 + 2k2 + 2k3 + k4 } and when n = 0:
6
h
y1 = y0 + {k1 + 2k2 + 2k3 + k4 }
6
0.1
= 1.0 + { − 1.5 + 2(−1.451219512) + 2(−1.45240928) + (−1.40702813) }
6
0.1
= 1.0 + { − 8.714285714 } = 0.854762
6
Let n = 1 to determine y2 :
dy y
2. k1 = f ( x1 , y1 ) = f (2.1, 0.854762); since =
− + 1 ,
dx x
0.854762
f (2.1, 0.854762) = − + 1 = –1.407029524
2.1
h h 0.1 0.1
3. k2 = f x1 + , y1 + k1 = f 2.1 + , 0.854762 + (−1.407029524)
2 2 2 2
0.784410523
= f(2.15, 0.784410523) = − + 1 = –1.364842104
2.15
h h 0.1 0.1
4. k3 = f x1 + , y1 + k2 = f 2.1 + , 0.854762 + (−1.364842104)
2 2 2 2
0.786519894
= f ( 2.15, 0.786519894 ) = − + 1 = –1.365823207
2.15
5. k4 = f ( x1 + h, y1 + hk3 ) = f ( 2.2, 0.854762 + 0.1(−1.365823207) )
0.718179679
= f (2.2, 0.718179679) = − + 1 = –1.326445309
2.2
h
6. yn +1 = yn + {k1 + 2k2 + 2k3 + k4 } and when n = 1:
6
h
y2 = y1 + {k1 + 2k2 + 2k3 + k4 }
6
This completes the third row of the table below. In a similar manner y3 , y4 and y5 can be
4 x
(b) If y = − when x = 2.2, y = 0.718182
x 2