You are on page 1of 13

Chapter 2

First Order Differential Equations

Note: This module is prepared from Chapter 2 of the text book (G.F. Simmons, Differential
Equations with Applications and Historical Notes, TMH, 2nd ed., 1991) just to help the students.
The study material is expected to be useful but not exhaustive. For detailed study, the students
are advised to attend the lecture/tutorial classes regularly, and consult the text book.

Dr. Suresh Kumar, Associate Professor,


Department of Mathematics, BITS Pilani, Pilani Campus, Rajasthan-333031, INDIA.
E-mail: suresh.kumar@pilani.bits-pilani.ac.in, sukuyd@gmail.com

Appeal: Please do not print this e-module unless it is really necessary.

1
Contents

2 First Order Differential Equations 1


2.1 First Order Differential Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Exact methods for solving first order DE . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2.1 Variable separable DE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2.2 DE reducible to variable separable . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 Exact DE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4 Integrating Factor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4.1 Existence and uniqueness of Integrating Factor . . . . . . . . . . . . . . . . . 7
2.4.2 IF of first order linear DE . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.4.3 Bernoulli’s DE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4.4 IF of homogeneous DE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Clairaut’s DE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.6 Existence and uniqueness of solution of IVP . . . . . . . . . . . . . . . . . . . . . . 10
2.7 Analytical and Numerical Solutions of a First Order LDE in Python . . . . . . . . . 12

2
2.1 First Order Differential Equations
In general, any first order DE is of the form

g(x, y, y 0 ) = 0. (2.1)

Sometimes, it is possible to write the first order DE (2.1) in the canonical form

y 0 = f (x, y) (2.2)

There is no method to find a general solution of (2.1) or (2.2).

2.2 Exact methods for solving first order DE


In the following, we present some particular families of first order DE and exact methods to solve
the same.

2.2.1 Variable separable DE


A first order DE is said to be in variable separable form if it can be written as

y 0 = F (x)G(y), (2.3)

where F (x) is function of x, and G(y) is function of y. Equation (2.3) can be rewritten as

dy
= F (x)dx,
G(y)

which on integration, yields the solution


Z Z
dy
= F (x)dx + C,
G(y)

where C is a constant of integration.

Ex. 2.2.1. Solve y 0 = y cos x.

Solution 2.2.1. y = cesin x .

2.2.2 DE reducible to variable separable


There are DE which are not directly variable separable but can be reduced to variable separable
by using some suitable transformation(s). In the following, we present some families of such DE.

3
DE of the form y 0 = f (ax + by + c)
Here a, b and c are constants. Such DE can be reduced to variable separable by using the trans-
formation

ax + by + c = t.

For, we have a + by 0 = t0 , which transforms the DE y 0 = f (ax + by + c) into the variable separable
DE

t0 = bf (t) + a

with the general solution


Z
dt
= x + C.
bf (t) + a

Ex. 2.2.2. Solve y 0 = sin(x − y).

Solution 2.2.2. sec(x − y) + tan(x − y) = x + c.

Homogeneous DE
A function h(x, y) is said to be homogeneous function of degree n if h(tx, ty) = tn h(x, y). A DE
of the form M (x, y)dx + N (x, y)dy = 0 is said to be homogeneous if M (x, y) and N (x, y) are
homogeneous functions of same degree. The DE M (x, y)dx + N (x, y)dy = 0 can be rewritten
as y 0 = −M (x, y)/N (x, y) = f (x, y) (say). Therefore, a DE expressed in the form y 0 = f (x, y)
is homogeneous if f (tx, ty) = f (x, y) = f (1, y/x). To solve the homogeneous DE, we use the
transformation y = vx, where v is a function of x. This gives y 0 = v + xv 0 . So the DE y 0 = f (x, y)
transforms to

v + xv 0 = f (1, v),

which can be rearranged in the variable separable form


dv dx
= .
f (1, v) − v x

Integrating both sides, we get the general solution


Z
dv
= ln x + C.
f (1, v) − v
x+y
Ex. 2.2.3. Solve y 0 = x−y
.
p
Solution 2.2.3. tan−1 (y/x) = log x2 + y 2 + C.

4
DE of the form y 0 = (ax + by + c)/(px + qy + r)
Here a, b, c, p, q and r are constants. In case, ap = qb = m (say), we have ax + by = m(px + qy).
Then the transformation px + qy = t transforms the given DE into variable separable form. Now,
consider that ap 6= qb . In this case, we use the transformations x = X + h and y = Y + k, where
h and k are constants to be determined from the equations ah + bk + c = 0 and ph + qk + r = 0.
The equation y 0 = (ax + by + c)/(px + qy + r), then, transforms to

dY aX + bY
= ,
dX pX + qY
which is a homogeneous DE in X and Y .
x+y+4
Ex. 2.2.4. Solve y 0 = x−y−6
.
y+5
p
Solution 2.2.4. tan−1

x−1
= log (x − 1)2 + (y + 5)2 + c.

2.3 Exact DE
dy
The first order DE dx = f (x, y) can be written in the canonical form M (x, y)dx + N (x, y)dy = 0
where f (x, y) = −M (x, y)/N (x, y). It is said to be an exact DE if M dx + N dy is an exact differ-
ential of some function say F (x, y), that is, M dx + N dy = dF .

For example, ydx + xdy = 0 is an exact DE since ydx + xdy = d(xy).

The following theorem provides the necessary and sufficient condition for a DE to be exact.

Necessary and sufficient condition for exact DE: If M (x, y) and N (x, y) possess continuous
first order partial derivatives, then the DE M (x, y)dx + N (x, y)dy = 0 is exact if and only if
∂M
∂y
= ∂N
∂x
.
Proof. First assume that the DE M (x, y)dx + N (x, y)dy = 0 is exact. Then by definition, there
exists some function F (x, y) such that

M dx + N dy = dF. (2.4)

Also F (x, y) is a function of x and y. So from the theory of partial differentiation, we have

∂F ∂F
dx + dy = dF. (2.5)
∂x ∂y

From (2.4) and (2.5), we obtain

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

∂M ∂ 2F ∂N ∂ 2F
=⇒ = , = . (2.7)
∂y ∂y∂x ∂x ∂x∂y

5
Given that M (x, y) and N (x, y) possess continuous first order partial derivatives. Therefore,
∂2F ∂2F ∂2F ∂2F
∂y∂x
and ∂x∂y are continuous functions, which in turn implies that ∂y∂x = ∂x∂y . Hence, (2.7) gives

∂M ∂N
= . (2.8)
∂y ∂x
Conversely assume that the condition (2.8) is satisfied. We shall prove that there exists a
function F (x, y) such that equation (2.4) and hence (2.6) are satisfied. Integrating first of the
equations in (2.6) w.r.t. x, we get
Z
F = M dx + g(y). (2.9)

Z
∂F ∂
=⇒ = M dx + g 0 (y).
∂y ∂y

Z

=⇒ N= M dx + g 0 (y).
∂y

Z  Z 

=⇒ g(y) = N− M dx dy. (2.10)
∂y

Z

=⇒ The integrand N − M dx is a function of y only.
∂y

 Z 
∂ ∂
=⇒ N− M dx = 0.
∂x ∂y

∂2
Z
∂N
=⇒ − M dx = 0.
∂x ∂x∂y

 Z 
∂N ∂ ∂
=⇒ − M dx = 0.
∂x ∂y ∂x

∂N ∂M
=⇒ − = 0,
∂x ∂y
which is true in view of (2.8). This completes the proof.

Note. If the DE M dx + N dy = 0 is exact, then in view of (2.9) and (2.10) the solution F (x, y) = c
reads as
Z Z  Z 

M dx + N− M dx dy = c.
∂y

6
Ex. Test the equation ey dx + (xey + 2y)dy = 0 for exactness and solve it if it is exact.
Sol. Comparing the given equation with M dx + N dy = 0, we get

M = ey , N = xey + 2y.

∂M ∂N
=⇒ = ey = .
∂y ∂x
This shows that the given DE is exact, and therefore its solution is given by
Z Z  Z 

M dx + N− M dx dy = c.
∂y

Z Z  Z 
y y ∂ y
=⇒ e dx + xe + 2y − e dx dy = c.
∂y

Z  
y y ∂ y
=⇒ xe + xe + 2y − (xe ) dy = c.
∂y

Z
y
=⇒ xe + (xey + 2y − xey ) dy = c.

=⇒ xey + y 2 = c.

2.4 Integrating Factor


If the DE M dx + N dy = 0 is not exact and suppose there exists a function µ(x, y) such that
the DE µ(M dx + N dy) = 0 is exact, then µ(x, y) is called an integrating factor (IF) of the DE
M dx + N dy = 0.

Obviously, we need to determine the integrating factor for a non-exact DE.

2.4.1 Existence and uniqueness of Integrating Factor


Existence of IF is ensured provided there exists general solution of the DE M dx + N dy = 0. For,
let the general solution of M dx + N dy = 0 be f (x, y) = c. Then ∂f
∂x
dx + ∂f
∂y
dy = 0. Its comparison
with M dx + N dy = 0 gives
∂f ∂f
∂x ∂y
= = µ(x, y) (say).
M N
Therefore, µM = ∂f
∂x
and µM = ∂f
∂y
. So µM dx + µN dy = ∂f
∂x
dx + ∂f
∂y
dy = df . It implies that
µM dx + µN dy = 0 is exact.

7
Next, assume that µ is IF and f (x, y) = c be general solution of the DE M dx + N dy = 0. Let
F be any function of f , then µF (f ) is also an IF of M dx + N dy = 0. For
Z 
µF (f )(M dx + N dy) = F (f )df = d F (f )df .

This shows that IF of a DE, if exists, is not unique.


Now we determine the IF µ(x, y). Since µM dx + µN dy = 0 is an exact DE, so by the condition
of exactness
∂ ∂
(µM ) = (µN ).
∂y ∂x

∂M ∂µ ∂N ∂µ
=⇒ µ +M =µ +N .
∂y ∂y ∂x ∂x

 
1 ∂µ ∂µ ∂M ∂N
=⇒ N −M = − . (2.11)
µ ∂x ∂y ∂y ∂x
We can not determine µ in general from (2.11). If µ happens to be a function of x only, then
(2.11) reduces to
 
1 dµ 1 ∂M ∂N
= − = h(x) (say).
µ dx N ∂y ∂x


=⇒ = h(x)dx.
µ

R
h(x)dx
=⇒ µ=e .
  R
1 ∂M ∂N
Thus, if N ∂y
− ∂x
= h(x) is a function of x only, then the IF µ = e h(x)dx .
  R
1 ∂N
Similarly, if M ∂x
− ∂M
∂y
= h(y) is a function of y only, then the IF µ = e h(y)dy
.

Ex. Solve (x2 + y 2 + x)dx + xydy = 0.

Sol. 3x4 + 4x3 + 6x2 y 2 = c.

2.4.2 IF of first order linear DE


A linear DE (LDE) of first order is of the from

y 0 + p(x)y = q(x), (2.12)

which can be written in the canonical form

(p(x)y − q(x))dx + dy = 0.

8
 with M dx + N dy = 0 gives M = p(x)y − q(x) and N R= 1. Here, we find that
Itscomparison
1 ∂M ∂N
N ∂y
− ∂x = p(x) is a function of x only. Therefore, the IF is µ = e p(x)dx . Now multiplying
both sides of (2.12) by the IF, we obtain
R R R
y0e p(x)dx
+ p(x)ye p(x)dx
= q(x)e p(x)dx
.

d  R p(x)dx  R
=⇒ ye = q(x)e p(x)dx .
dx

R
Z R
p(x)dx p(x)dx
=⇒ ye = q(x)e dx + c

is the general solution of the LDE.

Ex. Solve sec x y 0 = y + sin x.


Sol. y = −(1 + sin x)e− sin x + c.

2.4.3 Bernoulli’s DE
A non-linear DE of the form y 0 + p(x)y = q(x)y n (n 6= 1) is called Bernoulli’s DE, which can be
reduced to LDE by dividing it by y n and then substituting y 1−n = z.

Ex. Solve y 0 + xy = x3 y 3 .
2
Sol. y −2 = 1 + x2 + cex .

2.4.4 IF of homogeneous DE
If M (x, y)dx+N (x, y)dy = 0 is a homogeneous DE, then its IF is 1/(M x+N y) provided M x+N y 6=
0. In case, M x + N y = 0, the IF is 1/x2 or 1/y 2 or 1/(xy).

2.5 Clairaut’s DE
A Clairaut’s DE is of the form

y = xy 0 + f (y 0 ), (2.13)

where f is any function of y 0 . Separating x from this equation, we get

y f (p)
x= − , (p = y 0 ). (2.14)
p p
Differentiating with respect to y, we get

1 1 y dp f (p) dp f 0 (p) dp
= − 2 + 2 − . (2.15)
p p p dy p dy p dy

9
or
dp
[y − f (p) + pf 0 (p)] = 0. (2.16)
dy
dp
It suggests that either dy = 0 or y = f (p) − pf 0 (p).
dp
If = 0, then p = c (a constant) and we get the general solution of (2.13) given by
dy

y = cx + f (c).

In case, y = f (p) − pf 0 (p), from equation (2.13), we get x = −f 0 (p).

So the parametric equations x = −f 0 (t) and y = f (t) − tf 0 (t) define another solution of (2.13).
It is called singular solution of (2.13).
It should be noted that the straight lines given by the general solution y = cx + f (c) are
tangential to the curve given by the singular solution x = −f 0 (t) and y = f (t) − tf 0 (t). Hence, the
singular solution is an envelope of the family of straight lines of general solution as illustrated in
the following example.

Note: In general, a given DE need not to possess a solution. For example, |y0 | + |y| + 1 = 0 has
no solution. The DE |y 0 | + |y| = 0 has only one solution y = 0.

2.6 Existence and uniqueness of solution of IVP


In this section, we discuss some theorems which guarantee the existence/uniqueness of solution of
the IVP y 0 = f (x, y), y(x0 ) = y0 .

Existence Theorem: Let f (x, y) be continuous in a closed rectangular region R = {(x, y) :


|x − x0 | ≤ a, |y − y0 | ≤ b}, and there exists some constant M > 0 such that |f (x, y)| ≤ M for
all (x, y) ∈ R. Then there exists a solution of the IVP y 0 = f (x, y), y(x0 ) = y0 in the interval
[x0 − h, x0 + h], where h = min{a, b/M }.
The above theorem suggests that through any given point (x0 , y0 ) of a closed rectangular region
R, there passes at least one solution curve of the DE y 0 = f (x, y) provided f (x, y) is continuous
and bounded in R. Also note that this theorem gives the sufficient conditions for the existence
of solution but not the necessary. For example, consider the IVP xy 0 = 3y, y(1) = 1 and the
rectangular region R = {(x, y) : |x| ≤ 2, |y| ≤ 3}. For the given IVP, we have f (x, y) = 3y/x,
which is not continuous in R as it is not continuous at the point (0, 0) in R. However, y = x3 is a
solution of the given IVP.

Uniqueness Theorem: Let f (x, y) be continuous in a closed rectangular region R = {(x, y) :


|x − x0 | ≤ a, |y − y0 | ≤ b}, and there exists some constant M > 0 such that |f (x, y)| ≤ M for all
(x, y) ∈ R. Suppose f (x, y) satisfies the Lipshitz condition in R with respect to y, that is, there
exists a constant L such that |f (x, y1 ) − f (x, y2 )| ≤ L|y1 − y2 | for all (x, y1 ), (x, y2 ) ∈ R. Then
there exists a unique solution of the IVP y 0 = f (x, y), y(x0 ) = y0 in the interval [x0 − h, x0 + h],
where h = min{a, b/M }.

10
∂f
Picard’s Theorem: Let f (x, y) and ∂y
be continuous in a closed rectangular region R. If
(x0 , y0 ) is any point in R, then there exists some constant h > 0 such that the IVP y 0 = f (x, y),
y(x0 ) = y0 has a unique solution in the interval [x0 − h, x0 + h].

11
2.7 Analytical and Numerical Solutions of a First Order
LDE in Python
A LDE can be solved symbolically using sympy package in python. Let us solve the LDE y 0 −y = 0
with the initial conditions y(0) = 1.

Copy and paste the following program in a Jupyter Notebook cell of python in your system.
Alternatively, you can do it on the online Jupyter Notebook available at https://jupyter.org/try.
Try Classic Notebook at this link, insert a new cell there, and copy-paste the program given below.

%matplotlib inline
import sympy as sy
sy.init_printing() # for LaTeX formatted output
from IPython.display import display
x = sy.symbols(’x’); y = sy.symbols(’y’, cls=sy.Function)
#Enter the differential equation (DE): y-y=0
a1=1;a0=-1;r=0
DE = sy.Eq(a1*y(x).diff(x) + a0*y(x), r)
# Print the DE
display(DE)
# Solve the DE
sol = sy.dsolve(DE,y(x))
# Print the solution
display(sol)
# Solving C1 from the intial conditions y(0)=1
constants = sy.solve([sol.rhs.subs(x,0) - 1])
display(constants)
# Final solution
C1 = sy.symbols(’C1’)
fsol = sol.subs(constants)
display(fsol)

Retype the inverted commas over x, y and C1. Then run the program. It displays the following
output:
d
−y(x) + y(x) = 0
dx
y(x) = C1 ex

{C1 : 1}

y(x) = ex

This is great! Now you can solve the DE: a1y 0 + a0y = r. Just you need to supply the coef-
ficients a1, a0 and the right hand side function r in the above program. Also, supply the initial
condition, if a particular solution is required from the general solution.

12
Now let us do the numerical solution of the above differential equation for which the python
program is as follows:

%matplotlib inline
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
def dydx(y, x):
# Consider the DE y’=- (a0/a1)*y + r/a1
a1=1;a0=-1;r=0
return -(a0/a1)*y + r/a1
x = np.linspace(0, 2, 200)
w = odeint(dydx, [1], x) # Here [1] stands for the IC [y(0)]=[1]
y = w[:,0] # y’ = w[:,0]
# plot results
plt.plot(x,y,’b--’,label=’Numerical’)
plt.plot(x,np.exp(x),’g’,label=’Exact’)
plt.legend(loc="best")
plt.xlabel(’$x$’)
plt.ylabel(’$y(x)$’)
plt.show()

Take care of the inverted commas at different places after copy-pasting the above program
in Jupyter Notebook. Then run the program. The numerical solution as well as the analytical
solution are shown for the range x ∈ [0, 2] in the following figure, which is the output of the above
program. We see that both the solution curves overlap each other, as expected. We look for
numerical solution of the DE where the exact or analytical solution is not available.

Numerical
7 Exact
6
5
y(x)

4
3
2
1
0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00
x

13

You might also like