You are on page 1of 20

MMME1026 (MM1MTE)

Mathematics for Engineers


Chapter 6: First order ordinary differential equations

School of Mathematical Sciences

Spring 2019/20

Outline

6 Ordinary Differential Equations


6.1 Introduction
6.2 Order of an ODE
6.3 Linearity
6.4 First-order ODEs
6.5 Separable first-order ODEs
6.6 First order linear equations
6.7 Boundary and initial conditions
6.8 Exact equations
6.1 Introduction
An ordinary differential equation (ODE) is an equation involving an
unknown function of one variable, y(x) say, and its derivatives; for
example,
dy d2 y dy
= 2xy (1), or + 4 + 6y = 0 (2).
dx dx 2 dx
Aim: to learn how to solve ODEs for the unknown function y (x).
Only certain classes of ordinary differential equations can be
solved explitly (i.e. a formula for y(x) can be found).
We will look at methods for solving some classes of ODEs here;
you will see more techniques in subsequent modules.
Many (or most) differential equations can only be solved
numerically.
We can also consider partial differential equations (PDEs) where,
for example in 2d, the equation to solve involves f (x, y) and its
partial derivatives with respect to x and y. (Next year!)

Notation
For ordinary differential equations
y is called the ‘dependent’ variable, and x is the ‘independent’
variable.
We may use other notation for derivatives, e.g.
y 00 (x) + 4y 0 (x) + 6y (x) = 0 is an equivalent form of equation (2).
We may change the letters used for variables, such as an ODE for
d2 x dx
x as a function of t, e.g. 3 2 + 5 + 7x = 0.
dt dt
When the independent variable is time t, derivatives are often
denoted by dots: 3ẍ(t) + 5ẋ(t) + 7x(t) = 0.
ODEs arise quite naturally in a wide variety of practical engineering
situations. Some examples of this now follow...
6.1.1 Motion of a mass on a spring in a resistive
medium

x =0 x = X (t)
dX
Resistive force: −k1 × (speed) = −k1 ,
dt
Spring restoring force: −k2 × (extension) = −k2 (X − l),
where k1 and k2 are constants and l is the natural length of the spring.
Newton’s Second Law (F = ma = mẍ) ⇒

dX d 2X
−k1 − k2 (X − l) = m 2
dt dt
d 2X dX
i.e. m 2 + k1 + k2 X = k2 l
dt dt

6.1.2 The LCR circuit

L C R
I(t)

V(t)
Z
dI 1
Kirchhoff’s Law: L + IR + I(t)dt = V (t)
dt C
d 2I dI 1 dV
Differentiating gives L 2 + R + I =
dt dt C dt
— an ODE for I(t).
6.1.3 Newton’s law of cooling
The rate of decrease of temperature of a body is proportional to the
temperature difference between the body and the surrounding air

dT dT
that is, ∝ T − T0 or, equivalently = −k(T − T0 )
dt dt
for some constant k.

6.1.4 Free fall under gravity with air resistance


R A mass m falls a distance y (t),
dy
and has downward speed V (t) =
dt
Resistive force, R ∝ V ⇒ R = kV 2 , (k > 0)
2

dV
F = ma ⇒ mg − R = m
dt

mg dV
⇒ m = mg − kV 2 for V = V (t).
dt
We can rewrite this in other ways: • for y as a function of t, using y (t)
dy d 2y
 2
V = ⇒ m dt 2 = mg − k dy dt ;
dt
• for V as a function of y, that is V (y),
d dy d d dV
using = =V implies mV = mg − kV 2
dt dt dy dy dy
6.2 Order of an ODE
The order of an ODE is the highest derivative occurring in the
equation. For example,

d 2y dy
+ 6 − 10y = 0 is second-order;
dx 2 dx
dy
3 + 4y 3 x = 0 is first-order.
dx
We only consider first and second-order ODEs in this module, though
some of the ideas carry over to higher-order examples.

6.3 Linearity

An ODE is ‘linear’ if (a) the only 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’.
Examples 6.3.1
 3
d2 y dy
2
+ 5 − 4y = ex is second-order and nonlinear,
dx dx
d2 y dy
+ 10 − 6y = 0 is second order and linear ,
dx 2 dx
dy
y + x 3 = 0 is first-order and nonlinear,
dx
dy
+ 4x 3 y = e4x is first order and linear.
dx
6.4 First-order ODEs
Notice that the coefficients in the ODE might depend upon the
independent variable (x in this case).
First-order ODEs are usually written in the canonical form

dy
= f (x, y)
dx

where f is a given function. Sometimes they are written in the


equivalent form
y 0 (x) = f (x, y ).
Not all ODEs can be solved explicitly; we now cover some
techniques which enable certain classes to be solved.

6.5 Separable first-order ODEs


In this case, the function f ‘separates’ into the product of a function of
x and a function of y. Then we can write f (x, y ) = g(x)h(y )
so that the equation becomes

dy
= g(x)h(y ).
dx

1 dy
We can then rearrange this into the form = g(x).
h(y) dx
Hence, the solution is obtained by
Z Z
1
dy = g(x) dx + c,
h(y )

remembering to include the arbitrary constant of integration c.


Example 6.5.2
dy
Find the general solution of = ky.
dx
Solution
Z Z
dy 1
= ky ⇒ dy = kdx + c ⇒ ln |y| = kx + ln |A|,
dx y

where c ≡ ln |A|. Hence,


y = Aekx ,
where A is an arbitrary constant.

Example 6.5.3
dy
Find the general solution of = y 1/2 x.
dx
Solution. Z Z
dy 1 dy
= y 2x ⇒ 1
= xdx + c.
dx y 2

Hence,
1/2 x2 1/2 1 2 
2y = + c or y = x +A ,
2 4
where A = 2c is an arbitrary constant. Finally,

1  2 2
y= x +A .
16
Example 6.5.4
dy
Find the general solution of (1 − x 2 ) = −2xe−y
dx
Solution This is separable - divide by (1 − x 2 ) and multiply by ey .
In this case, when the variables have been separated, we get

−2x
Z Z
ey dy = dx + c.
(1 − x 2 )

Hence, ey = ln |1 − x 2 | + c
or, if you prefer,  
2
y = ln ln |1 − x | + c .

6.5.1 Implicit solutions


It is not always possible to get an explicit expression for y as a function
of x. For example:
dy cos x
=
dx sin y
separates to give
Z Z
sin y dy = cos x dx + c

which has the ‘solution’

− cos y = sin x + c.

We consider this as the solution, and it represents a family of curves


with each member of the family corresponding to a particular value of
the constant of integration, c.
6.6 First order linear equations
Recalling our definition of a linear differential equation, we see that
some of the separable cases that we have studied are nonlinear. For
dy
= f (x, y )
dx
to be linear we must have
f (x, y) = −p(x)y + q(x)
for given functions p and q. Then the equation becomes
dy
+ p(x)y = q(x).
dx
No ‘y ’-terms are multiplied together and there are no functions of y .

The equation is homogeneous if q(x) ≡ 0 and inhomogeneous if


q(x) 6≡ 0.

When q(x) 6≡ 0, the equation is not separable - need a new technique.

6.6.1 Integrating Factor


d
When we have (f (x)) = g(x) the left-hand-side is an exact
dx
derivative and it is easy to see that
Z
f (x) = g(x) dx + c.

The strategy here is to find a function r (x) such that when we multiply
our linear ODE by r (x) the left-hand-side becomes an exact derivative:

dy d dy dr
r (x)+ r (x)p(x)y (x) = [r (x)y(x)] = r (x) + y(x).
dx dx dx dx
Therefore the function r (x) must satisfy the separable ODE
Z Z Z
dr 1
= r (x)p(x) ⇒ dr = p(x) dx ⇒ ln(r (x)) = p(x) dx
dx r (x)
Thus R
Integrating factor (I.F.) r (x) = e p(x) dx .
6.6.2 Solution of First order linear equations
Multiplying our first order linear equation by this integrating factor r (x)
we have
d
[r (x)y(x)] = r (x)q(x).
dx
Now integrate to find that
Z
r (x)y(x) = r (x)q(x) dx + C

for arbitrary constant C.

Therefore the general solution to the ODE is


Z
1 C
y(x) = r (x)q(x) dx + .
r (x) r (x)

Example 6.6.1
dy
Find the general solution of − 2y = ex .
dx
Solution. We identify p(x) = −2, q(x) = ex
R R
The integrating factor is e p(x)dx = e− 2dx = e−2x
 
dy
Hence, e−2x − 2y = e−2x ex = e−x .
dx
Then Z
d  −2x 
ye = e−x ⇒ ye −2x
= e−x dx + c
dx
⇒ ye−2x = −e−x + c ⇒ y = −e−x e2x + ce2x .
⇒ y = −ex + ce2x for arbitrary constant c.
Example 6.6.2
dy
Find the general solution of + 2y = 3x 3
x
dx
dy dy 2
Solution: Divide by the coefficient of to obtain + y = 3x 2 (1)
dx dx x
Identify p(x) = 2/x and hence find the integrating factor:
2 2
= e2 ln |x| = e(ln x ) = x 2 .
R R
p(x)dx dx
e =e x

Multiply (1) by IF = x 2 :

2 dy 4 d  2 
x + 2xy = 3x ⇒ x y = 3x 4
dx dx
3 5 3 3 c
⇒ x 2y = x +c ⇒ y= x + 2.
5 5 x

6.7 Boundary and initial conditions

We have seen that the solution for a first-order ODE involves one
unknown constant. This is called the general solution.
Generally, the number of unknown constants in the general
solution equals the order of the ODE.
To determine a specific solution, we must find these constants.
We therefore need as many conditions on the solution as there
are unknown constants.
These conditions usually involve the value of the unknown
function and/or some of its derivatives at certain points.
For a first-order equation we only need one such condition, and
this is called a boundary condition.
If the independent variable in the ODE is time t, then we normally
specify the condition at time t = 0. Then the boundary condition is
called an initial condition.
Example 6.7.1
dy x
Find the general solution of + y =x
dx 1 + x2
and the solution subject to the boundary condition y(1) = 0.
Solution. This is a linear ODE with
x
p(x) = , q(x) = x.
1 + x2
Hence we find the integrating factor
Z Z
x 1  2
 
2
1/2
p(x)dx = dx = ln 1 + x = ln 1 + x .
1 + x2 2
1/2  1/2
ln(1+x 2 )
R
p(x)dx 2
⇒ e =e = 1+x .
The effect of multiplying the ODE by the integrating factor is to put the
equation into the form
  1/2 
d 2

2
1/2
y 1+x =x 1+x
dx

Z

2
1/2 
2
1/2 1 2
3/2
⇒ y 1+x = x 1+x dx + c = 1+x + c,
3

1   −1/2
2 2
⇒ y= 1+x +c 1+x .
3
This is the general solution to the ODE.
Suppose that we insist that y = 0 when x = 1, i.e. y (1) = 0. Then

1 1
(1 + 1) + c(1 + 1)− 2 = 0,
3

2 2
which can be solved to give the value of c in this case as c=− .
3
The solution for y is then
√  −1/2
1  2 2
y= 1 + x2 − 1+x 2
.
3 3
Example 6.7.2
Find the general solution of dy 2 −y
dt = 3t e
and the solution subject to the initial condition y(0) = 1.
Solution This is a separable ODE where we can write
Z Z
ey dy = 3t 2 dt

so that ey = t 3 + c and the general solution is

y (t) = ln(t 3 + c).

Suppose that we insist that y = 1 when t = 0. i.e. y(0) = 1. Then

1 = ln(c) ⇒ c = e.

The solution for y which satisfies the initial condition is then

y(t) = ln(t 3 + e).

Example 6.7.3
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 five
hours?
dc
Solution: Let c(t) denote the concentration at time t. Then = kc,
dt
for some constant k. This is a separable ODE and so we obtain
Z Z
1
dc = kdt + ln |A| ⇒ ln |c(t)| = kt + ln |A| ⇒ c(t) = Aekt
c
where A is a constant.
Using c = Aekt and the initial condition

c = c0 at t = 0 ⇒ c0 = Ae0 = A,

gives
c(t) = c0 ekt .
At t = 4 (in units of hours), c = 2c0 . So

2c0 = c0 e4k

or
1
k= ln 2 ⇒ c(t) = c0 e(t/4) ln 2 .
4
If t = 5,
5/4
c(5) = c0 e(5/4) ln 2 = c0 eln 2 = 25/4 c0 .

Example 6.7.4
Find the curve in the (x, y ) plane that passes through (0,3) and whose
tangent line at a point (x, y ) has slope 2x/y 2 .
Solution
dy dy 2x
Since the slope of the curve y = y (x) is , we have = 2
dx dx y
and since it must pass through (0,3)
Z we have Zthe condition y (0) = 3.
Separating the variables, we find y 2 dy = 2xdx + c
1 3
where c is an arbitrary constant. Hence 3y = x 2 + c.

1 3
y(0) = 3 ⇒ 3 =0+c so c = 9.
3
Finally
1 3  1
3
y = x2 + 9 or y = 3x + 27 2
.
3
6.8 Exact equations
6.8.1 Motivation
Consider the first order ODE
dy 2x + y 2 dy
=− ⇒ (2x + y 2 ) + 2xy = 0.
dx 2xy dx

Observe that the function F (x, y ) = x 2 + xy 2 satisfies

∂F ∂F
= 2x + y 2 and = 2xy.
∂x ∂y

∂F ∂F dy
Therefore the original ODE can be written as + = 0.
∂x ∂y dx
Recall also the Total derivative (see section 5.10):

d ∂F dx ∂F dy ∂F ∂F dy
(F (x, y(x))) = + = + .
dx ∂x dx ∂y dx ∂x ∂y dx

So we can see that the ODE can be written as the exact derivative
d
(F (x, y(x))) = 0
dx
Integrating this gives
F (x, y(x)) = c
for an arbitrary constant c.

Therefore the solution of the ODE is

x 2 + xy 2 = c.
6.8.2 Exact equations
dy
We can express any first order ODE, = f (x, y) in the form
dx
dy
M(x, y) + N(x, y) = 0, (6.1)
dx
M(x, y)
by setting f (x, y) = − .
N(x, y)
If we can find a function F (x, y) such that
∂F ∂F
M(x, y) = and N(x, y) = (6.2)
∂x ∂y
∂F ∂F dy
then the ODE (6.1) can be written as + = 0, or
∂x ∂y dx
d
(F (x, y(x))) = 0 ⇒ F (x, y(x)) = c
dx
for arbitrary constant c.
We say that (6.1) is an exact equation.

6.8.3 Conditions for exact derivatives

The simultaneous partial differential equations in (6.2) only have a


solution F (x, y ) when they are consistent:

∂2F ∂2F ∂M ∂N
= ⇒ = .
∂y∂x ∂x∂y ∂y ∂x

(see section 5.12)


If the equations (6.2) are consistent then the ODE (6.1) is exact
and we can calculate F (x, y ) as in section 5.12.
6.8.4 Solution strategy for exact ODEs
dy
Given an ODE of the form M(x, y ) + N(x, y ) =0 (∗)
dx
∂M ∂N
1 Check if (∗) is exact: Does = ?
∂y ∂x
2 If so, then find F (x, y ) from the simultaneous PDEs

∂F ∂F
M(x, y) = and N(x, y) =
∂x ∂y

d
3 Finally, since (*) is equivalent to (F (x, y(x))) = 0, the solution
dx
is
F (x, y) = c for an arbitrary constant c.

Example 6.8.1
dy
Find the general solution of the ODE y +x = 0.
dx
Solution:
1
∂M ∂N
M(x, y) = y , N(x, y) = x ⇒ =1= .
∂y ∂x
Therefore the equation is exact.
2 Now compute F (x, y):

∂F ∂F
= M(x, y) = y and = N(x, y) = x.
∂x ∂y

∂F
=y ⇒ F = xy + g(y).
∂x
∂F ∂
=x ⇒ (xy + g(y )) = x + g 0 (y) = x
∂y ∂y
⇒ g 0 (y) = 0 or g(y ) = const.
So F (x, y ) = xy + constant.
3 Therefore the general solution is xy = constant.

Example 6.8.2
x 2 dy 2x
Find the general solution of the ODE − 2 + = 0,
y dx y
and also the particular solution which satisfies y(2) = 1.
Solution:
2x x2 ∂M 2x ∂N
1 M(x, y ) = , N(x, y ) = − 2 . ⇒ = − 2 =
y y ∂y y ∂x
so the equation is exact.
2x x2
2 Compute F (x, y): Fx = M = and Fy = N = − 2 .
y y
∂F 2x x2
= ⇒ F = + g(y ).
∂x y y
x2 ∂ x2 x2 x2
 
∂F 0
=− 2 ⇒ + g(y) = − 2 + g (y) = − 2 .
∂y y ∂y y y y
Hence, g 0 (y) = 0 ⇒ g(y) = constant.
Then F (x, y ) = x 2 /y + constant.
3 Therefore the general solution is x 2 /y = constant.
4 Finally, use the boundary condition to find the particular solution:
22
y = 1 when x = 2 so = constant. Therefore the solution
1
satisfying the boundary condition is

x 2 /y = 4.

Example 6.8.3
  dy
2
Check the solvability and, if possible, solve 2xy + x − 1 = 0.
dx
Solution:
∂M ∂N
1 M(x, y ) = 2xy, N(x, y) = x 2 − 1 ⇒ = 2x =
∂y ∂x
so the equation is exact.
2 Now compute F (x, y):

∂F ∂F
= M(x, y) = 2xy and = N(x, y) = x 2 − 1.
∂x ∂y

∂F
= 2xy ⇒ F = x 2 y + g(y ).
∂x
∂F
Therefore = x 2 + g 0 (y ) = x 2 − 1
∂y
⇒ g 0 (y) = −1, implying g(y) = −y + const.
Then F (x, y) = x 2 y − y + const.
3 The general solution of the ODE is x 2 y − y = c.
c
This can be re-expressed in the form y = 2 .
x −1

You might also like