Topic 3: Ordinary Differential Equation 3.1 Ordinary Differential Equations
Topic 3: Ordinary Differential Equation 3.1 Ordinary Differential Equations
Jan 2015
y ( x) 2 xy ( x)
-- (1)
And
d2y
dy
-- (2)
2 3 y 4 sin 2 x 7 cos 2 x
2
dx
dx
are ordinary differential equations. The solution of an ODE is a function that satisfies the
equation at every point of its domain. For example, y( x) exp( x 2 ) is a solution of (1), while
y( x) exp( x) cos 2 x is a solution of (2).
Other notations for OED are possible, such as an ODE for x as a function of t:
d 2x
dx
-- (3)
3 2 5 7x 0
dt
dt
dx
d 2x
Often derivatives with respect to t are denoted by dots, eg x
, x 2 , etc , so that (3)
dt
dt
may be also be written as
3x 5x 7 x 0
d 2x
dx
3 x 0
2
dt
dt
4x 3x x 0
ODEs arise quite naturally in a wide variety of physical situations, as described below.
Example:
Newtons law of cooling
It states that the rate of decrease of the temperature of a body is proportional to the difference
between the temperature T of the body and the temperature T0 of the surrounding air, i.e.
dT
T T0
dt
Or equivalently,
dT
k (T T0 )
dt
for some constant k.
Jan 2015
Example:
Motion of a mass on a spring in a resistive medium
x=0
x = X (t)
Let X(t) denote the displacement of the mass at time t. The resistive force is given by
dX
-- (4)
k1 (speed) k1
dt
and the spring restoring force by
-- (5)
k 2 (extension ) k 2 ( X l )
where k1 and k2 are constants and l is the natural length of the spring. By Newton's Second
Law, the total force F acting on the body must equal the acceleration a of the body times its
mass m, i.e. F = ma. Hence
dX
d2X
-- (6)
k1
k2 ( X l) m 2
dt
dt
d2X
dX
-- (7)
m 2 k1
k 2 X k 2l
dt
dt
Which is an ODE for the displacement X(t)
Order
The order of an ODE is the highest derivative occurring in the equation.
For example,
d2y
dy
6 10 y 0
2
dx
dx
Is second-order
dy
3 4y3x 0
dx
Is first order
Jan 2015
Degree
The degree of an ODE is the power to which the highest-order derivative is raised, after the
equation has been rationalised to contain only integer powers of derivatives. Hence
2
d4y
dy
4 x y 0
dx
dx
7
d 2 y dy 4
y 0
dx 2 dx
Is second order and degree 4, since in order to remove fractional powers, we rearrange as
follows
7
d y
dy 4
y 2
dx
dx
2
d2y
dy
y 2
dx
dx
Linearity
An ODE is linear, if
(a)
the y-dependent terms are y itself and derivatives of y and
(b)
these terms do not appear multiplied together. ODEs containing products of y
dependent terms, or functions of y, are said to be nonlinear.
3
d2y
dy
5 4 y e x
2
dx
dx
Jan 2015
The ODE may possess an analytical solution where the dependent variable can be expressed
as a function of the independent variable. For example,
dy
4 x
dx
has an analytical solution
y( x) 2 x 2 c
where c is a constant of integration. Here the dependent variable y has been expressed as a
function of the independent variable x.
Jan 2015
dy
at any point in the xy plane, as follows. Suppose we consider a grid of
dx
dy
points in the xy plane. At each point, draw a short line segment with gradient
. This is the
dx
direction field which consists of line-segments that are tangent to the solution curves. Thus
the solution curves may be inferred
We can compute
Where f is a given function. Sometimes they are written in the equivalent form
y ( x) f ( x, y)
Jan 2015
dy
f ( x, y) g ( x)h( y)
dx
We can then rearrange this into the form
1 dy
g ( x)
h( y ) dx
Integrating with respect to x we get
1
h( y) dy g ( x) dx + c
remember to include the arbitrary constant of integration c
Example:
Solve the equation
dy
ky
dx
We have
1 dy
k
y dx
1
y dy k dx c
ln | y | kx c
| y | e kx c e c e kx
Hence,
y e c e kx Ae kx
Example:
Solve the differential equation
dy
x
dx
y
Solution:
ydy xdx C
y2
x2
C
2
2
y2 x2 A
6
Jan 2015
Example:
Solve the differential equation
dy
y1/ 2 x
dx
Solution:
1
1/ 2
dy xdx C
y 2 dy
x2
C
2
1
2
y
x2
C
1/ 2 2
x2
2 y
C
2
Example:
Solve the differential equation
(1 x 2 )
dy
2 xe y
dx
Solution:
2x
dx C
(1 x 2 )
2x
y
e dy (1 x 2 ) dx C
1
dy
e y ln | 1 x 2 | C
Example:
Solve the differential equation
dy
2x y
e
dx 1 y
Solution:
dy
2x y
e
dx 1 y
1 y
e y dy 2 xdx C
(1 y)e
dy x 2 C
e y (1 y ) e y x 2 C
Jan 2015
-- (8)
No `y'-terms are multiplied together and there are no functions of y. If a linear first-order
equation is written as in (8) it is said to be in standard form. Notice that if q(x) = 0 the
equation is also separable. For then
dy
dy
p( x) y 0
p ( x) y
dx
dx
Hence,
1
y dy p( x) dx c
Where c is a constant of integration, so that
ln | y | p( x) dx c
Taking exponentials,
y Ae p ( x ) dx
y e
e
ye
p( x)dx
ye
e
dx
dx
dx
dx
dx
And also
p ( x ) dx
dy
p ( x) y )
dx
p ( x ) dx
d
( ye
)
dx
p ( x ) dx
-- (9)
Jan 2015
Theory
Hence, to solve the linear ODE in standard form
dy
p ( x) y q ( x)
dx
p ( x ) dx
We multiply by the integrating factors e
e
p ( x ) dx
p ( x ) dx
dy
q(x)
p ( x) y e
dx
ye
p ( x ) dx
q( x)e
p ( x ) dx
Final result:
p ( x ) dx
p ( x ) dx dx ce p ( x ) dx
ye
q( x)e
Example:
dy
Solve x 2 y 3x 3
dx
Solution:
dy
p ( x) y q ( x)
dx
dy 2
y 3x 2
dx x
2
Integrating factor
x dx
e 2 ln x x 2
d
yx 2 3 x 2 x 2 3 x 4
dx
d
2
4
dx yx 3x dx
3
yx 2 x 5 C
5
Jan 2015
dy
P( x) y Q( x) y a
dt
dx
x 4 dy
dy
4 dx
and
3x
dt
dt
dt
3 dt
4
x dy 1
cos t
dy 3 3 3 cos t
x 3 x4
x 3
3 dt t
dt t
t
t
dy 3
3 cos t
y 3
dt t
t
Therefore,
Then
t dt
e 3 ln t t 3
d
3 cos t
yt 3 t 3 3 3 cos t
dt
t
d
3
dt yt 3 cos tdt C
yt 3 3 sin t C
1
x3
yt 3 3 sin t C
So
1 3
t 3 sin t C
x3
t3
x
3 sin t C
1/ 3
10
Jan 2015
Example:
Solve y
2
y x2 y 2 .
x
Solution:
2 1
y x2
x
1
Let w
y
y
w 2
y
2
w w x 2
x
solve this differential equation by First order linear equation
yy 2
Integrating factor is e
x dx
e 2ln x x 2
x 2 w w x 2 x 2
x
d 2
4
dx x w dx x dx C
x5
2
x w C
5
2
5
x
x
C
y
5
5x2
x5 A
11
Jan 2015
Example:
Solve y
4
y x3 y 2 .
x
Solution:
4
y y 2 y 1 x 3
x
1
Let w
y
y
w 2
y
4
w w x 3
x
solve this differential equation by First order linear equation
Integrating factor is e
x dx
1
4 1
w w 4 x 3
4
x x
x
d 1
dx x
e 4 ln x
1
x4
w dx dx C
x
1
w C ln | x |
x4
1
x 4 C ln | x |
y
1
y 4
x C ln | x |
12
Jan 2015
Example:
dy 1
Solve y e x y 4 .
dx 3
Solution:
1 dy 1 3
y ex
4
y dx 3
1
Let w 3
y
3
w 4 y
y
1
1
w w e x
3
3
w w 3e x
d x
e w 3
dx
d x
dx e w dx 3dx C
e x w 3x C
ex
1
3 x C
y3
1
e x (C 3 x)
3
y
13
Jan 2015
Example:
Solve x
dy
y xy 3 .
dx
Solution:
dy y
y3
dx x
1 dy 1 1
1
y 3 dx y 2 x
1
Let w 2
y
2
w 3 y
y
1
1
w w 1
2
x
2
w w 2
x
Integrating factor is e
x dx
1
x2
1
2 1
w w 2 2
2
x x
x
d 1 2
w
dx x 2 x 2
1
2
w 2 dx C
2
x
x
1
2
w C
x
x2
w 2 x Cx 2
1
2 x Cx 2
2
y
1
y2
2 x Cx 2
14
Jan 2015
Example:
dy
Solve
Ay By 2 , where A and B is constant.
dx
Solution:
y Ay By 2
a = 2, therefore let u y1a y12
1
y
y2
y 2u y
and
then
y Ay By 2
so u B Au
1
y
y 2u Ay By 2
u Au B
B
A
y
1
Ce At
Exercise:
dy
Solve
2y ex
dx
Solution:
dy
2y ex
dx
Integrating factor
u B Ay 1
dy
p ( x) y q ( x)
dx
e
e 2 x
d
ye 2 x e x e 2 x e x
dx
d
2 x
x
dx ye e dx
ye 2 x e x C
2 dx
y e x Ce 2 x
15
B
A
Jan 2015
f (x, y) y x ( y x) f ( x, y)
f ( x, y) y x
g ( x, y) y x
2
g ( x, y) 2 y 2 2 x 2 2 ( y 2 x 2 ) 2 g ( x, y)
dx B( x, y )
Where A(x,y) and B(x,y) are homogeneous functions of the same degree. The RHS of a
homogeneous ODE can be written as a function of y/x, because
dy A( x, y) A(1, y / x)
F ( y / x)
dx B( x, y) B(1, y / x)
-- (11)
Hence, the solution method is first to check whether the equation is homogeneous. If so,
make the substitution y = vx, then separate variables as in (11) and solve directly. Finally
replace v by y/x to obtain the solution.
16
Jan 2015
Example:
Solve
dy y x
dx y x
Let
dy
dv
vx
dx
dx
Then we have
dy y x
dx y x
dv v 1
1 v2
v
dx v 1
v 1
Example:
Solve
dy y
y
tan
dx x
x
dv
v tan v
dx
Hence,
1
cot v dv x dx C
ln | sin v | ln | x | C
y x sin 1 Ax
17
Jan 2015
Example:
Solve
dy
x
yx
dx 1 x 2
p ( x ) dx
Integrating factor e
1 x2
1/ 2
d
y 1 x2 x 1 x2
dx
d
2
2
dx y 1 x x 1 x dx
3/ 2
1
y 1 x2 1 x2
C
3
1
C
y 1 x2
3
1 x2
Given y = 0 when x = 1
y(1) 0
1
C
1 12
0
3
1 12
C
2 2
3
1
2 2
1
1 x2
3
3 1 x2
18
Jan 2015
Example:
Suppose that a variable current I(t), where t is time in seconds, flows through a coil with
inductance L and a resistor of resistance R with an applied voltage V , where we assume that
L, R and V are constants. Suppose also that the current is zero at time t = 0. Then the current
satisfies the ODE
dI
L RI V
dt
Subject to the initial condition
I(0) = 0
Solution:
R
t
V
ce L
R
V
R
Exercise:
The rate of increase of the concentration of a chemical is proportional to the concentration at
that time. Experiment shows that the concentration doubles in four hours. If the initial
concentration is c0, what is the concentration after six hours?
19
Jan 2015
y Ae
c
x
b
dy
cy 0
dx
bmAemx cAemx 0
Aemx (bm c) 0
Hence,
m
c
b
Ae mx (am 2 bm c) 0
Ae mx 0
am 2 bm c 0
-- (12)
y Ae m1x Be m2 x
Where A and B are arbitrary constants.
20
Jan 2015
Example:
We start with an example. Suppose we wish to solve
d2y
2 y
2
dx
We first check that y sin x is a solution:
y cos x ,
y 2 sin x 2 y
y 2 cos x 2 y
y 2 2 cos x 2 y
Example:
Solve
d 2 y dy
2y 0
dx 2 dx
Solution:
Try
y Ae mx then we have Ae mx (m 2 m 2) 0
m = 2 , m = -1
y Ae x Be 2 x
21
Jan 2015
Example
Solve
d2y
dy
4 3y 0
2
dx
dx
Solution:
Try
y Ae mx then we have Ae mx (m 2 4m 3) 0
m=3 ,m=1
y Ae x Be 3 x
Since as we've seen in (12) m1 and m2 are the roots of a quadratic equation with real
coefficients, three different cases are possible:
- m1 and m2 are real and distinct (as in the previous two examples)
- m1 and m2 are real and repeated (i.e. m1 = m2)
- m1 and m2 are complex conjugates
We now consider the second and third cases, the first having already been dealt with.
Real and repeated roots
If m1 = m2, the general solution appears to be
y Ae m1x Be m1x e m1x ( A B) Ce m1x
The solution now only contains one constant of integration, but we know that it should
contain two. In this case, the solution is
y ( A Bx )em1 x
Where A and B are arbitrary.
Example:
Solve
Try
y 6 y 9 y 0
y Ae mx then we have Ae mx (m 2 6m 9) 0
m = 3 , m = 3 (repeat)
y A Bx e 3 x
22
Jan 2015
m2 i
m1 i
ex Ae ix Be ix
ex C cos x D sin x
Where C and D are arbitrary constants (they are, in fact, combinations of A and B)
This is the general solution in this case.
Example:
Solve
y 4 y 0
Solution:
Try
y Ae mx then we have Ae mx (m 2 4) 0
m = 2i , m = -2i (repeat)
0 and
The general solution for y is then
y C cos 2 x D sin 2 x
d2y
dy
b cy 0
2
dx
dx
23
Jan 2015
And can be found using the methods of previous section. Here we will discuss how to find
the particular integral. There is no general rule for finding the particular integral. In certain
cases it is possible to find a particular integral by first guessing the general form of the
particular integral in terms of a function containing a number of as yet undetermined
constants, and then adjusting the constants so as to turn the function into a solution. This
technique is known as the method of trial functions and we will illustrate it by a number of
examples.
Example:
Find the general solution of
d 2 y dy
2y x
dx 2 dx
Solution:
The complementary function is the solution of
d 2 y dy
2y 0
dx 2 dx
y Ae x Be 2 x
To find the particular solution, we consider the trial function
y Cx D
Equating the coefficients of the various power of x on the left and right sides give
C 2D 0
2C 1
Which we have
1
2
and
1
4
y(x) Ae x Be 2 x
24
1
1
x
2
4
Jan 2015
Example:
Find the general solution of
d2y
dy
5 9 y 44 x
2
dx
dx
Solution:
The complementary function is the solution of
d2y
dy
5 9 y 44 x
2
dx
dx
12 5 61 x
Be
12 5 61 x
Equating the coefficients of the various power of x on the left and right sides give
C
1
27
y p ( x)
12 5 61 x
25
Be
12 5 61 x
1 4x
e
27
Jan 2015
Example:
Find the general solution of
d2y
dy
5 9 y cos 2 x
2
dx
dx
Solution:
The complementary function is the solution of
d2y
dy
5 9 y cos 2 x
2
dx
dx
12 5 61 x
Be
12 5 61 x
Equating the coefficients of the various power of x on the left and right sides give
C
13
269
and D
10
269
1
10 sin 2 x 13 cos 2 x
269
y p ( x)
Thus, the general solution is
y ( x) y c y p
y(x) Ae
12 5 61 x
Be
12 5 61 x
1
10 sin 2 x 13 cos 2 x
269
26
Jan 2015
If f (x) consists of the sine or cosine of a multiple of x, the trial function should be a linear
combination of sine and cosine of the same multiple of x.
e.g. if f (x) = cos 5x try
Csin 5x + Dcos 5x.
(In all the above, C, D an E are arbitrary constants)
1
0
4
1
y (0) A 2 B 0
2
1
A
3
1
B
12
y (0) A B
Therefore we get
1
1
1
1
y ex e2 x x
3
12
2
4
27