You are on page 1of 33

# Primer on First-Order Ordinary

Differential Equations

1. Introduction
In this notebook we present an introductory review of the properties and solutions of 1st order ordinary differential equations. In section 2 we introduce the concept of 1-parameter family of level curves which we show in later
sections forms the building block for understanding the solution properties of 1st order ODEs. We then review
some basic definitions regarding ordinary differential equations, and then proceed with the main discussion on
several methods for solving ODEs. The first method we consider is for linear differential equations which can be
solved by finding an integrating factor. The next section introduces a solution method based on separation of
variables that can be used to solve nonlinear 1st order ODES. Each section has numerous worked out examples.
These notes do not discuss exact ODEs or the use of homogeneous functions to solve first order ODES

2. Level Curves
Concept 1:

A function g Hx, yL = c defines a one-parameter family of plane curves called level curves.

## Example 2.1: Level Curves

Let T Hx, yL define the temperature of a plane body. Then the function defined by T Hx, yL = c (where c is a
constant) represents a curve in the x - y plane of constant temperature called an isotherm. Each value of the
constant c defines a different isotherm. Isotherms defined by T Hx, yL = c are also called level curves.

## Example 2.2 : Mathematica experiments with level curves

Suppose the family of level curves is given by

g Hx, yL = y2 + 3 xy + x2 = c

## Display the level curves for c = 8-3, -2, -1, 0, 1, 2, 3<

(1)

FirstOrderODEs_Primer.nb

Solution

For each value of c we need to find the Hx, yL pair that satisfies
g Hx, yL = y2 + 3 xy + x2 = c
Since g Hx, yL = c defines a surface of height c, we need to determine a contour plot of this function. This can
be readily done in Mathematica using the ContourPlot function. Here is the code that achieves the desired result.
ContourPlot@y2 + 3 x y + x2 ,
8x, -3, 3<, 8y, -3, 3<, ContourShading -> False,
PlotPoints -> 100, ContourStyle -> RGBColor@0, 0, 1DD;
3

-1

-2

-3
-3

-2

-1

It is more instructive to plot particular level curves. For example, suppose we want the level curves for
c = 8-3, -2, -1, 0, 1, 2, 3<. This can be done in ContourPlot by specifying the option
Contours. The result is shown below

FirstOrderODEs_Primer.nb

## ContourPlot@y2 + 3 x y + x2 , 8x, -3, 3<, 8y, -3, 3<,

Contours -> 8-3, -2, -1, 0, 1, 2, 3<, ContourShading -> False,
PlotPoints -> 100, ContourStyle -> RGBColor@0, 0, 1DD;
3

-1

-2

-3
-3

-2

-1

Note that in this example the point H0, 0L lies at the intersection of two contours. It follows from the function
g Hx, yL that H0, 0L must lie on the contour for c = 0. Indeed, one can show that for each value of c 0 there
are two level curves that satisfy g Hx, yL = c. We show this in the next plot for c = -2

FirstOrderODEs_Primer.nb

## ContourPlot@y2 + 3 x y + x2 , 8x, -3, 3<,

8y, -3, 3<, Contours -> 8-2<, ContourShading -> False,
PlotPoints -> 100, ContourStyle -> RGBColor@0, 0, 1DD;
3

-1

-2

-3
Thus when c = 0, there is a an Hx, yL pair, namely, H0, 0L that is common to both level curves. The implication of this point will be discussed later.
-3

-2

-1

## Example 2.3: More experiments with level curves

Consider the family of level curves given by

g Hx, yL = y2 - 2 y - x3 - 2 x = c

Determine the value of c such that a curve passes through the point x = 0, y = -1.5. Plot the level curve and
show its relationship to the family

Solution
For x = 0, y = -1.5 we have

## g H0, -1.5L = H-1.5L2 - 2 H-1.5L = c

Thus c = 5.25
Here is a plot of the level curve

FirstOrderODEs_Primer.nb

## plt1 = ContourPlot@y2 - 2 y - x3 - 2 x, 8x, -3, 3<,

8y, -4, 4<, ContourShading -> False, Contours -> 85.25<,
PlotPoints -> 100, ContourStyle -> RGBColor@0, 0, 1DD;
4

-2

-4
-3

-2

-1

We can display this level curve within the family as follows. First we construct contours for
c = 8-5, -3, -1, 0, 1, 3, 6, 7<. We plot these using ContourPlot but suppress output using the option
DisplayFunction->Identity.
Then we combine the two plots using the function Show, with the option DisplayFunction->\$DisplayFunction
plt2 = ContourPlot@y2 - 2 y - x3 - 2 x, 8x, -3, 3<,
8y, -4, 4<, Contours -> 8-5, -3, -1, 0, 1, 3, 6, 7<,
ContourShading -> False, PlotPoints -> 100,
ContourStyle -> RGBColor@1, 0, .5D, DisplayFunction -> IdentityD;

FirstOrderODEs_Primer.nb

4

-2

-4
-1

Concept 2:

dy

dx = F Hx, yL
where
g
g -1
F Hx, yL = -
x H
y L

g dy
g

y
dx +
x = 0

## Rearranging this result gives

dy
g
g

dx = -
x H
y L

-1

FirstOrderODEs_Primer.nb

3. Definitions
This section discusses some general concepts for ordinary differential equations. These concepts apply to first
order equations as well as n-th order equations. The student should study and understand the concepts in this
section before preceding with subsequent sections.

An differential equation is an equation involving a function and its derivatives. If y HxL is a function of x, then
the most general form for a ordinary differential equation involving y HxL is
F Hx, y, y ', y ' ', yH3L , , yHnL L = 0

## where we have used the shorthand

d y
yHnL
dx n
n

to represent the nth derivative of y HxL. In the above equation y is referred to the dependent variable, and x the
independent variable. Differential equation involving two or more independent variables are called partial
differential equations. In this module we will be focussing on ordinary differential equations(ODEs).

## Example 3.1: Differential equations

The following are examples of ordinary differential equations
(i)

d u
F Ht, u, uH2L L = 0, where F Ht, u, uH2L L =
+ u - Log HtL
dt 2
2

## In this case u is the dependent variable, and t is the independent variable.

(ii)
(iii)

du
H
dt L

+ t2 u = 0

d y
dy

+ 3 t
dt + 4 y = Sin HtL
dt3
3

## In this case y is the dependent variable and

d y
dy
F Ht, y, y ', yH3L L
+ 3 t
dt + 4 y - Sin HtL
dt3
3

(iv)

d y
dy
2
4 x2
+ 3 x
dx + xy = y Sin HxL
dx2
2

In this example the dependent variable is y, and the independent variable is x. Also
d y
dy
2
F Hx, y, y ', yH3L L 4 x2
+ 3 x
dx + xy - y Sin HxL
dx2
2

## Here is an example of a partial differential equation

u
2 u
(v) u
t + x
x 2 = Cos HtL
2

In this example the dependent variable is u and the independent variables are t and x.

FirstOrderODEs_Primer.nb

Concept 3:
The order of a differential equation is the highest derivative of the dependent variable appearing in the equation.

## Example 3.2: Order of differential equations

Determine the order of the following differential equations:
(i)
(ii)
(iii)
(iv)
(v)

d u

+ u - Log HtL = 0
dt2
2

du
H
dt L

+ t2 u = 0

d u
du
d u
I
M + H
+ t3 u = e-t
dt L
dt2
dt 3
2

d u
du
4 x2
+ 3 x
dx + xu = u Sin HxL
dx2
2

u
2 u
u
t + x
x2 = Cos HtL
2

Solution
2

d u
(i) The order is 2, since the highest derivative of u is
dt 2
du
(ii) The order is 1, since the highest derivative of u is
dt . Note that even though the derivative is raised to the
third power, the order of the differential equation is still determined by the highest derivative.
3

d u
(iii) The order is 3, since the highest derivative is
dt 3
2

d u
(iv) The order is 2, since the highest derivative is
dx 2

(v) In this case we have a partial differential equation. It is first order in the t derivative, and second order in the x
derivative.

Concept 4:

A variable y HxL is said to be of nth degree if it has the form yn HxL. Likewise, a derivative of y is of nth
degree if it has the form
dy n
H
dx L
Higher order derivatives of nth degree are given by
d2 y n
dp y n
I
M , H
L
dx p
dx2

FirstOrderODEs_Primer.nb

Concept 4:
An ordinary differential equation (ODE)
F Hx, y, y ', y ' ', yH3L , , yHnL L = 0
is said to be linear if
(i) the dependent variable and its derivatives are all of 1st degree, and
(ii) the coefficients multiplying the derivatives are at most a function of the independent variable,x.
The most general form for a nth order linear ODE is
dn y
dn-1 y
dy
an HxL
+ an-1 HxL
+ + a1 HxL
dx + a0 HxL = f HxL
dxn
dxt n-1
In this module we will use either x or t to denote the independent variable. The dependent variable may be
denoted by y, u or w. The alphabetic choice for a variable is often dictated by personal factors, or to conform to
physical variables, e.g. time is often denoted by the variable t. Thus it is imperative the student understand how to
determine which are the independent and dependent variables in any given problem. We will see shortly that
calculus allows us to often to interchange the dependent and independent variables. That is we can write y HxL or
x HyL.

## Example 3.3: Classification of differential equations

Classify the following ODEs:
(i)
(ii)
(iii)
(iv)

d u

+ u - Log HtL = 0
dt2
2

du
H
dt L

+ t2 u = 0

d u
du
d u
I
M + H
+ t3 u = e-t
dt L
dt2
dt 3
2

d u
du
4 x2
+ 3 x
dx + xu = u Sin HxL
dx2
2

Solution
(i) This is a linear second order ODE with variable coefficients
(ii) This is a nonlinear first order ODE with variable coefficients. Note that the first derivative is of degree 2.
(iii) This is a nonlinear third order ODE with variable coefficients. Note that the second derivative is of degree
du
two and the coefficient multiplying the third derivative depends on u, (actually
dt )
(iv) This is a linear, second order ODE with variable coefficients.

10

FirstOrderODEs_Primer.nb

Concept 6:

## We say y HtL = f HtL is a solution of the nth order ODE

F Ht, y, y ', y ' ', yH3L , , yHnL L = 0
if on a given interval a < t < b, y HtL = f HtL is continuous and has derivatives to at least order n, such that on
substitution it reduces F Ht, y, y ', y ' ', yH3L , , yHnL L = 0 to an identity on the interval.

## Example 3.4: Solutions to ODEs

Show that the following are solutions to the given ODE:

dy
3 x +2

dx =
2 Hy-1L
2

## (ii) y HtL = c1 Cos H3 tL + c2 Sin H3 tL is a solution to

2

d y

+9t = 0
dt 2

2 ce
(iii) y HtL =
t is a solution to
1+ce2
2t

dy

dt = y H2 - yL

Solution

(i) In this case g Hx, yL yields y as an implicit function of t. Differentiating g Hx, tL with respect to x gives
dy
dy
2
2 y
dx - 2
dt = 3 x - 2 x
dy
Solving for
dx gives
dy
3 x +2

dx =
2 Hy-1L
2

Note that g Hx, y, cL = 0 defines a 1-parameter family of level curves that according to Concept 2 must
satisfy
dy
g
g
3 x +2

dx = -
x H
y L =
2 Hy-1L
-1

## (ii) If we differentiate y HtL = c1 Cos H3 tL + c2 Sin H3 tL twice we obtain

d y

= -9 c1 Cos H3 tL - 9 c2 Sin H3 tL
dt 2
2

d y

## - 9 y = -9 c1 Cos H3 tL - 9 c2 Sin H3 tL - 9 8c1 Cos H3 tL + c2 Sin H3 tL<

dt 2
=0
Note that in this example to solution is defined by a 2-parameter family.

Thus

## (ii) If we differentiate y HtL = c1 Cos H3 tL + c2 Sin H3 tL twice we obtain

d y

= -9 c1 Cos H3 tL - 9 c2 Sin H3 tL
dt 2
FirstOrderODEs_Primer.nb
2

11

d y

## - 9 y = -9 c1 Cos H3 tL - 9 c2 Sin H3 tL - 9 8c1 Cos H3 tL + c2 Sin H3 tL<

dt 2
=0
Note that in this example to solution is defined by a 2-parameter family.

Thus

dy
4 ce
2 ce
4 ce

2 ce2 t =

2 t L -
dt =
H1+ce
2t 2
2t 2
H1+ce

2t

2t

H1+ce

2t

Now from

2 ce
y HtL =
t
1+ce2
2t

## we can solve for c to find

y
c =
e-2 t
H2-yL

dy
Substituting for c in the expression found for
dt gives

dy
y
y H2-yL
4 ce
1

= 4
2 = 4
2t 2
dt =
2-y y
4 = y H2 - yL
H1+ce

2t

H1+
2-y L

Note we can deduce from the differential equation that y = 2, and y = 0 are also solutions to the ODE. These
solutions can be found as special cases of the 1-parameter family y HtL = 2 ce2 t 1 + ce2 t when c = 0, and
when t -> , respectively. This behavior of multiple solutions occurs because the ODE is nonlinear . We will
discuss this point later.

Concept 7:

The
solution
y HtL = 0
is
called
the
trivial
solution
to
the
F Ht, y, y ', y ' ', yH3L , , yHnL L = 0 if on substitution it satisfies the differential equation.

ODE:

Concept 8:
Suppose every solution of a nth order ODE in a given interval is determined from
g Ht, y; c1 , c2 , , cn L = 0
by suitable choice of the parameters ci . Then we say that
g Ht, y; c1 , c2 , , cn L = 0
is the general solution of the nth order ODE:
F Ht, y, y ', y ' ', yH3L , , yHnL L = 0
Concept 8 implies that the general solution of a nth order ODE is a n-parameter family. Although this is strictly
true for a nth order linear ODEs, the situation may be more complicated for nonlinear ODEs. The following
example illustrates this point.

12

FirstOrderODEs_Primer.nb

## Example 3.5: Solution of Clairaut's equation

Consider the following 1st order ODE
dy
dy 3
y = t
dt + H
dt L
(i) Show that y HtL = c1 t + c1 3 is a general solution to
4
3
(ii) Show further that y2 = -
27 t is also a solution

Solution

dy
Let us differentiate y HtL = c1 t + c1 3 . This gives
dt = c1 . Thus substituting into the ODE gives

c1 t + c1 3 = c1 t + c1 3

4
3
which shows that y HtL = c1 t + c1 3 is a solution. Next consider y2 = -
27 t . Differentiating gives
2

dy
dy
12
2 t
2
2 y
dt = -
27 t fl
dt = -
9
y

3

2t
8
t
y = -
9 y -
981
y3

## Multiplying through by y3 gives

2
8
3 2
6
y4 = -
9 t y -
981 t
4
3
Substituting for y2 = -
27 t gives
16
8
8
16
6

t6 =
t6 =
t6
927 t -
27 2
27 2
272
4
3
Hence y2 = -
27 t is also a solution. Note however that this solution is not contained within the one-parameter
solution y HtL = c1 t + c1 3 . It is called a singular solution

Concept 9:

Suppose that g Ht, y; c1 , c2 , , cn L = 0 is a general solution of a nth order ODE. We say that the function
yp HtL is a particular solution of the nth order ODE if it satisfies the ODE and is free of any parameters.
Clearly, a particular solution can always be found by choosing specific values for the parameters in the general
solution.

FirstOrderODEs_Primer.nb

## Example 3.6: Finding a particular solution of a ODE

Consider the following ODE
2

d x

+ 9 y = e2 t
dt 2

1
2t
Show that xp HtL =
is a particular solution.
13 e

Solution
To be a particular solution it must satisfy the ODE and have no free parameters. By direct differentiation we can
show
4
9
2t
2t

+
= e2 t
13 e
13 e

and since it does not have any free parameters xp HtL is a particular solution to the ODE.

## 4. Linear Differential Equations

From Concept 5 it follows that the most general form for a 1st order linear ODE is
dy
a1 HxL
dx + a0 HxL y = f HxL

The equation is said to be homogeneous if the function f HxL vanishes. If f HxL does not vanish, the equation is
said to be inhomogeneous. In our analysis we will assume that the functions a1 HxL, a0 HxL, and f HxL are
continuous over some finite interval a < x < b.
It is helpful to use the concepts and definitions from Section 3 and apply them to first order ODEs:
(a) A solution to a 1st order ODE is a relationship between the dependent variable y and the independent variable
x, free of any derivatives, which satisfies the ODE identically.
(b) We can classify solutions to 1st order ODEs in the following ways:
(i) A general solution of a 1st order ODE is a solution that involves one arbitrary constant (See Concept 8).
(ii) A particular solution of a 1st order ODE is found from the general solution by assigning a value to the arbitrary constant in the general solution (See Concept 9).
(iii) A singular solution of a 1st order ODE is a solution that cannot be derived from the general solution by
assigning a value to the arbitrary constant in the general solution.
(iv) An equilibrium solution of a 1st order ODE is given by y = constant, which satisfies the ODE.
(c) Two additional definitions related to existence and uniqueness of solutions to ODEs will be studied in this
section.
(i) The question of existence addresses whether a ODE has a solution.
(ii) The question of uniqueness addresses whether the ODE has more than one solution for a given set of
parameters.
The solution of linear homogeneous 1st order ODE is given by the following concept:

13

14

FirstOrderODEs_Primer.nb

Concept 10:

If a1 HxL,and a0 HxL are continuous over some interval a < x < b, then the general solution to the linear
homogeneous 1st order ODE :
dy
a1 HxL
dx + a0 HxL y = 0
is given by
a0 HxL
y HxL = C Exp H-
xL
a1 HxL
where C is an arbitrary constant

## Example 4.1: Proof of Concept 10

To show that the solution to

dy
a1 HxL
dx + a0 HxL y = 0

is

a0 HtL
y HxL = C Exp H-
tL
a1 HtL

we proceed as follows. First, we rearrange the equation by separating variables: we collect terms involving y on
one side, and terms involving x are collected on the other side of the equation:
dy
a0 HxL

dx
y = -
a1 HxL

## Then integrating each side we obtain

a0 HxL
a0 HxL
1
x fl Ln H y L = -
x + C '

y y = -
a1 HxL
a1 HxL

Thus

a0 HxL
y HxL = Exp@C 'D Exp H-
x L
a1 HxL

a0 HxL
y HxL = Exp@C 'D Exp H-
x L
a1 HxL

## Absorbing the arbitrary sign into a new constant C ' '

a0 HxL
y HxL = Exp@C ' 'D Exp H-
x L
a1 HxL

So finally we have

a0 HxL
y HxL = C Exp H-
x L
a1 HxL

When the 1st order ODE is inhomogeneous, the general solution can be found by the method of integrating
factors. We motivate the method by solving a simple inhomogeneous ODE, given in Example 4.2.

FirstOrderODEs_Primer.nb

15

## Example 4.2: Inhomogeneous Linear First-Order ODE

Find the general solution to the following linear ODE
dy

dx +2y = 4

Solution
First, we rearrange the terms so that
dy

d x = 2 H2 - yL

fl

dy
1

= 2
d x
H2-yL

## But recall that

dy
d
1

dx 8Ln H 2 - y L< = -
2-y
dx

## Thus we can write the ODE as

dx 8ln H 2 - y L< = -2

Integrating gives

Ln H 2 - y L = -2 x + C '

## This can be reorganized as (See Example 4.1)

2 - y = CExp H-2 xL

or

y HxL = 2 + C E-2 x

## Another form for the solution is

g Hx, yL = H2 - yL E2 x = C

Thus the general solution to a 1st order ODE defines a family of level curves (See Section 2), also known as
integral curves. Here is a plot of the level curves for select values of C.

16

FirstOrderODEs_Primer.nb

y2

0
0

3
x

For large x, the general solution asymptotes toward y = 2. Note that in our derivation we assumed that y 2, as
1 H2 - yL = .
If we reverse the steps leading to the solution given in Example 4.2, we can devise a method for solving linear
inhomogeneous 1st order ODEs.
(i) First, we multiple the original ODE in Example 4.2 by E2 x . This gives
dy
2x
H
= 4 E2 x
dx + 2 yL E

dy
d
H
+ 2 yL E2 x =
HyE2 x L
dx
dx

## such the original ODE becomes

d
2x

L = 4 E2 x
dx HyE

FirstOrderODEs_Primer.nb

17

## (iii) Finally we integrate both sides to obtain

yE2 x = 2 E2 x + C
which on reorganization gives
y = 2 + CE-2 x

The function m HxL E2 x that we multiplied the original ODE with is called an integrating factor. Our goal then
is to devise a general method for finding integrating factors m HxL. The following concept addresses that goal:

Concept 11:
The general solution to a linear 1st order ODE :
dy

dx + p HxL y = f HxL

is given by
1
y HxL =
m HxL 9 m HxL f HxL x + C=

where

m HxL = E

p HxL x

## is called the integrating factor.

Thus it follows from Concept 11 that once an integrating factor m HxL is found (which entails integrating the
function p HxL), the general solution can be found by doing one more additional integration. The proof of Concept 11 is given in Example 4.3.

## Example 4.3: Proof of Concept 11

Our goal is to find a function m HxL such that

dy
d
m HxL H
dx + p HxL yL
dx Hm HxL yL

If we can find such a function then the original ODE can be written as
d

## In this form we can integrate both sides to obtain

m HxL y = m HxL f HxL x + C
Hence the general solution is then
1
y HxL =
m HxL 9 m HxL f HxL x + C=

## To find m HxL we note that

18

FirstOrderODEs_Primer.nb

## Hence the general solution is then

1
y HxL =
m HxL 9 m HxL f HxL x + C=

dy
d
m HxL H
dx + p HxL yL
dx Hm HxL yL

is true if
dm

dx = m p

## Integrating this equation gives

m HxL = C E

p HxL x

The constant of integration C can be set equal to unity without loss of generality since the ODE for m HxL is
homogeneous

Concept 12:
The Initial value problem for 1st order linear ODEs is given by:
dy

dx + p HxL y = f HxL

## subject to the initial condition

y Hx i L = yi

The solution to the initial value problem must satisfy both the ODE and the initial condition. The initial condition
selects a level curve from the family of level curves that satisfy the ODE.

## Example 4.4: Solution of First-Order Linear ODEs

Find the general solution to the following 1st order linear ODEs by determining an integrating factor.
dy
3x
(i)
dx + 2 y = E

dy
(ii) H1 - x2 L
dx = 7 xy

dy
-3 x
(iii) x
dx + H3 x + 1L y = 2 E

FirstOrderODEs_Primer.nb

19

Solution

## (i) In this case p HxL = 2, and f HxL = E3 x so that

m HxL = E 2 x = E2 x

## We also need to evaluate

1
2x 5x
5x
5x
m HxL f HxL x = E E x = E x =
5 E

1
1
1
5x
3x
y HxL =
+ C< =
+ CE-2 x
E2 x 8
5 E
5 E

x
p HxL = -7
H1-x2
L , f HxL = 0

x
7
2
m HxL = ExpA-7
H1-x2
L xE = Exp@
2 Ln H-1 + x LD

= Hx2 - 1L

## and the general solution is

H x -1 L

y =
C

72
2

H3 x+1L
2
-3 x .
(iii) In this case p HxL =
x and f HxL =
x E
The integrating factor is
H3 x+1L
1
m HxL = ExpA
x xE = ExpA 3 x +
x xE

= Exp@3 x + Ln HxLD = x E3 x
Thus the general solution is
1
2
1
-3 x
y HxL =
9 xE3 x
x + C= =
82 x + C<
x E
xE3 x
xE3 x
C
-3 x
= 2 E-3 x +
x E

20

FirstOrderODEs_Primer.nb

## Example 4.5: Solution of Initial Value Problems

Find the solution to the following initial value problems:

dy
dy
3
(i) x
dx - 3 y = 2 x , y H1L = 3 (ii) Hx + 1L
dx + 2 y = Ln HxL, y H1L = 3
dy
(iii) Cos2 HxL
dx + 2 y = 1, y H0L = 1

Solution

3
2
(i) In this problem p HxL = -
x and f HxL = 2 x . The integrating factor is:
3
-3
m HxL = ExpA-
x xE = Exp@-3 Ln HxLD = x

## Thus the general solution is

1
-3
y HxL =
2 x2 x + C=
x -3 9 x

= x3 82 Ln HxL + C<
The initial condition gives

## y HxL = x3 82 Ln HxL + 3<

Ln HxL
2
(ii) For this problem p HxL =
and f HxL =

Hx+1L
Hx+1L
The integrating factor is
1
m HxL = ExpA2
xE = Exp@2 Ln H2 x + 1LD
Hx+1L

= Hx + 1L2
The general solution is
Ln HxL
1
y HxL =
9 Hx + 1L2
x + C=
Hx+1L
Hx+1L2

1
x
1
=
9-x -
4 +
2 x H2 + xL Ln HxL + C=
Hx+1L2
2

1
1
1
y H1L 3 =
4 8-1 -
4 + C< fl C = 13
4

## Hence the solution to the iVP is

1
x
1
1
y HxL =
9-x -
4 +
2 x H2 + xL Ln HxL + 13
4 =
Hx+1L2
2

=
9-x -
+
x H2 + xL Ln HxL + C=
4
2
Hx+1L2
Next we apply the initial condition:
FirstOrderODEs_Primer.nb
y H1L 3 =

8-1 -

21

+ C< fl C = 13

## Hence the solution to the iVP is

1
x
1
1
y HxL =
9-x -
4 +
2 x H2 + xL Ln HxL + 13
4 =
Hx+1L2
2

2
1
(iii) For this case p HxL =
and f HxL =

Cos2 HxL
Cos 2 HxL

## The integrating factor is

2
m HxL = ExpA
xE = Exp@2 Tan HxLD
Cos 2 HxL

1
1
2 Tan HxL
y HxL =
x + C=
HxL 9 E
E 2 Tan
Cos 2 HxL
1
1
2 Tan HxL
=
+ C<
HxL 8
E2 Tan
2 E

1
1
1
0L + C< fl C =
y H0L 1 =
E0L 8
2 E
2

## Thus the solution to the IVP is

1
1
1
2 Tan HxL
y HxL = =
+
HxL 8
E2 Tan
2 E
2 <

In Example 4.5 we showed how to determine the constant of integration from the specified initial condition.
Because the general solution represented as g Hx, yL = C, is in general a nonlinear function of x and y , there is
usually not a one-to-one relation between the initial conditions Hxi , yi L and the value of C. In other words,
different initial conditions may yield the same value of C., as we show and discussed in Example 4.6.

## Example 4.6: Solution of Multiple Initial Value Problems

Find the solution to the following initial value problem:
dy
y

dx +
x = 2

## y H1L = 0, y H1L = 1, y H1L = 2

Plot the level curves for the values of C determined from the initial condition.

22

FirstOrderODEs_Primer.nb

Solution
The integrating factor for this problem is
1
m HxL = ExpA
x xE = Exp@Ln HxLD = x

## Thus the general solution is

1
C
y HxL =
x 9 2 x x + C= = x +
x

## (i) C = -1 for y H1L = 0, (ii) C = 0 for y H1L = 1, (iii) C = 1 for y H1L = 2.

To plot the level curves for the values of C = 8-1, 0, 1<, we make use of Mathematica's ContourPlot
function. Here is the code to achieve the desired result:
ContourPlot@x Hy - xL, 8x, -3, 3<, 8y, -3, 3<,
ContourShading -> False, Contours -> 8-1, 0, 1<, PlotPoints -> 120,
Epilog -> 8PointSize@0.03D, Hue@.9D, Point@81, 0<D,
Point@81, 1<D, Point@81, 2<D<, FrameLabel -> 8"x", "y"<D;
3

y 0

-1

-2

-3
-3

-2

-1

0
x

The solution curves that have a red marker are the solutions to the initial value problem. Note that for each value
of C there are two sets of trajectories. This illustrates the lack of one-to-one correspondence between initial values
and the parameter C. Note further that two trajectories intersect each other at the point 80, 0<. This means that if
we specify y H0L = 0as our initial condition, the solution is not unique! We can trace out either of the trajectories that intersect at 80, 0<. In the next section we will discuss what conditions must be met to ensure that we
have the existence of a unique of solution to IVP.

The solution curves that have a red marker are the solutions to the initial value problem. Note that for each value
FirstOrderODEs_Primer.nb
of C there are two sets of trajectories. This illustrates the lack of one-to-one correspondence between initial values
and the parameter C. Note further that two trajectories intersect each other at the point 80, 0<. This means that if
we specify y H0L = 0as our initial condition, the solution is not unique! We can trace out either of the trajectories that intersect at 80, 0<. In the next section we will discuss what conditions must be met to ensure that we
have the existence of a unique of solution to IVP.

5. Separation of Variables
In Section 4 the key assumption was that the 1st Order ODE was linear. This allowed us to introduce the concept
of an integrating factor, and through simple quadrature formulas the general solution to the ODE could be found.
When the ODE is nonlinear (i.e. the ODE contains terms involving yn , or transcendental functions of y such as
Sin HyL), then it is not possible to use the recipe based on integrating factors. However, if the nonlinear ODE has
a special form given by
dy

## dx = F Hx, yL f HxL y HyL

then it is possible to reorganize terms such that the general solution can once again be found by quadrature, as
explained in the following concept:

Concept 13:
If a differential equation

dy

dx = F Hx, yL

dy

## it is said to be separable. The general solution is then found by quadrature

1

y HyL y = f HxL x + C

## which on integration can be expressed as

G HyL = H HxL + C

The general solution can also be expressed as a 1-parameter family of level curves
g Hx, yL = C

where

## g Hx, yL G HyL - H HxL

23

24

FirstOrderODEs_Primer.nb

## Example 5.1: Separable equations

Determine which of the following equations are separable:
dy
Hy+1L
dy
y x
(i)
2 + x 2
dx =
Hy- y
x 2 L , (ii)
dx =
H1+ x2 + y
y2 L
3

dy
-y + E-2 x+ y ,
(iii) Sin HxL y
dx = E

dy
(iv) Log Hy2
dx L = x

dy
(v) Sin@x + yD
dx = Tan HxL + Tan HyL,

dy
x y+x+y
(vi)
dx =
x y

Solution

Hy+1L
(i) Here F Hx, yL =
Hy- y
x 2 L . Thus we can write this expression as
3

Hy+1L
Hy+1L

Hy- y
x2 L =
y H1-
x 2 L
3

so that

dy
Hy+1L

dt =
y H1-
x2 L = f HxL y HyL
3

where

Hy+1L
1
f HxL =
H1-x2
L , y HyL =
y
3

## Thus the ODE is separable.

y x
(ii) Here F Hx, yL =
H1+ x2 + y2
+ x2
y2 L . We can regroup terms in the denominator to give
dy
yx
yx

= f HxL y HyL
2 LL =
dx =
H1+x2 + y 2
H1+ x
H1+x2 L H1+
y2 L

where

y
x
f HxL =
H1+x2
L , y HyL =
H1+y2
L

## Thus the ODE is separable.

E +E
(iii) Here F Hx, yL =
Sin HxL y
. We can reorganize the terms in the numerator to obtain
-y

-2 x+ y

dy
E
H1+ E
L

= f HxL y HyL
dx =
Sin HxL
y
-y

where

-2 x

H1+ E
L
E
f HxL =
Sin
HxL , and y HyL =
y
-2 x

## Thus the ODE is separable.

(iv) For this example it is best to write

dy
2 dy
x
Log Hy2
dx L = x as y
dx = E

Then

dy
E

dx =
y2 = f HxL y HyL
x

where

1
f HxL = Ex and y HyL =
y2

-y

## (iv) For this example it is best to write

FirstOrderODEs_Primer.nb
Log Hy

Then

dy

dx L

= x as y

dy

dx

25
=E

dy
E

dx =
y2 = f HxL y HyL
x

where

1
f HxL = Ex and y HyL =
y2

## Tan HxL+Tan HyL

(v) In this example F Hx, yL =
. Recall from trig identities that
Sin Hx+yL

## Sin Hx + yL = Cos HyL Sin HxL + Cos HxL Sin HyL

= Cos HxL Cos HyL 8Tan HxL + Tan HyL<

Thus

where

dy
Tan HxL+Tan HyL
1

= f HxL y HyL
dx =
Cos HxL Cos HyL 8Tan
HxL+Tan
HyL<
Cos HxL Cos
HyL

1
f HxL =
and
Cos HxL

1
y HyL =

Cos HyL

## Thus the ODE is separable.

x y+x+y
(vi) Here F Hx, yL =
x y . We can reorganize the numerator as

dy
x Hy+1L+y
Hy+1L
1

=
dx =
xy
y +
x

## Example 5.2 General Solution to Separable ODEs

Find the general solution to the following ODEs:
dy
Hy+1L
dy
y x
(i)
2 + x 2
dx =
Hy- y
x2 L , (ii)
dx =
H1+ x2 + y
y2 L ,
3

dy
(iii) Sin@x + yD
dx = Tan HxL + Tan HyL

26

FirstOrderODEs_Primer.nb

Solution
(i) From Example 5.1 we can express the ODE as
dy
Hy+1L

dt =
y H1-
x2 L
3

Integrating gives
y
1
y =

H1-x2
L x
Hy+1L3

y
1
1
y =
-

1+y
Hy+1L3
2 H1+yL2
1
1
1

H1-x2
L x=-
2 Log Hx - 1L +
2 Log Hx + 1L

Hx+1L
1
2

-
D = C
1+y - Log@
Hx-1L
H1+yL2

or

H1+2 yL
Hx+1L

+ Log@
D = C
Hx-1L
H1+yL2

## (ii) From Example 5.1, we can rewrite the ODE as

dy
yx

dx ==
H1+x 2 L H1+
y2 L

Integrating gives
H1+y L
x

y y =
H1+x2
L x
2

to yield

y
1
2

2 + Log HyL =
2 Log H1 + x L + C
2

(iii) From Example 5.1 we can rewrite the ODE in the form
dy
1

dx =
Cos HxL Cos
HyL

Integrating gives
1
x
Cos HyL y =
Cos HxL

x
x
x
x
Sin HyL = -Log@Cos H
2 L - Sin H
2 LD + Log@Cos H
2 L + Sin H
2 LD + C

dy
1

dx
Cos HxL Cos HyL

Integrating gives
FirstOrderODEs_Primer.nb

1
x
Cos HyL y =
Cos HxL

x
x
x
x
Sin HyL = -Log@Cos H
2 L - Sin H
2 LD + Log@Cos H
2 L + Sin H
2 LD + C

The general solutions obtained in Example 5.2 are complicated implicit functions of x and y . Thus graphical tools
are essential for visualizing how the solution behaves and its dependence on the constant of integration. A
convenient way of visualizing the solution is to plot the family of level curves g Hx, yL = G HyL - H HxL = C .
This can best be achieved using Mathematica's ContourPlot routine, as shown in Example 5.3.

## Example 5.3: Graphical Display of General Solutions

Use Mathematica's ContourPlot routine to visualize the general solution as a family of level curves.
Solution
The Mathematica code to display the solution is given below:

H1+2 yL
Hx+1L
(i) g Hx, yL =
+ Log@
D = C. Note since we plan to plot our level curves for negative x values ,
Hx-1L
H1+yL2

we must replace the arguments of any logarithmic functions with absolute values. Thus we define our function
g Hx, yL
H1 + 2 yL
Hx + 1L
g@x_, y_D := + LogA E . Log@a_D -> Log@Abs@aDD
2
Hx - 1L
H1 + yL
g@x, yD

1+2y
1+x

+ LogAAbsA EE
2
-1
+x
H1 + yL

Next we use ContourPlot to display the level curves for representative values of C.

27

28

FirstOrderODEs_Primer.nb

## ContourPlot@Evaluate@g@x, yDD, 8x, -4, 4<, 8y, -4, 4<,

FrameLabel -> 8"x", "y"<, ContourShading -> False,
PlotPoints -> 120, ContourStyle -> Hue@.7DD;
4

y 0

-2

-4
-4

-2

0
x

Observe that the function g Hx, yL is not defined for y = -1, and x = 1. The level curves have singularities at
these values.
y
1
2
(ii) g(x,y)=
2 + Log HyL -
2 Log H1 + x L
2

y2
1
g@x_, y_D := + Log@yD - Log@1 + x2 D . Log@a_D -> Log@Abs@aDD
2
2
g@x, yD
y2
1
- Log@Abs@1 + x2 DD + Log@Abs@yDD
2
2

FirstOrderODEs_Primer.nb

29

## ContourPlot@Evaluate@g@x, yDD, 8x, -4, 4<, 8y, -4, 4<,

FrameLabel -> 8"x", "y"<, ContourShading -> False,
PlotPoints -> 120, ContourStyle -> Hue@.7DD;
4

y 0

-2

-4
-4

-2

0
x

## In this example the solution is not defined for y = 0.

x
x
x
x
(iii) g Hx, yL = Sin HyL + Log@Cos H
2 L - Sin H
2 LD - Log@Cos H
2 L + Sin H
2 LD

g@x_, y_D :=

x
x
x
x
JSin@yD + LogACosA E - SinA EE - LogACosA E + SinA EEN .
2
2
2
2

g@x, yD

x
x
x
x
LogAAbsACosA E - SinA EEE - LogAAbsACosA E + SinA EEE + Sin@yD
2
2
2
2

30

FirstOrderODEs_Primer.nb

## ContourPlot@Evaluate@g@x, yDD, 8x, -4, 4<, 8y, -4, 4<,

FrameLabel -> 8"x", "y"<, ContourShading -> False,
PlotPoints -> 120, ContourStyle -> Hue@.7DD;
4

y 0

-2

-4
-4

-2

0
x

x
In this example we have singularities when Tan H
2 L = 1, or x = 1.5708

The solutions that we have examined in the previous examples were generated by nonlinear ODEs. Before undertaking an analysis of an ODE, it is useful to know beforehand whether a solution exists, and if so, is it unique. The
following concept is provides the analysis tools for determining existence and uniqueness.

Concept 14:
Consider the initial value problem
dy

dx = F Hx, yL,

y Hxi L = yi

If F and F y are continuous in some region !, defined by a < x < b, and c < y < d, then there exists an
interval x - xi < h centered at xi in which there exists a unique solution to the IVP.
We apply this test for uniqueness defined by Concept 14 in the following examples

FirstOrderODEs_Primer.nb

31

## Example 5.4: Existence and Uniqueness

Consider the following linear IVP problem:

dy
Cos HxL
2

dt = F Hx, yL = -
x y +
x , y Hxi L = yi

It follows from Concept 14 that F and F y are continuous everywhere except at x = 0 . Since F and
F y are not continuous at x = 0, we cannot be assured that a solution exists or if it does exists that it is
unique. Let us explore what happens when we consider the following initial value points:
xi = 0, yi = 1; xi = 1, 1; xi = 2, yi = 1. The general solution to this problem can be readily found by
seeking an integrating factor (see Section 4). The result is
m HxL = x2

C+ Cos@xD+ x Sin@xD
y HxL =

2
x

If we apply the initial conditions we find that the constant of integration takes on the following values for the three
cases: C = -1., C = -0.381773, C = 2.59755
The level curves of the general solution with the above values of C are shown below. The red dots define the
initial conditions. Note that there is a unique curve that passes through two of the initial values that have
xi 0. The case xi = 0 has no level curve passing through the initial value. A solution does not exist for this
IVP.
4

-1
-3

-2

-1

32

FirstOrderODEs_Primer.nb

## Example 5.5: More on Existence and Uniqueness

Consider the following IVP:
dy
x

dx =
y ,

y H0L = 0

Determine the general solution and then solve the IVP. Discuss the solution behavior at y H0L = 0

Solution
The equation can be solved by separation of variables
y
G HyL = y y =
2 ,
2

x
H HxL = x x =
2
2

1
2
2
g Hx, yL =
2 Hy - x L = C

## If we apply the initial condition we find C=0. Thus

y = x

This means we have two trajectories passing through the point H0, 0L. Hence the solution is non-unique. It
follows from Concept 14 that the condition for uniqueness is not satisfied at H0, 0L as both F Hx, yL and
F y are not continuous at H0, 0L. The solution trajectories are shown below for a set of initial conditions.
4

y 0

-2

-4
-4

-2

0
x

FirstOrderODEs_Primer.nb

33

## Two trajectories pass through H0, 0L!

In nonlinear problems, it is possible that a solution my cease to exist on a finite interval even though both
F Hx, yL, F y are continuous on that interval. Concept14 addresses local behavior of solutions. The global
behavior of the solution may behave in unexpected ways. In particular, at a finite value of x, the solution may
"blow-up". We illustrate this behavior in the following example.

## Example 5.6: Blow-up of Global Solutions

Determine the solution to the following IVP problem:
dy
2

dx = y , y H0L = a

## Discuss the global behavior of the solution as a function of the parameter a.

Solution
Since this equation is separable, we can write:
1
1
G HyL =
y2 y = -
y ,

H HxL = 1 x = x

## Thus the general solution is

1

y +x = C
1
Applying the initial value gives c =
a Thus the solution is
a
y HxL =
1-a x

For positive a, the solution is defined on the interval - < x < 1 a. At x = 1 a the solution blows up an
becomes undefined. Thus even though the conditions of Concept 14 hold for - < x < , the global properties
of the solution are not defined over this interval.

6. References
These notes were developed using several sources. In particular I found the textbook by Zill and Cullen most
useful and followed their approach in presenting the material in this notebook.
(1) Dennis G. Zill and Michael R. Cullen, Advanced Engineering Mathematics, PWS-KENT, Boston, MA, 1992
(2) Arvind Varma and Massimo Morbidelli, Mathematical Methods in Chemical Engineering, Oxford University Press, 1997.
(3) Martha L. Abell andJames P.Braselton, Differential Equations with Mathematica, 2nd Edition, Academic Press, 1997
(4) George Arfken, Mathematical Methods for Physicists, 3rd Edition, Academic Press, 1985
(5) Michael D. Greenberg, Foundations of Applied Mathematics, Prentice-Hall, Englewood Cliffs, NJ, 1978