C8
C8
differential equations
Some methods will be discussed in this course:
1
Example. Let y (x) be a function satisfying
2
y ′ (x) = x3 − x y (x) + (y (x)) , x ∈ (0, 1) ,
(⋆) {
y (0) = 2.2.
Find an approximation for y (0.1).
There are three methods discussed here:
• Euler’s method.
• Improved Euler’s method.
• Runge-Kutta method.
x0 x1 x2 x3 x10
0.1
2
Euler’s method.
≈ 2.6840 .
y (0.2) = y (x2)
≈ 3.3777.
3
Euler’s method.
4
Answer.
y (0.5) ≈ 10.0294
Implementation:
Y = Y + 0.1 (X 3 − XY + Y 2) ∶ X = X + 0.1
5
Improved Euler’s method
The idea of the improved Euler’s method: instead of using
first-order Taylor expansion, we consider second-order Taylor
expansion:
Example. Let y (x) be a function satisfying
2
y ′ (x) = x3 − x y (x) + (y (x)) , x ∈ (0, 1) ,
(⋆) {
y (0) = 2.2.
Find an approximation for y (0.1).
′ 1 2
≈ y (x0) + hy (x0) + h y” (x0)
2
≈ 2.7888.
6
Improved Euler’s method.
Implementation:
A = X + 0.1 ∶ B = Y + 0.1 (X 3 − XY + Y 2) ∶
0.1
Y =Y + (X 3 − XY + Y 2 + A3 − AB + B 2) ∶ X = A
2
8
Runge-Kutta method.
h Ak
Bk ∶= h f (xk + , yk + ) ,
2 2
h Bk
Ck ∶= h f (xk + , yk + ) ,
2 2
Dk ∶= h f (xk + h, yk + Ck ) .
10
Answer.
Thus
1
y1 = 0.3 + (A + 2B + 2C + D) = 0.4268.
6
11
Linear second-order boundary-value problem:
x0 x1 x2 x3 ⋯ xn
12
⇓
y (xk+1) − y (xk−1)
y ′ (xk ) ≈ (that’s why we call this method:
2h
finite-difference method).
13
yk+1 − 2yk + yk−1 yk+1 − yk−1
pk 2
+ q k + rk yk ≈ fk .
h 2h
p k qk 2pk p k qk
( 2 − ) yk−1+(rk − 2 ) yk +( 2 + ) yk+1 ≈ fk , 1 ≤ k ≤ n−1.
h 2h h h 2h
⎧
⎪ pk qk 2pk p k qk
⎪
⎪
⎪ ( 2 − ) yk−1 + (rk − 2 ) yk + ( 2 + ) yk+1 ≈ fk ,
⎪ h 2h
⎪
⎪ h h 2h
1 ≤ k ≤ n − 1,
⎨
⎪
⎪
⎪
⎪
⎪
⎪
⎩y0 = α, yn = β.
⎪
14
Example. Consider the linear second-order boundary-value
problem:
(x + 0.23) y” + x2y ′ − 1.23 y = 0.29x (x + 2) , 1 < x < 1.8,
{
y (1) = 0.27, y (1.8) = 1.67.
Use the finite-difference method with step size h = 0.2 to
approximate the values of y (1.2) , y (1.4) , y (1.6).
Answer. We have
16
Exercise.
1. Consider the Cauchy equation:
y ′ (x) = x2 + x y 3, x > 1,
{
y (1) = 0.7.
Use the Euler’s method with step size h = 0.2 to find an ap-
proximation for y (1.8).
2. Consider the Cauchy equation:
y ′ (x) = sin (x) + x2 y, x > 1,
{
y (1) = 0.3.
17
Answer.
1. y (1.8) ≈ 10.0387.
2. y (2.0) ≈ 7.6538.
3. y (1.2) ≈ 1.0879.
4. y (1.5) ≈ 0.3416, y (1.6) ≈ 0.5722, y (1.7) ≈ 0.7190.
18