Numerical methods: Euler’s method

advertisement
LECTURE 9: EULER’S METHOD, AND SECOND ORDER LINEAR ODES
MINGFENG ZHAO
September 28, 2015
Numerical methods: Euler’s method
Consider the initial value problem:
y 0 = f (x, y),
y(x0 ) = y0 .
Recall Taylor expansion:
y(x + ∆x) = y(x) + y 0 (x)∆x +
y 00 (x)
(∆x)2 + · · · .
2
Let’s take the linear approximation at x, then
y(x + ∆x) ≈ y(x) + y 0 (x)∆x.
(1)
Euler’s method:
Given the initial condition y(x0 ) = y0 and the step size ∆x, for any k = 0, 1, 2, · · · , let yk = y(xk ) and
xk = xk−1 + ∆x = x0 + (k − 1)∆x.
Now we want to approximate yk : Replace x by xk in (1), then we get
yk+1 = yk + f (xk , yk )∆x.
Example 1. Use Euler’s method to approximate y(5) with step size ∆x = 0.5, where y 0 = (x2 − y 2 ) sin(y), y(1) = 3.
Recall the linear approximation, we get
y(x + ∆x) ≈ y(x) + y 0 (x)∆x.
Let yk = y(xk ), put x = xk and ∆x = 0.5 in the above formula, so we have
yk+1 = yk + (x2k − yk2 ) sin(yk ) · 0.5.
1
2
MINGFENG ZHAO
Then we have
k
xk
yk
0
1
3
1
1.5
y1 = y0 + (x20 − y02 ) sin(y0 ) · 0.5 ≈ 2.43552
2
2
y2 = y1 + (x21 − y12 ) sin(y1 ) · 0.5 ≈ 1.241065
3
2.5
y3 = y2 + (x22 − y22 ) sin(y2 ) · 0.5 ≈ 2.404689
4
3
2.561758
5
3.5
3.229465
6
4
3.149579
7
4.5
3.125299
8
5
3.210694
9
5.5
2.703501
10 6
7.569442
Second order linear ODEs
A general second order linear differential equation is of the form:
A(x)y 00 + B(x)y 0 + C(x)y = F (x),
or y 00 + p(x)y 0 + q(x)y = f (x).
If f (x) = 0, we say that y 00 + p(x)y 0 + q(x)y = 0 is homogeneous.
LECTURE 9: EULER’S METHOD, AND SECOND ORDER LINEAR ODES
3
Example 2. y 00 − k 2 y = 0 is homogeneous.
It’s easy to check that y1 = ekx and y2 = e−kx are two solutions to y 00 − k 2 y = 0.
Example 3. y 00 + k 2 y = 0 is homogeneous.
It’s easy to check that y1 = cos(kx) and y2 = sin(kx) are two solutions to y 00 + k 2 y = 0.
Theorem 1 (Superposition). Let y1 and y2 be two solutions to a homogeneous equation y 00 + p(x)y 0 + q(x)y = 0, then
for any two constants C1 and C2 , y(x) = C1 y1 (x) + C2 y2 (x) is also a solution to y 00 + p(x)y 0 + q(x)y = 0.
Proof. In fact, since y(x) = C1 y1 (x) + C2 y2 (x), then we have
y 00 + p(x)y 0 + q(x)y
=
[C1 y1 (x) + C2 y2 (x)]00 + p(x)[C1 y1 (x) + C2 y2 (x)]0 + q(x)[C1 y1 (x) + C2 y2 (x)]
= C1 y100 (x) + C2 y200 (x) + C1 p(x)y10 (x) + C2 p(x)y20 (x) + C1 q(x)y1 (x) + C2 q(x)y2 (x)
= C1 [y100 (x) + p(x)y10 (x) + q(x)y1 (x)] + C2 [y200 (x) + p(x)y20 (x) + q(x)y2 (x)]
=
0
Since both y1 and y2 are solutions.
So
y(x) = C1 y1 (x) + C2 y2 (x) is also a solution to y 00 + p(x)y 0 + q(x)y = 0 .
Example 4. y 00 − k 2 y = 0.
By Theorem 1, cosh(x) =
ekx + e−kx
is also a solution to y 00 − k 2 y = 0.
2
Theorem 2. Let p(x), q(x) and f (x) be continuous functions on some interval I, x0 ∈ I, and b0 , b1 are constants.
Then the equations

 y 00 + p(x)y 0 + q(x)y = f (x)
 y(x ) = b , y 0 (x ) = b
0
0
0
1
has only one solution on I.
Definition 1. Let y1 and y2 be two function on an interval I, we say that y1 and y2 are linearly dependent if either
or
y2
y1
is a constant function. Otherwise, say y1 and y2 are linear independent.
y1
y2
4
MINGFENG ZHAO
Example 5. y1 (x) = cos(x) and y2 (x) = sin(x).
Notice that
y2
sin(x)
=
= tan(x),
y1
cos(x)
and
y1
cos(x)
=
= cot(x).
y2
sin(x)
It’s easy to see that neither tan(x) nor cot(x) are constant functions, then
y1 = cos(x) and y2 = sin(x) are linearly independent .
Theorem 3. Let p(x) and q(x) be continuous functions, y1 and y2 are two linearly independent solutions to a homogeneous equation y 00 + p(x)y 0 + q(x)y = 0. Then the general solution to y 00 + p(x)y 0 + q(x)y = 0 is:
y = C1 y1 (x) + C2 y2 (x).
Definition 2. Any two linearly independent solutions y1 and y2 to a homogeneous equation y 00 + p(x)y 0 + q(x)y = 0 is
called a fundamental set of solutions to this homogeneous equation y 00 + p(x)y 0 + q(x)y = 0.
Example 6. y 00 + k 2 y = 0, k is a nonzero constant.
The general solution to y 00 + k 2 y = 0 is y = C1 cos(kx) + C2 sin(kx) .
Constant coefficients second order linear ODEs
In this lecture, we always assume that a, b and c are three constants, let’s consider the differential equation:
ay 00 + by 0 + cy = 0.
Question 1. Let a, b and c be three constants, how can we solve the differential equation ay 00 + by 0 + cy = 0?
Let’s try y(x) = erx to be a solution, then
y 0 = rerx ,
and y 00 = r2 erx .
So we get
ay 00 + by 0 + cy = ar2 erx + brerx + cerx = erx [ar2 + br + c].
So y(x) = erx is a solution to ay 00 + by 0 + cy = 0 if and only if r is a zero of ar2 + br + c = 0.
LECTURE 9: EULER’S METHOD, AND SECOND ORDER LINEAR ODES
5
Example 7. Solve y 00 − 6y 0 + 8y = 0.
Let y = erx be a solution to y 00 − 6y 0 + 8y = 0, then
y 0 = rerx ,
and y 00 = r2 erx .
So we get
0
= y 00 − 6y 0 + 8y
= r2 erx − 6rerx + 8erx
= erx [r2 − 6r + 8].
So r2 − 6r + 8 = 0, which implies that
r1 = 2,
and r2 = 4.
So y(x) = e2x and y(x) = e4x are solutions to y 00 − 6y 0 + 8y = 0. It’s easy to see that y = e2x and y = e4x are linearly
independent, so the general solution to y 00 − 6y 0 + 8y = 0 is:
y(x) = C1 e2x + C2 e4x .
Problems you can do:
Lebl’s Book [2]: All exercises on Page 49 and Page 50. Exercise 2.2.6, 2.2.7, 2.2.9, 2.2.13 and 2.2.104 on Page
55 and Page 56.
Braun’s Book [1]: All Exercises on Page 136, Page 137 and Page 138 (We are going to study the Wronskian later.).
All Exercises on Page 140. Read all materials in Section 2.1 and Section 2.2.
References
[1] Martin Braun. Differential Equations and Their Applications: An Introduction to Applied Mathematics. Springer, 1992.
[2] Jiri Lebl. Notes on Diffy Qs: Differential Equations for Engineers. Createspace, 2014.
Department of Mathematics, The University of British Columbia, Room 121, 1984 Mathematics Road, Vancouver, B.C.
Canada V6T 1Z2
E-mail address: mingfeng@math.ubc.ca
Download