Chapters 1 and 2 1 Introduction

advertisement
Chapters 1 and 2
1
Introduction
Reading assignment: Study Sections 1.1 and 1.2. (If you have time it might be good
to read Section 1.3 to get an understanding of modeling applications of Ordinary
Differential Equations)
An Ordinary Differential Equation (ODE) is a relation between an independent variable
x and and a dependent variable y (i.e., y = y(x) depends on x) and its derivatives y (j) =
dj y
for j = 1, · · · , n. So it is an equation that can be written in the form
dxj
F (x, y, y (1) , · · · , y (n) ) = 0,
(1)
For example, in this chapter we will learn to solve equations like the following:
x−y
y 0 − x cos(x2 ) = 0, y 0 − sin(x + y) = 0, y 0 − 2xy − x = 0, and y 0 =
.
x+y
There are other types of differential equations most notably partial differential equations (PDEs). It is easy to distinguish an ODE from a PDE. An Ode always has a single
independent variable while a PDE always has more that one independent variable and
the equation involves partial derivatives. For example consider a PDE with independent
variables x and y and dependent variable z so that z depends on x and y, i.e., z = z(x, y).
Then a general second order PDE would be an equation of the form
∂z ∂z ∂ 2 z ∂ 2 z ∂ 2 z
F x, x, z,
, ,
,
,
= 0.
∂x ∂y ∂x2 ∂y 2 ∂x∂y
We study differential equations because many practical physical systems are govern
(or described by) either ordinary or partial differential equations. Solving ODEs for explicit
solutions can be very difficult or even impossible. But in this class we will focus on the
solution of simple problems in order to give students some idea of what is involved in the
more general case. The main tools needed by the students is a background in college
algebra and calculus (differentiation and integration).
1
The goal in “solving” an equation is to find all functions y(x) satisfying the equation (1).
Unfortunately this objective is beyond reach other than some very special cases. In this
class we will eventually study a few of these special cases.
Notation and Terminology: The following discussion may seem a bit over the top. The
main purpose is to introduce the standard notation and terminology used in talking about
ODEs. DO NOT BE OVERWHELMED they are just words. Also read the book where
more examples are also given. The main words to understand are written in italics and
underlined.
Definition 1.1.
1. The order of the highest order derivative, n in (1), is called the order
of the equation.
2. If we can solve for the highest order derivative term, then we say the equation can
be put in normal form:
dn y
= f (x, y, y (1) , · · · , y (n−1) ).
dxn
3. An ODE is said to be Linear if it can be written in the form
an (x)
dn y
d1 y
dn−1 y
+
a
+
·
·
·
+
a
(x)
+ a0 (x)y(x) = g(x).
n−1
1
dxn
dxn−1
dx1
(2)
Similarly a linear PDE in two independent variables is
a2,0 (x, y)
∂ 2z
∂ 2z
∂z
∂z
∂ 2z
+
a
(x,
y)
+
a
(x,
y)
+ a1,0 (x, y)
+ a0,1 (x, y) + a0,0 z = 0.
0,2
1,1
2
2
∂x
∂y
∂x∂y
∂x
∂y
(a) A linear equation is is said to be homogeneous if g(x) = 0. If g(x) 6= 0 then the
equation is called non-homogeneous.
(b) A solution y(x) may only exist on a certain domain called the interval of existence.
The interval of existence may be open, e.g., (a, b), closed, e.g., [a, b] or it may
be open on one end and closed on the other, e.g., (a, b]. It is possible that this
interval is all of (−∞, ∞).
(c) Here are some examples
2
· (1 + x)y 00 − cos(x2 )y 0 + ex y = cos(x) (second order, linear)
· (1 + y 2 )y 000 − x sin(y + y 0 ) = 0 (third order, nonlinear)
· y 0 − 2xy − y 2 = 0 (first order, nonlinear)
x−y
(first order, nonlinear)
· (y 0 )2 =
x+y
· x3 y 000 − x2 y 00 + 2xy 0 − y = 0 (third order, linear)
4. Sometimes it is possible that y = 0 is a solution. In this case we call this the
trivial solution.
5. If we have a solution given in the form y = y(x) then we say that y(x) is an
explicit solution. But very often it is either difficult or even impossible to obtain an
explicit solution even if we know that it exists. In this case we may still be able to find
a so-called implicit solution. We define an implicit solution as follows:
A relation G(x, y) = 0 is called an implicit solution of the ODE (1) if there exists
a function ϕ(x) (whether we can find it or not) so that G(x, ϕ(x)) = 0 and also
F (x, ϕ(x), ϕ(1) (x), · · · , ϕ(n) (x)) = 0
6. Generally speaking an nth order ODE has an n-parameter family of solutions. That
is to say that the solution depends on n arbitrary constants (constants of integration). Thus we would write an implicit solution as G(x, y, c1 , c2 , · · · , cn ) = 0 where
c1 , c2 , · · · , cn are arbitrary parameters. If we can find an implicit or explicit solution
containing n arbitrary parameters then we call the solution the general solution. For
example, a general explicit solution of y (3) = 0 is y = c1 + c2 x + c3 x2 .
7. The Initial Value Problem (IVP) is to find a unique solution of (1) satisfying the n
constraints (called initial conditions)
y(x0 ) = y1 , y 0 (x0 ) = y2 , · · · , y (n−1) (x0 ) = yn .
(3)
Remark 1.1. In order to solve the IVP generally we find a general solution which depends
on n parameters c1 , c2 , · · · , cn . We then apply the n constraints (3) to obtain a system of
n equations in n unknowns to evaluate the constants cj , j = 1, · · · , n and thus to obtain a
unique solution.
3
Example 1.1. As a glimpse ahead, consider the problem of finding all solutions in the
form y = emx of y 00 − 3y 0 + 2y = 0.
Substituting y = emx , y 0 = memx and y 00 = m2 emx into the equation we have
m2 emx − 3memx + 2emx = 0 ⇒ m2 − 3m + 2 = 0.
We can easily solve this quadratic equation to obtain m = 1, m = 2. So we have solutions y = ex and y = e2x .
We claim that y = c1 ex + c2 e2x is a general solution.
In order to be a general solution we also need to show that ex and e2x are linearly
independent. This will be done in chapter 3.
Let us finish these notes on Chapter 1 by solving an IVP for this example
y 00 − 3y 0 + 2y = 0 with y(0) = 0 and y 0 (0) = 1 .
We have y 0 (x) = c1 ex + 2c2 e2x and y 00 (x) = c1 ex + 4c2 e2x .
Substituting these into the equation to get
y 00 − 3y 0 + 2y = c1 (1 − 3 + 2)ex + c2 (4 − 6 + 2)e2x = 0
Substituting x =0 and y(0) = 0 and y 0 (0) = 1 we have 0 = y(0) = c1 + c2 and 1 = y 0 (0) = c1 + 2c2
 c +c =0
1
2
So we have
⇒ c1 = −1 c2 = 1
 c + 2c = 1
1
2
We have the unique solution y(x) = e2x − ex
Example 1.2. The general solution to the nonautonomous differential equation y 0 = 3x2
is y(x) = x3 + c where c (just integrate both sides) is an arbitrary constant. The unique
solution satisfying the initial condition y(2) = −1 is y(x) = x3 − 9.
2
First Order Equations and IVPs
Reading assignment: Your need to study Chapter 2, Sections 2.1 through 2.5.
4
In this section we will consider first order equations and, for the most part, we are
interested in those equations that can be put in the normal form
y 0 = f (x, y)
(4)
and the associated IVP
y 0 = f (x, y),
(5)
y(x0 ) = y0 .
Theorem 2.1 (Fundamental Existence Uniqueness Theorem). Let R be a rectangular
region R = {(x, y) : a ≤ x ≤ b, c ≤ y ≤ d} that contains the point (x0 , y0 ) in its interior. If
f (x, y) and ∂f /∂y are continuous in R, then there exists an interval I0 = (x0 − h, x + h) ⊂
(a, b) for a number h > 0, and a unique function y = ϕ(x) defined on I0 that solves the IVP
(5) on I0 .
d
R
(x0 , y0 )
y = ϕ(x)
y0
c
a
x0
I0
b
As an example let us consider the IVP y 0 = −y 2 , y(0) = 1. Here f (x, y) = −y 2 ,
fy (x, y) = −2y are both continuous functions everywhere in R2 = {(x, y) : x, y ∈ R}.
Therefore Theorem 2.2 implies that the IVP has a unique solution. Indeed, the general
solution to the ODE is y = (c + x)−1 where c is an arbitrary constant. Then the unique
solution to the IVP is y = (1 + x)−1 . Notice that this solution exists for all x > −1. But it
does not exist at x = −1.
Theorem 2.2 (Fundamental Existence Uniqueness Theorem First Order Linear). Con5
sider the first order linear IVP
a1 (x)y 0 + a0 (x)y = g(x),
(6)
y(x0 ) = y0 ,
on an interval I = (a, b) = {x : a < x < b} with x0 ∈ I. If the functions a1 (x), a0 (x) and
g(x) are all continuous on I and a1 (x) 6= 0 on all of I, then (6) has a unique soltuion that
exists on the whole interval I.
Here is an example
Example 2.1. Consider the first order linear IVP
(x2 − 9)y 0 + x cos(x)y =
x+1
with y(1) = 5.
x
x+1
. The functions a1 and
x
a0 are continuous on the whole real line but g(x) has a discontinuity at x = 0. Also the
In this case a1 (x) = (x2 − 9), a0 (x) = x cos(x) and g(x) =
leading coefficient a1 (x) = 0 at both x = ±3. The number line is then broken into 4 parts:
−∞ < x < −3, −3 < x < 0, 0 < x < 3 , and 3 < x < ∞. Since the initial point x0 = 1 we
see that the solution is guaranteed to exist on the interval 0 < x < 3.
−3
2.1
0
3
Autonomous Equations
The first order autonomous equations y 0 = f (y) are particularly interesting and the behavior of solutions can be described rather nicely even without solving the equation.
Autonomous Equations
In contrast to the general case above for which it can be very difficult to find explicit
solutions, there is a class of problems for which it is possible to obtain a somewhat more
detailed description of the behavior of the solutions without actually finding the solution.
The problems I am talking about are the first order autonomous equations y 0 = f (y)
(notice the independent variable x does not appear on the right hand side) which are
6
particularly interesting and the behavior of solutions can be described rather nicely even
without solving the equation.
In particular, it is possible to visualize the qualitative properties of the solution using the
so called Phase Line which consists of a one dimensional plot of the critical points (also
called the equilibria points or nodes) together with arrows depicting whether a solution is
increasing or decreasing.
Notice that an autonomous equation is always separable since we can write
Z
dy
=
f (y)
Z
dx + C
but the integral on the left hand side may be quite difficult to evaluate.
We begin our analysis by looking for solutions of the equation that are very simple.
Namely we look for what are called equilibrium solutions which are solutions that don’t
depend on the independent variable, in other words they are constants. If a solution is a
constant then it is of the form y(x) = y0 where y0 is a real number. But then we see that
y 0 (x) = 0 for all x so the left side of the equation is zero, which in turn means the right
hand side must be zero. In other words we need f (y0 ) = 0. These real numbers are the
equilibrium points (also called fixed point, critical points or nodes).
So a fixed point (or equilibrium point) of a differential equation y 0 = f (y) is a root of
the equation f (y) = 0. Notice that an equilibrium point gives a solution to the differential
equation – it is a constant solution. In particular, suppose that y0 is an equilibrium point,
i.e., f (y0 ) = 0, then set y(x) = y0 for all x (a constant function). Since y(x) is a constant its
derivative is zero and y0 is an equilibrium point we have y 0 = f (y). Qualitative information
about the equilibrium points of the differential equation y 0 = f (y) can be obtained from
special diagrams called phase diagrams.
A phase line diagram for the autonomous equation y 0 = f (y) is a line segment with
labels for all the nodes, i.e., one for each root of f (y) = 0, i.e. each equilibrium.
We can classify the possible behavior of a solution that begins in between two nodes
according to a simple classification of the three types of nodes: Asymptotically Stable
(AS), Unstable (US) or Semi-Stable (SS).
7
1. An equilibrium y0 is called Asymptotically Stable if solutions that begin near y0 at
x = 0 approach y0 as x → ∞. Such an equilibrium is also called a sink because it
x→∞
attracts nearby solutions, i.e., if y(0) is close to y1 , then |y(x) − y0 | −−−→ 0. In other
words y(x) moves toward y1 .
2. An equilibrium y1 is called Unstable if solutions that begin near y0 at x = 0 move
away from y0 as x → ∞. Such an equilibrium y1 is said to repel nearby solutions
and it is called a source, i.e., if y(0) is close to y1 , then |y(x) − y1 | increases as
x → ∞. In other words y(x) moves away from y1 .
3. An equilibrium y2 which is neither a sink or a source is called a Semi-Stable node.
In this case solutions that begin near y2 on one side (either greater than or less than
y2 ) will approach y2 on one side but move away on the other side.
Classification of Nodes
In order to determine where a node is AS, US or SS we only need to determine the
sign of f (y) for y near the node.
1. AS: In this case we must have f (y) > 0 for y < y0 and f (y) < 0 for y > y0 . Here
f (y) > 0 indicates that y 0 (x) = f (y(x)) > 0 which means that y(x) is increasing (or
moving to the right on the number line). And, y 0 (x) = f (y(x)) < 0 means that y(x) is
decreasing (or moving to the left on the number line).
2. US: In this case we must have f (y) < 0 for y < y1 and f (y) > 0 for y > y1 .
3. SS: In this case there are two possibilities: we could have f (y) < 0 for y < y2 and
f (y) < 0 for y > y2 . Or we could have, f (y) > 0 for y < y2 and f (y) > 0 for y > y2 . In
other words the sign of f (y) is the same on both sides of y2 .
8
Phase Line
Let us consider an example given by
y 0 = y(y + 1)(y − 2)2 (y + 3)3 (y − 4)2 .
So we have f (y) = y(y + 1)(y − 2)2 (y + 3)3 (y − 4) which has critical points y =
−3, −1, 0, 2, 4 and we want to classify each of the nodes. So we draw a phase line on
which we plot all these critical points and indicate, using a simple sketch with + and −
signs of where f (y) is positive and negative.
Phase Line for the example
Examples of Autonomous Equations
In these examples we consider an autonomous equation in the form y 0 = f (y) where
y is a function of the independent variable x. Note that the independent variable could be
anything. for example, it could be t. Also the dependent variable could be anything, for
example it could be x. So the equation could read x0 = f (x). In our examples we will stick
with the examples as they are in the book and use y = y(x).
1. Given the equation y 0 = y 2 − 3y we have f (y) = y 2 − 3y = 0 implies that y = 0, 3
So we see that y = 0 is an Asymptotically Stable node (sink) and y = 3 is an
Unstable node (source).
2. Given the equation y 0 = y 2 − y 3 we have f (y) = y 2 − y 3 = y 2 (1 − y) = 0 implies that
y = 0, 1
9
So we see that y = 0 is a Semi-Stable node and y = 1 is an Asymptotically Stable
node (sink).
Direction Fields for General First Order Equations
Returning to general first order equations we briefly discuss the idea of using the
notion of derivative of a function as a tool to guess the shape of the solution to a first
order equation
y 0 = f (x, y).
Note that if ϕ is a solution of this equation satisfying ϕ(x) = y then the slope of the tangent
line to the graph of y = ϕ(x) at (x, ϕ(x)) is given by f (x, ϕ(x)) because y 0 (x) = f (x, ϕ(x))
and from what you learned in Calculus 1, ϕ0 (x) is the slope of the tangent line. Since we
can compute f (x, y) at every point we can plot the direction a solution will take starting
from any given point. The Direction Field for a first order ODE (4) is a figure in which
arrows are placed at a grid of points in the xy-plane with an arrow at each point (x, y) of
the grid pointing in the direction f (x, y). By starting at a point (x0 , y0 ) one can move in the
directions of the arrows to get an idea what the solution of the IVP looks like.
Let us consider an example to demonstrate the idea.
y 0 = y 2 − x.
10
For this example we plot the solution satisfying y(0) = 0.
Notice that the above example is non-autonomous, i.e., f depends on x and y. As
we have already mentioned, things are simpler for autonomous equations. Consider the
example
y 0 = sin(y).
We notice that the function f (y) = sin(y) which does explicitly depend on x. The
equilibria (or stationary) solutions are given by
sin(y) = 0
⇒
y = kπ,
k = ±1, ±2, · · · .
For autonomous equations these solutions have very special properties. Generally,
11
solutions of the differential equation either approach of are repelled by the equilibrium
solutions.
Direction Field for y 0 = sin(y)
For this example we have plotted two solutions with initial conditions y(0) = 2 (Blue
curve) and y(0) = 5 (Green Curve), respectively. Notice that both solutions approach the
sink corresponding to the stationary solution y0 = π.
12
y0 = π is asymptotically stable
As we have already discussed in our discussion of autonomous equations, it useful to
look at the graph of f (y) to determine the direction of the arrows. What we gain from this
picture is that if a solution begins in a region in which f (y) is positive the y 0 = f (y) > 0 so
the function y(x) must be increasing. Notice that, other than nodes, solutions are trapped
between sources and sinks and these solutions move away from sources and toward
sinks.
+
2.2
+
-
+
-
+
-
+
+
Separable Equations
A very important class of problem (autonomous and nonautonomous) are ones that can
be “separated.” These are problems that can be written in the form
dy
= f (y)g(x).
dx
In this case we can rewrite the problem in the form
1 dy
= g(x)
f (y) dx
or
1 dy
= g(x).
f (y) dx
Integrating both sides we arrive at
Z
1 dy
dx =
f (y) dx
Z
13
g(x) dx + C
or
Z
Z
1
dy =
f (y)
g(x) dx + C
and we say the problem is solved “up to quadrature.” This simply means we must evaluate
the indefinite integrals.
This shows already how hard solving differential equations are since it is easy to write
down functions that cannot be integrated exactly in terms of elementary functions. For
example,
y 0 = e−x
2
has solution which can be expressed as
Z
x
2
e−s ds + C
y(x) =
0
but it is well known that this integral cannot be expressed “in closed form.”
In spite of this example, the simplest class of separable first order equations are ones
in the form y 0 = f (x) which can be written in the separated form dy = f (x) dx. Therefore
R
by the Fundamental Theorem of Calculus y = f (x) dx + C.
You will be required to make substitutions many times when doing integrals. Suppose,
R
for example, you want to integrate e3x dx then you need to use the substitution
u = 3x => du = 3dx
and the integral becomes
Z
1/3
eu du = 1/3eu + C = 1/3e3x + C.
More generally let us replace
R
e3x dx by
R
ekx dx and use the same type substitution
u = kx => du = kdx
14
so the integral becomes
Z
eu du = 1/keu + C = 1/kekx + C.
1/k
Now suppose you need to integrate
R
f (kx)dx and you know an antiderivative for f (x) is
F (x), i.e., F 0 (x) = f (x) then using the substitution u = kx would give
Z
f (kx)dx = 1/kF (kx) + C.
We will use this idea maybe even a hundred times this semester so I would learn it. Just
remember this simple fact and you won’t have to make all these trivial substitutions.
Example 2.2. Consider the differential equation y 0 = (x + 1) cos(x2 + 2x). We separate
the equation and integrate to find the solution.
dy = (x + 1) cos(x2 + 2x)dx
so that
Z
Z
dy =
(x + 1) cos(x2 + 2x)dx + C.
By the power rule the integral of dy is y so we have
Z
y=
(x + 1) cos(x2 + 2x)dx + C.
To carry out the integral on the right we need to use a simple substitution u = x2 + 2x
which implies du = 2(x + 1)dx and we have
Z
y=
1
(x + 1) cos(x + 2x)dx + C =
2
2
Z
1
cos(u) du + C = sin(x2 + 2x) + C.
2
Example 2.3. Consider the differential equation y 0 = xy 2 . We separate the dependent
15
and independent variables and integrate to find the solution.
dy
= xy 2
dx
y −2 dy = x dx
Z
Z
−2
y dy = x dx + c
x2
+c
2
1
y=− 2
x /2 + c
− y −1 =
Example 2.4. The equation y 0 = y − y 2 is separable and we find
dy
= dx
y − y2
On the left we expand in partial fractions and integrate.
Z 1
1
−
y y−1
Z
dy =
dx + c
ln |y| − ln |y − 1| = x + c
This is an implicit solution for y(x). We can solve for y(x) to obtain an explicit solution as
16
follows.
y =x+c
ln y − 1
y x+c
y − 1 = e
y
= ±ex+c
y−1
y
= c1 ex (Here we have substituted c1 for ±ec .)
y−1
−c1 ex
y=
c1 e x − 1
1
y=
(divided top and bottom by −c1 and ex .)
−x
1 + 1/(c1 )e
1
(finally we set C = 1/c1 .)
y=
1 + Ce−x
Here are a list of some separable equations with partial details.
Supplemental Separable Equations
1. y 0 =
1 − x2
⇒ y 2 dy = (1 − x2 )dx ⇒ y = (3x − x3 + k)1/3
y2
2. y 0 = 3yx2 ⇒
dy
3
= 2x2 dx ⇒ y = kex
y
1 − y2
2y
dx
3. xy =
⇒ 2
=−
⇒ y = ±(1 + kx−1 )1/2
2y
y −1
x
0
4. y 0 =
cos2 (y)x
1 + x2
⇒ sec2 (y)dy =
5. y 0 = 4x3 (1 − y), y(0) = 3
⇒
xdx
⇒ y = tan−1 (ln(1 + x2 )1/2 + k)
1 + x2
dy
4
4
= 4x3 dx ⇒ y = kex + 1, y = 2ex + 1
1−y
p
6. y 0 = 2 y + 1 cos(x), y(π) = 0 ⇒ 1/2(y + 1)−1/2 dy = cos(x)dx ⇒
(y + 1)1/2 = sin(x) + C ⇒ y = (sin(x) + k)2 − 1, y = sin2 (x) + 2 sin(x)
3x2 + 4x + 2
, y(0) = −1 ⇒ (2y + 1)dy = (3x2 + 4x + 2)dx ⇒ y 2 + y =
2y + 1
x3 + 2x2 + 2x + C, y 2 + y = x3 + 2x2 + 2x
7. y 0 =
8. y 0 = 2x sin2 (y), y(0) = π/4
⇒
csc2 (y)dy = 2xdx
cot−1 (1 − x2 )
17
⇒
− cot(y) = x2 + C, y =
√
3
dy
dx
⇒ p
= √
⇒
2
1 − x2
1 − y2
sin−1 (x) + C ⇒ y = sin(sin−1 (x) + C ⇒ y = sin(sin−1 (x) − π/3)
p
√
9. 1 − y 2 dx = 1 − x2 dy, y(0) =
10.
sin−1 (y) =
dx
dx
= 4(x2 + 1), x(π/4) = 1 ⇒
= 4dt ⇒ tan−1 (x) = 4t + C
2
dt
(x + 1)
⇒ x = tan(4t + C) ⇒ x = tan(4t − 3π/4)
dy
1−x
=
⇒ ln(|y|) = (−x−1 − ln(|x|)) + C ⇒
2
y
x
−1
e−(x +1)
⇒ y=
x
11. x2 y 0 = y − xy, y(−1) = −1 ⇒
−1
−y = e
2.3
−x−1 −ln(|x|)+C
kex
=
−x
First Order Linear Equations
A first order, linear, homogeneous equation has the form
dy
+ p(x)y = 0.
dx
Note that if we can find one solution, then any constant times that solution also satisfies
the equation. If fact, all the solutions of this equation differ only by multiplicative constants.
Notice that we can solve any equation of this type because it is separable.
dy
= −p(x) dx
y
Z
ln |y| = − p(x) dx + c
y = ±e−
y = ce−
R
R
p(x) dx+c
p(x) dx
(Here we have renamed the arbitrary constant ±ec to c).
18
First Order, Linear Homogeneous Differential Equations. We have just shown that the
first order, linear, homogeneous differential equation,
dy
+ p(x)y = 0,
dx
has the general solution
y = ce−
R
p(x) dx
.
(7)
Notice that solutions differ by multiplicative constants.
Example 2.5. Consider the equation
dy 1
+ y = 0.
dx x
We use Equation (7) to determine the solution.
y(x) = c e−
R
1/x dx
,
for x 6= 0
y(x) = c e− ln |x|
c
y(x) =
|x|
c
y(x) =
x
Here on the last step we use the fact that the constant c is arbitrary so if x is known to be
positive then |x| = x and if x is known to be positive then |x| = −x and we replace c by
−c.
General First Order, Linear Differential Equations.
The first order, linear, nonhomogeneous differential equation has the form
dy
+ p(x)y = f (x).
dx
(8)
This equation is not (in general) separable. To solve Equation (8), we multiply by an
integrating factor.
19
Multiplying a differential equation by its integrating factor has the effect of transforming
the left hand side of the equation into an exact derivative. By this we mean that multiplying
Equation (8) by the integrating factor, µ(x), yields,
µ(x)
dy
+ p(x)µ(x)y = f (x)µ(x).
dx
In order that µ(x) be an integrating factor, it must satisfy
dµ(x)
= p(x)µ(x).
dx
This is a first order, linear, homogeneous equation with the solution
R
p(x) dx
µ(x) = ce
.
This is an integrating factor for any constant c. For simplicity we will choose c = 1.
So to solve the equation (8) we multiply by the integrating factor and integrate. Let
R
P (x) = p(x) dx.
dy
+ p(x)eP (x) y = eP (x) f (x)
dx
dy P (x) e
y = eP (x) f (x)
dx Z
y = e−P (x) eP (x) f (x) dx + ce−P (x)
eP (x)
y ≡ yp + c yc
The general solution is the sum of a particular solution, yp , that satisfies y 0 + p(x)y = f (x),
and an arbitrary constant times a homogeneous solution, yc , that satisfies y 0 + p(x)y = 0.
We show that yp satisfies the non homogeneous problem
−P (x)
yp = e
Z
P (x)
e
20
f (x) dx
yp0
−P (x)
Z
= −pe
P (x)
e
f (x) dx + e−P (x) eP (x) f (x)
= −pyp + f (x),
and therefore
yp0 + yp = f (x).
Example 2.6. Consider the differential equation
1
y 0 + y = x2 ,
x
x > 0.
First we find the integrating factor.
Z
µ(x) = exp
1
dx
x
= eln x = x
We multiply by the integrating factor and integrate.
dy
(xy) = x3
dx
1
xy = x4 + c
4
1
c
y = x3 + .
4
x
The particular and homogeneous solutions are
1
yp = x3
4
and
yh =
1
.
x
Note that the general solution to the differential equation is a one-parameter family of
functions.
R
Example 2.7. y 0 + 3x2 y = x2 ⇒ µ = e
3x2 dx
3
= ex . Thus we have
h 3 i0
3
ex y = x2 ex
21
which implies
Z
x3
1 3
3
x2 ex dx + C = ex + C.
3
e y=
Therefore
y=
1
3
+ Ce−x .
3
1
Example 2.8. xy 0 − y = x2 sin(x) must be written as y 0 − y = x sin(x) from which we find
x
R
µ = e− dx/x = e− ln(x) = x−1 . So we find
−1 0
x y = sin(x)
which implies
Z
−1
x y=
sin(x) dx + C = − cos(x) + C
and therefore
y = −x cos(x) + Cx.
Example 2.9. (x + 1)y 0 + y = ln(x) with y(1) = 10. The equation must be written as
R
1
ln(x)
y0 +
y=
from which we find µ = e dx/(x+1) = eln(x+1) = (x + 1). So we have
(x + 1)
(x + 1)
[(x + 1)y]0 = ln(x)
which implies
Z
(x + 1)y =
Z
ln(x) dx + C =
Z
0
x ln(x) dx = x ln(x) −
dx + C = (x ln(x) − x) + C.
At this point we evaluate the constant C using y(1) = 10
20 = (0 − 1) + C ⇒ C = 21.
and therefore
y=
(x ln(x) − x + 21)
.
(x + 1)
22
Example 2.10. y 0 + 2y =


1, 0 ≤ x < 3
with y(0) = 0. We need to solve two separate
x≥3

0,
problems in a certain order. First we solve y 0 + 2y = 1 with y(0) = 0 on the interval
0 ≤ x < 3. For this problem the integrating factor is µ = e2x so we have [e2x y]0 = e2x which
implies e2x y = e2x /2 + C. The initial condition gives 0 = 1/2 + C so C = −1/2. This gives
1
y=
1 − e−2x for all 0 ≤ x < 3. Now the continuity of the solution then requires that
2
y(3) = lim y(x) =
x→3
1
1 − e−6 .
2
This now becomes the initial condition for the second problem:
y 0 + 2y = 0 with y(3) =
1
1 − e−6
2
for x ≥ 3.
Solving this problem we get (notice we have the same integrating factor) [e2x y]0 = 0 so
1 6
1
e − 1 . Finally then we
e2x y = C and the initial condition implies C = e6 1 − e−6 =
2
2
get
1 6
y=
e − 1 e−2x for x ≥ 3.
2
Putting these solutions together we have
y(x) =


 1 (1 − e−2x ) ,
0≤x<3

 1 (e6 − 1) e−2x ,
x≥3
2
2
2.4
Exact Equations
Any first order ordinary differential equation of the first degree can be written (in infinitely
many ways) in differential form,
M (x, y) dx + N (x, y) dy = 0.
23
We know from Calculus III that if F (x, y) is a function satisfying
dF = M dx + N dy = 0,
then this equation is called exact. An (implicit) general solution of the differential equation
is
F (x, y) = c,
where c is an arbitrary constant. Since the differential of a function, F (x, y), is
dF ≡
∂F
∂F
dx +
dy,
∂x
∂y
M and N are the partial derivatives of F :
M (x, y) =
∂F
,
∂x
N (x, y) =
∂F
.
∂y
Example 2.11.
xdx + ydy = 0
is an exact differential equation since
d
dx
1 2
(x + y 2 )
2
=x+y
dy
dx
The solution of the differential equation is
1 2
(x + y 2 ) = c.
2
A necessary and sufficient condition for exactness. Consider the exact equation,
M dx + N dy = 0.
24
A necessary and sufficient condition for exactness is
∂N
∂M
=
.
∂y
∂x
What this means is that if the equation is exact then we are guaranteed there exits a
function F (x, y) so that
M=
∂F
∂x
and N =
∂F
∂y
(9)
and a general solution to the problem can be written as F (x, y) = 0.
More importantly (9) provides a method for finding F (x, y). Namely, integrating the first
equation of we see that
Z
F (x, y) =
M (ξ, y) dξ + f (y),
for some f (y).
If we differentiate this equation with respect to y and use the the second equation in
(9)
∂F
= N (x, y)
∂y
we arrive at an equation
Z
My (x, y) dx + f 0 (y) =
∂F
= N (x, y).
∂y
It can be shown that, after simplifying, we will arrive at an equation only in y for which
we can find f (y).
Let us reconsider the earlier example
Example 2.12.
xdx + ydy = 0.
Here M = x and N = y so
∂M
∂N
=0=
∂y
∂x
so the equation is exact and we know there exists a function F (x, y) so that Fx = M and
Fy = N .
25
Integrating Fx = M with respect to x we have
Z
F (x, y) =
x dx =
x2
+ f (y).
2
Differentiating with respect to y and using Fy = N we have
y = N = Fy = f 0 (y)
⇒
f 0 (y) = y.
Thus, integrating we obtain
y2
f (y) =
2
and we find
F (x, y) =
x2 y 2
+ .
2
2
The implicit general solution is
x2 y 2
+
=c
2
2
which, by renaming the constant c can be written as
x2 + y 2 = c.
Integrating Factors
Consider an equation
f dx + N
e dy = 0.
M
When this equation is not exact sometimes it can be made exact using an integrating
fy 6= N
ex but we can look for a function µ to multiply
factor. The idea is this, it may be that M
times the equation so that the resulting equation
f dx + µN
e dy = 0
µM
f and N = µN
e we obtain an exact equation M dx+N dy = 0.
is exact, i.e., Defining M = µM
26
The problem of finding such an integrating factor can be very difficult and we will only
investigate two possible scenarios. Some times it happens that we can find an integrating
factor that is a function of x alone, i.e., µ = µ(x). To test the new equation for exactness
we would seek µ(x) so that
f)y − (µ(x)N
e )x = µ(x)M
fy − µ(x)N
ex − µ0 (x)N
e =0
(µ(x)M
This can be rewritten as
µ0 (x) −
fy − N
ex
M
e
N
!
µ(x) = 0.
Assuming that
fy − N
ex
M
e
N
!
is a function of x alone then denoting it by f (x) we obtain a first order linear equation
µ0 (x) − f (x)µ(x) = 0,
with solution
Z
µ(x) = C exp
f (x) dx .
Thus we obtain the following
If f (x) =
fy − N
ex
M
e
N
!
Z
⇒ µ(x) = exp
f (x) dx
(10)
In a similar way we could ask if there is an integrating factor as a function of y alone.
To test the new equation for exactness we would seek µ(y) so that
f − (µ(y)N
e )x = µ0 (y)M
f + µ(y)M
f)y − µ(y)N
ex = 0
(µ(y)M
This can be rewritten as
µ0 (y) +
fy − N
ex
M
f
M
27
!
µ(y) = 0.
Assuming that
fy − N
ex
M
f
M
!
is a function of y alone then denoting it by g(y) we obtain a first order linear equation
µ0 (y) + g(y)µ(y) = 0,
with solution
Z
µ(y) = C exp − g(y) dy .
Thus we obtain the following
If g(y) =
fy − N
ex
M
f
M
!
Z
⇒ µ(y) = exp − g(y) dy
(11)
f = (2y 2 +3x) and N
e = 2xy
Example 2.13. Consider (2y 2 +3x) dx+2xy dy = 0. We have M
and
fy − N
ex = 4y − 2y = 2y.
M
e we obtain a function of x alone
If we divide by N
f (x) =
fy − N
ex
M
4y − 2y
2y
1
=
=
= .
e
2xy
2xy
x
N
We obtain
µ=e
R
f (x) dx
R
=e
dx/x
= eln(x) = x.
Multiplying the equation through by µ we have
(2xy 2 + 3x2 ) dx + 2x2 y dy = 0
and this equation is exact.
f = (2x + yx−1 ) and
Example 2.14. Consider (2x + yx−1 ) dx + (xy − 1) dy = 0. We have M
28
e = (xy − 1) and
N
fy − N
ex = x−1 − y.
M
e we obtain a function of x alone
If we divide by N
f (x) =
fy − N
ex
1 xy − 1
1
x−1 − y
M
=−
=− .
=
e
xy − 1
x xy − 1
x
N
We obtain
R
µ=e
f (x) dx
= e−
R
dx/x
= e− ln(x) = x−1 .
Multiplying the equation through by µ we have
(2 + yx−2 ) dx + (y − x−1 ) dy = 0
and this equation is exact.
f = (y 2 +2xy) and N
e = −x2
Example 2.15. Consider (y 2 +2xy) dx−x2 , dy = 0. We have M
and
fy − N
ex = (2y + 2x) − (−2x) = 2y + 4x.
M
f we obtain a function of y alone
If we divide by M
g(y) =
fy − N
ex
M
2y + 4x
2 (y + 2x)
2
= 2
=
= .
f
(y + 2xy)
y (y + 2x)
y
M
We obtain
µ = e−
R
g(y) dy
= e−2
R
dy/y
= e−2 ln(y) = y −2 .
Multiplying the equation through by µ we have
(1 + 2xy −1 ) dx − (x2 y −2 ) dy = 0
and this equation is exact.
29
Example 2.16. Find an integrating factor in the form µ = xn y m for the equation
(2y 2 − 6xy) dx + (3xy − 4x2 ) dy = 0
(12)
f = (2y 2 − 6xy), N
e = (3xy − 4x2 ) and we seek an integrating factor µ. This
So we have M
f)y = (µN
e )x or
means we need (µM
∂[xn y m (2y 2 − 6xy)]
∂[xn y m (3xy − 4x2 )]
=
∂y
∂x
Simplifying this a bit by collecting the x and y terms we obtain
∂(2xn y m+2 − 6xn+1 y m+1 )
∂(3xn+1 y m+1 − 4xn+2 y m )
=
∂y
∂x
or
2(m + 2)xn y m+1 − 6(m + 1)xn+1 y m = 3(n + 1)xn y m+1 − 4(n + 2)xn+1 y m .
Now on each side we have powers of the form xn y m+1 and xn+1 y m and the corresponding
coefficients of these terms on each side must be the same so that implies
2(m + 2) = 3(n + 1)
and
− 6(m + 1) = −4(n + 2)
or
3n − 2m = 1
2n − 3m = −1
To solve this system system of equations you could multiply the first equation by −2/3
and add it to the second equation (so that the n’s cancel) to get
3n − 2m = 1
−5/3m = −5/3
From the second equation we get m = 1 and then the first equation becomes 3n − 2 = 1
which implies n = 1 so we obtain an integrating factor µ = xy.
30
Lets check to make sure it works. Multiplying the differential equation (12) by µ we get
(2xy 3 − 6x2 y 2 ) dx + (3x2 y 2 − 4x3 y) dy = 0.
So M = (2xy 3 − 6x2 y 2 ) and N = (3x2 y 2 − 4x3 y) and we have
My = (6xy 2 − 12x2 y)
and
Nx = (6xy 2 − 12x2 y)
and since My = Nx the equation is exact.
2.5
Homogeneous Equations
Consider a first order equation
dy
= f (x, y).
dx
We say that this equation is Homogeneous if the right hand side can be written in the form
dy
= F (y/x).
dx
(13)
If this is possible the we can reduce the equation to a separable equation using the change
of dependent variable
u = y/x.
Note that u = y/x implies y = xu which, in turn, implies
dy
du
=u+x .
dx
dx
Therefore the equation (13) can be written as
u+x
du
= F (u)
dx
31
which is separable. Namely, we can write
dx
du
=
F (u) − u
x
and we obtain an implicit solution by integration
Z
du
=
F (u) − u
Z
dx
+ C.
x
Example 2.17. Consider the problem
x
dy
y2
=
+ y.
dx
x
Dividing by x we obtain
dy y 2 y =
+
.
dx
x
x
Proceeding as above, we set u = y/x implies y = xu which, in turn, implies
dy
du
=u+x .
dx
dx
Thus the equation becomes
u+x
du
= u2 + u.
dx
Now we simplify by subtracting the u on both sides and separate the variables to obtain
du
dx
=
.
2
u
x
Integrating both sides we have
−
1
= ln |x| + C.
u
So we get
u=
−1
ln |x| + C
and finally
y = xu =
−x
ln |x| + C
32
2.6
Bernoulli equations
A Bernoulli equation is any equation that can be written in the form
y 0 + f (x)y = g(x)y α ,
α 6= 0, 1.
(14)
Note that if α = 0, 1 then the equation is first order linear.
The Bernoulli equation can be reduced to a first order linear equation using the following substitution:
u = y 1−α .
This relation implies
du
dy
= (1 − α)y −α .
dx
dx
Multiplying the Bernoulli equation by (1 − α)y −α we see that it can be written as
(1 − α)y −α
dy
+ (1 − α)f (x)y 1−α = (1 − α)g(x)y α y −α
dx
which simplifies to
du
+ (1 − α)f (x)u = (1 − α)g(x).
dx
If we let p(x) = (1 − α)f (x) and q(x) = (1 − α)g(x) then we obtain the first order linear
equation
du
+ p(x)u = q(x)
dx
which can be solved using the methods discussed in the Section on first order linear
problems.
Example 2.18. Consider the problem
y0 + y = y4.
This is a Bernoulli equation with α = 4 so (1 − α) = −3 and we set u = y −3 . Then we
33
obtain the linear equation
du
− 3u = −3.
dx
To solve this problem we find the integrating factor
I = e−3
R
dx
= e−3x .
Multiplying by I we obtain
0
e−3x u = −3e−3x .
Next we integrate to obtain
Z
e
−3x
Z
u dx =
−3e−3x dx
which gives
e−3x u = e−3x + C
or
u(x) = 1 + Ce3x .
Finally, converting back to y we have
y(x)−3 = 1 + Ce3x .
2.7
RHS in the form f (ax + by + c)
If for the equation y 0 = f (x, y) right hand side can be written as function of a linear relation
in x and y, i.e., it has the form f (ax + by + c) then a simple substitution transforms the
problem into a separable problem. Namely, if we set v = ax + by + c then v 0 = a + bf (v)
which is separable.
Example 2.19. Consider the problem
y 0 = e−(x+y) − 1.
34
We set v = x + y which implies v 0 = 1 + y 0 = 1 + (e−v − 1) = e−v . The equation v 0 = e−v is
separable and seperating the variables we have
ev
dv
=1
dx
⇒
ev dv = dx
⇒
ev = x + c ⇒
ex+y = x + c.
Thus we have an implicit general solution ex+y = x + c.
2.8
Numerical Method - Euler’s Method
We consider the most basic numerical method – Eulers method. Thus we consider finding
an approximate solution for the first order problem
y 0 = f (x, y),
y(0) = y0 ,
on [0, L]
First we discretize the interval [0, L] by setting h = L/N for N a positive integer and set
xn = nh,
n = 0, 1, · · · , N,
h=
L
.
N
Next we note that for N large (i.e., for h small), if y(x) is differentiable then
y(xn ) − y(xn−1 )
≈ y 0 (xn−1 )
h
or
y(xn ) ≈ y(xn−1 ) + hy 0 (xn−1 ).
Since y 0 (xn−1 ) = f (xn−1 , y(xn−1 )) we have
y(xn ) ≈ y(xn−1 ) + hf (xn−1 , y(xn−1 )).
The Euler numerical method exploits this approximation by computing a sequence of
numbers {yn }N
n=1 given by
yn = yn−1 + hf (xn−1 , yn−1 ) n = 1, 2, · · · N.
35
For N very large (i.e., h very small), we expect that yn is approximately equal to y(xn ).
Consider a simple example
Example 2.20. Consider the initial value problem
y 0 = y,
y(0) = 1.
Solution: The algorithm simplifies in this special case to the formulas
xn = nh, yn = yn−1 + hyn−1 = (1 + h)yn−1 , n = 1, ..., N.
It is easy to compute a few values by hand. For example, let h = .1 and consider
finding an approximation to y(.5) using Euler’s method.
n
0
1
2
3
4
5
xn
0
0.1
0.2
0.3
0.4
0.5
yn
1.0000 1.1000 1.2100 1.3310 1.4641 1.6105
So, since the exact solution is y = ex our approximation to y(.5) = e.5 = 1.6487 is
y5 = 1.6105 and the error in this approximation is e5 = |y(.5) − y5 | = 0.0382.
Below we use a computer to compute the iterates for (xn , yn ) for N = 20, 80, 200 on
0 < x < 2 (so with L = 2) using Eulers method, as follows:
Step 1. Define x0 = 0, y0 = 1, from the initial condition y(0) = 1.
Step 2. Define h = L/N , xn = nh, n = 1, · · · , N .
Step 3. Definef (x, y) = y), the right side of the differential equation, and then let
yn = yn−1 + hf (xn−1 , yn−1 ),
Step 4. Plot the resulting approximate solution.
36
n = 1, ..., N.
xj
N = 20 N = 80 N = 200
0
0
0
0
7
0.2222
0.0129
0.0034
0.0014
6
0.4444
0.0322
0.0085
0.0034
5
0.6667
0.0600
0.0159
0.0064
4
0.8889
0.0993
0.0264
0.0107
3
1.1111
0.1542
0.0412
0.0167
2
1.3333
0.2300
0.0617
0.0250
1.5556
0.3333
0.0898
0.0365
1.7778
0.4733
0.1279
0.0520
2.0000
0.6616
0.1795
0.0730
1
0
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
Errors e(j) = |yj − exj |
A maple implementation appears below for solving y 0 = y, y(0) = 1. We solve the
problem on the time interval 0 < x < 2 and plot the result together with the exact solution
y = ex .
with ( plots ) :
f : = ( x , y)−> y ;
N: = 2 0 : L : = 2 : h : = L /N: x0 : = 0 : y0 : = 1 :
xx : = a r r a y ( 0 . . N ) ;
y := array ( 0 . .N) ;
t t [ 0 ] : = x0 ; y [ 0 ] : = y0 ;
f o r j from 1 t o N do
xx [ j ] : = xx [ j −1]+h : y [ j ] : = y [ j −1]+h∗ f ( xx [ j −1] , y [ j − 1 ] ) : od :
[ xx [ 0 ] , y [ 0 ] ] ;
V: = seq ( xx [ j ] , y [ j ] ] , j = 0 . .N ) ;
pv : = p l o t ( [ V ] , c o l o r = b l u e ) :
e x a c t : = r h s ( d s o l v e ( { d i f f ( y ( x ) , x )= f ( x , y ( x ) ) , y ( 0 ) = 1 } , y ( x ) ) ) ;
pexact : = p l o t ( exact , x = 0 . . L , c o l o r =red ) :
d i s p l a y ( [ pv , pexact ] ,
t i t l e = ‘ e x a c t and Euler ‘ ) ;
37
Here is an example for which the exact solution cannot be computed in closed form.
Example 2.21. Consider the initial value problem
y 0 = 1 + xy,
y(0) = 1,
0<x<1
so we have f (x, y) = 1 + xy and
yn = yn−1 + h(1 + xn−1 yn−1 )
= yn−1 + h(1 + (n − 1)h yn−1 )
= [1 + h + (n − 1)h2 ] yn−1
n = 1, 2 · · · .
For the Euler approximation we have set N = 10.
As for the exact solution, in Maple we obtain the following result
√ √ √
2
y (x) = 1/2 π 2erf 1/2 2x + 1 e1/2 x
where erf is the error function defined by
Z
x
erf(x) =
2
e−s ds.
0
Here is a very basic simple Matlab code
N=10;
T=1;
x = ( 0 :N) ∗ h ;
h=T /N;
y (1)=1;
f o r n = 2 : (N+1)
y ( n )= y ( n−1) + h ∗(1+ x ( n−1)∗y ( n − 1 ) ) ;
end
plot ( x , y )
38
39
xj
yj
|yj − y(xj )|
0
1
0
0.1
1.1
0.006
0.2
1.189
0.012
0.3
1.265
0.017
0.4
1.327
0.025
0.5
1.374
0.031
0.6
1.405
0.037
0.7
1.421
0.042
0.8
1.422
0.047
0.9
1.408
0.049
1
1.381
0.05
Download