Lecture 3: First-order ODEs 2
Dr. D. Turton
MATH2038 PDEs
Semester 2
D. Turton Lecture 3 MATH2038 1 / 19
Outline
1 Review
2 First order ODEs, continued
Linear first-order ODEs
Exact ODEs
D. Turton Lecture 3 MATH2038 2 / 19
Review
When trying to solve first order ODEs it is best to see if they fit in
certain simple types:
1 Direct integration
Z
ẏ (t) = f (t) ⇒ y (t) = f (t)dt
2 Separable
Z Z
dy f (y ) dy dx
= ⇒ =
dx g(x) f (y ) g(x)
3 Homogeneous first-order
dy y
=g .
dx x
Change the dependent variable from y (x) to z(x) = y (x)/x ,
to reduce it to a separable ODE.
D. Turton Lecture 3 MATH2038 4 / 19
Linear ODEs
Linear: a first-order ODE
F (x, y , y ′ ) = 0
is linear if F is a linear function of y and y ′ .
(So y and y ′ appear only with power 1; there are no terms
such as y 2 or y y ′ etc).
D. Turton Lecture 3 MATH2038 6 / 19
Linear ODEs
A general class of linear first-order ODE can be written as
dy
+ p(x) y = r (x),
dx
where p(x), r (x) are functions of x.
(We will always assume p(x), r (x) are continuous).
[Side note: we could have started with
dy
q(x) + p̃(x) y = r̃ (x),
dx
but we will assume that q(x) has no zeroes, and divide through by
q(x) to obtain the form in the first equation above.]
D. Turton Lecture 3 MATH2038 7 / 19
Linear ODEs
Similarly, a general class of linear second order ODEs can be
written
y ′′ + p(x)y ′ + q(x)y = r (x),
for any (continuous) functions p(x), q(x), r (x).
D. Turton Lecture 3 MATH2038 8 / 19
Two meanings of homogeneous
An ODE can be homogeneous in two completely different respects:
Homogeneous first-order: see Lecture 2,
dy y
=g .
dx x
Homogeneous linear: A linear ODE with no terms
solely in terms of the independent variable: r (x) = 0.
These concepts are distinct.
We will mostly use the term homogeneous linear only for second-order
(and higher-order) ODEs, since homogeneous linear first-order ODEs
are separable.
[The reason that these two distinct types of ODE are both described as
homogeneous is that they are both related to homogeneous functions.]
D. Turton Lecture 3 MATH2038 9 / 19
Linear equations: method
dy
+ p(x)y = r (x)
dx
Such ODEs can be solved using an integrating factor.
Let P(x) be an antiderivative of p(x), i.e.
Zx
′
P (x) = p(x) or P(x) = p(s)ds .
For the following method any antiderivative will work,
so we don’t need to add a constant to P(x)
(and it is usually simpler not to, as we will see in examples).
The integrating factor is
eP(x)
and we multiply the ODE by this factor to simplify it.
D. Turton Lecture 3 MATH2038 10 / 19
Linear equations: method
Multiply ODE by integrating factor eP(x) , where P ′ (x) = p(x).
P(x) dy
e + p(x)y = eP(x) r (x),
dx
Left hand side is a total derivative:
d h i
y (x)eP(x) = eP(x) r (x)
dx
Integrate both sides with respect to x (include constant here):
Z
P(x)
y (x)e = eP(x) r (x)dx + C
General solution:
Z
y (x) = e−P(x) eP(x) r (x)dx + C .
D. Turton Lecture 3 MATH2038 11 / 19
Linear equations: example
Consider the ODE
dy
− y = e2x .
dx
1 This is a linear ODE with p(x) = −1, r (x) = e2x .
2 We first find the integrating factor:
Z
P(x) = p(x)dx = −x ⇒ eP(x) = e−x .
Note that we did not include a constant of integration in P(x).
3 We multiply the ODE by e−x and solve:
′
e−x y ′ − y = ex y e−x = ex
⇒
⇒ y e−x = ex + C
⇒ y (x) = e2x + C ex .
Note: to ensure this works, we must first ensure that y ′ term has
coefficient 1. Divide through if necessary.
D. Turton Lecture 3 MATH2038 12 / 19
Exact equations
The last type of first-order ODE that we’ll study is exact equations.
Let us consider a first-order ODE given to us in the form
dy M(x, y )
=− ,
dx N(x, y )
or, rearranging,
dy
M(x, y ) + N(x, y )= 0.
dx
Suppose that we can find a function u(x, y ) such that
∂u ∂u
= M(x, y ), = N(x, y ) .
∂x ∂y
Then our ODE is called exact and becomes
∂u ∂u dy
+ = 0.
∂x ∂y dx
D. Turton Lecture 3 MATH2038 13 / 19
Exact equations: method
Recalling the chain rule from multivariable calculus,
and using the fact that y is a function of x, we see that
du ∂u ∂u dy
x, y (x) = + .
dx ∂x ∂y dx
So our ODE can be written as
∂u ∂u dy du
+ =0 ⇒ (x, y ) = 0 ,
∂x ∂y dx dx
whose general solution is
u(x, y ) = const.
This is an implicit solution to the ODE, as it gives y implicitly in
terms of x (and it is a solution since we have removed y ′ ).
D. Turton Lecture 3 MATH2038 14 / 19
Exact equations: method
How do we know if a first-order ODE is exact?
There is a simple test.
A necessary and sufficient condition for the function u(x, y ) to
exist is:
∂M ∂N
(x, y ) = (x, y ). (1)
∂y ∂x
∂u ∂u
Necessary: If u(x, y ) exists such that ∂x = M, ∂y = N, then
∂M ∂2u ∂N ∂2u ∂2u
= , = = ,
∂y ∂y ∂x ∂x ∂x∂y ∂y ∂x
where in the last step we used the fact that partial derivatives
commute. This implies Eq. (1).
Sufficient: given Eq. (1), we next give a constructive method to
find u(x, y ).
D. Turton Lecture 3 MATH2038 15 / 19
Exact equations: example
Example: Consider the ODE
dy dy 2x + ey
xey + 2x + ey = 0 ⇒ =−
dx dx xey
This ODE is neither separable, linear nor homogeneous first-order.
So let us investigate whether it is exact.
We have
M(x, y ) = 2x + ey , N(x, y ) = xey
Then
∂M ∂N
(x, y ) = ey , (x, y ) = ey ,
∂y ∂x
and so the equation is exact.
It follows that there exists a function u(x, y ) such that
∂u ∂u
= 2x + ey , = xey .
∂x ∂y
We next construct the function u(x, y ).
D. Turton Lecture 3 MATH2038 16 / 19
Exact equations: example
Integrating the first equation, we obtain
∂u
= 2x + ey ⇒ u(x, y ) = x 2 + xey + c(y ) .
∂x
Since we are integrating an equation for ∂u ∂x , we must add an
integration “constant” c(y ) that is a function of y , i.e. it is
“constant” with respect to x only.
We next differentiate this result with respect to y , obtaining
∂u dc(y )
= xey + .
∂y dy
∂u
Comparing with the second equation, ∂y = xey , we see that
dc(y )
=0 ⇒ c = constant .
dy
Thus u(x, y ) = x 2 + xey + c and so the general solution is
C − x2
2 y
x + xe = C ⇒ y (x) = ln .
x
D. Turton Lecture 3 MATH2038 17 / 19
Next Steps (but Recap slide still to come)
The next steps for you to follow are:
Attempt Problem Sheet 1, all questions (especially core questions)
Attend Problem Class 1 (Integration methods & STACK Quizzes).
D. Turton Lecture 3 MATH2038 18 / 19
Summary
First-order ODEs: Direct integration, Separable, Homogeneous, and:
4 Linear
dy
+ p(x)y = r (x) .
dx
Find P(x) such that P ′ (x) = p(x).
Multiply with integrating factor eP(x) and integrate.
5 Exact
dy M(x, y ) dy
=− or M(x, y ) + N(x, y ) = 0,
dx N(x, y ) dx
∂M ∂N
(x, y ) = (x, y ).
∂y ∂x
The solution is u(x, y ) = constant, where u(x, y ) is obtained by
solving
∂u ∂u
= M(x, y ), = N(x, y ).
∂x ∂y
D. Turton Lecture 3 MATH2038 19 / 19