0% found this document useful (0 votes)
133 views

Differential Equations: 4.1 Classification

This document discusses methods for solving ordinary differential equations (ODEs). It begins by classifying ODEs as either linear or nonlinear, homogeneous or non-homogeneous, and by order. Examples are given of each type of ODE. Methods are then presented for solving first order homogeneous ODEs, including using separation of variables for nonlinear equations and integrating factors for linear equations. Finally, numerical methods for solving ODEs on a computer are briefly introduced, starting with the explicit Euler method.

Uploaded by

Nisha Alcantara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views

Differential Equations: 4.1 Classification

This document discusses methods for solving ordinary differential equations (ODEs). It begins by classifying ODEs as either linear or nonlinear, homogeneous or non-homogeneous, and by order. Examples are given of each type of ODE. Methods are then presented for solving first order homogeneous ODEs, including using separation of variables for nonlinear equations and integrating factors for linear equations. Finally, numerical methods for solving ODEs on a computer are briefly introduced, starting with the explicit Euler method.

Uploaded by

Nisha Alcantara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Chapter 4

Differential Equations

In the following short chapter we will summarize some easy and efficient methods for solving simple
first order Ordinary Differential Equations (ODEs). In order to use the appropriate method to obtain
the solution of a given ODE we must be able to classify the type of ODE we have at hand.

4.1 Classification
In general we classify differential equations as either partial or ordinary. For now we examine only
ordinary differential equations. In general however most models are usually comprised of several (a
system) partial or ordinary differential equations. Another reason that ordinary differential equations
(ODEs) are important is that techniques of solution for partial differential equations (PDEs) can stem
from those in ordinary differential equations. So learning how to solve ODEs will be useful by itself
or in conjuction to solving PDEs.
To choose the appropriate method of solution for a given ODE you must find out what type of
ODE you have. ODEs are categorized, among other things, as: linear/non-linear, ordinary/partial.
Also we usually refer to the “order” of the ODE as well as to whether it is “homogeneous” or not.
The following examples should be helpful in understanding how this classification system works:
dy
o dx
= −3x + 5 1st order linear non-homogeneous ODE
dy
o 3 dx = 9y 2 1st order non-linear homogeneous ODE
dy
o 3 dx +y =0 1st order linear homogeneous ODE
d2 y
o 3 dx2 + 9x3 y = 9 2nd order linear non-homogeneous ODE
dy 2

o 7 dx + 4y = 0 1st order non-linear homogeneous ODE

Try to figure out based on the examples above how naming of ODEs works. You probably understand
from the above how we determine the order of an ODE - based on the order of the derivative in
the equation. How about linearity? Do you see it? Linearity refers to the power of y. For instance
anything with y 2 and higher is non-linear. Similarly if a derivative was raised to a power, such as
dy 2
( dx ) , then it is also non-linear. Now determining whether an ODE is homogeneous or not is a
different story. The idea, as you may have noticed, is to bring all terms which include y’s on one
side of the equation. If by doing so the other side of the equation is 0 then you have a homogeneous
ODE. Otherwise you have a non-homogeneous ODE.

53
FMN050–Spring 2014. Claus Führer and Alexandros Sopasakis page 54

4.2 Solving first order homogeneous ODEs


Now that you have learned some of the basics about the names of these equations you will put them
to use in order to decide which method to choose in order to obtain their solutions. If you correctly
identified the ODE then you will be able to solve it!
It is not the point of our class to review all methods of solution for a given ODE. Instead we
emphasize on the ones we will probably put to use during our study of mathematical models. In that
respect we start by studying methods of solution for 1st order homogeneous ODEs.

4.2.1 Non-linear first order homogeneous ODEs


It may sound surpricing but some of the easiest first order ODEs to solve are the nonlinear (homoge-
neous) ones. Let us examine for example the following non-linear 1st order homogeneous differential
equation,
0 dy
xy = y 2 , or otherwise also written as: x = y2
dx
with the following initial condition y(1) = −1. We will present the solution of this equation based
on the separation of variables method. We outline this method of solution for such an ODE below:
1. Separate variables:
dy dx
2
=
y x
2. Integrate both sides: Z Z
dy dx
dx = dx
y2 x
which gives,
1
− = ln(x) + C (4.1)
y
do not forget the constant of integration C! To evaluate C we use the initial condition, y(1) = 5.
If, on the other hand, no initial condition is provided then C will be part of the final solution
for this equation. Note that the initial condition y(1) = 5 implies that for x = 1 then y = 5.
Substituting these values to equation (4.1) above we obtain,
1
C = − − ln(1) = −.2
5
Thus equation (4.1) becomes
1
− = ln(x) − .2
y
That’s it! We solved this differential equation! How do we know that we solved it? Easy!
Do you see any derivatives left? If not then we are done. The equation is solved! In this
case we can even go further and solve it for y itself (something that is not always necessary or
sometimes even possible),
1
y=−
ln(x) − 15
Ok, so now we can take care of the non-linear homogeneous type first order ODEs. Let’s now see
how we can solve the linear ones.
FMN050–Spring 2014. Claus Führer and Alexandros Sopasakis page 55

4.2.2 Linear first order ODEs


In this case we will in fact see a method which not only solves the linear first order homogeneous
ODEs but the non-homogeneous ones also! Let’s first look at a typical example for such an equation,
dy
− 2y = 5 with the following initial condition y(0) = 0
dx
We outline the steps of the solution below:
0
1. Rewrite the equation in a “canonical” form y + p(x)y = q(x). Note that luckily enough our
equation is already in this form.
2. Obtain the “integrating factor” µ which is defined to be
R
p(x) dx
µ=e
In our case the integrating factor for this ODE is,
R
−2 dx
µ=e = e−2x

3. Multiply both sides of the ODE with the integrating factor µ.


0
µ(y + p(x)y) = µq(x)
You can then “group” the left and the right hand sides as follows
0
(yµ) = µq(x)
In our case we multiply the ODE with µ and obtain,
dy
e−2x ( − xy) = e−2x 5
dx
We then can rewrite the above as,
0
e−2x y = 5e−2x

4. Integrate both sides. This has the effect that always the left hand side derivative disappears.
In our example this gives, Z
e y = 5e−2x + C
−2x

or rather
5 −2x
e−2x y = e +C
−2
As previously we can find the value C by substituting the initial conditions. In our example
we are given that y = 0 when x = 0. Thus substituting on the above we obtain,
5
e0 0 = − e0 + C
2
which implies that C = 5/2. Therefore our equation becomes,
5 5
e−2x y = − e−2x +
2 2
Note that this is really our solution for the ODE. We can even solve it for y as follows,
5 5
y = + e2x
2 2
FMN050–Spring 2014. Claus Führer and Alexandros Sopasakis page 56

4.3 Numerical solutions to ODEs


In this section we will learn how to solve a number of different types of ODEs using a computer and
applying some well known and very effective numerical algorithms. We start our exposition with a
simple but robust method.

4.3.1 Explicit Euler’s method


This method is simple to learn and will essentially allow us to solve almost any type of ODE which
we will come across. Naturally we implement this method in the computer but in fact for simple
problems you could possibly obtain the solution with a calculator (or even by hand).
The starting point is to write your ODE in the following form,
0
y = f (x, y)

where f (x, y) corresponds to any other term in your ODE. For instance looking back at the equation
0
xy = y 2 which we solved earlier we would rewrite it as,
0 y2
y =
x
y2
In this case therefore f (x, y) = x
. Once this is established the method iterates in the computer with
the following formula,

Explicit Euler’s method: yn+1 = yn + hf (xn , yn )

where here h denotes the step size in x. The iteration counter n starts at 0 and will go on until we
produce the solution required by the problem. For instance recall that the initial condition for our
ODE was provided to be y(1) = 5. In this case for n = 0 we have that x0 = 1 and y0 = 5 with which
to start the iteration of our method. The only thing which may be left up to you (unless specifically
given by the problem) is how big the step size h should be chosen to be.
Euler’s method is not exact! In fact it almost always includes errors and the solution predicted
is only an approximation to the true solution. The bigger the step size h the bigger the errors to our
solution. So if you would like to have a very accurate solution then you must take a very small step
size h and therefore you must iterate several times.
Let us assume that you would like to obtain the solution y when x = 10 for the following ODE
0
xy = y 2 , with initial condition y(1) = −1

Remember that we rewrite the ODE first. So here f (x, y) = y 2 /x. Since the step size h is not
specified you are free to choose. So if you take h = 1 then you would have to iterate Euler’s method
9 times since you are starting at x = 1 and need to reach x = 10 with this h. The following table
shows the result of the computer output and how each y is produced after each iteration of the
method,
n 0 1 2 3 4 5 6 7 8 9
x 1 2 3 4 5 6 7 8 9 10
y −1 −.5 −.42 −.37 −.34 −.32 −.31 −.29 −.28 −.2801
f (x, y) .5 .08 .04 .03 .02 .01 .01 .01 .008 .007
FMN050–Spring 2014. Claus Führer and Alexandros Sopasakis page 57

So the solution at x = 10 is y = −.2801 using a step size of h = 1. Is this correct? In fact we can
check this since we have found earlier the exact solution to be
1
y=−
ln(x) + 1
Let us compare, side by side, the approximate solution produced by Euler’s method above with this
exact solution in the table below:
x 1 2 3 4 5 6 7 8 9 10
yapp. −1 −.50 −.41 −.37 −.34 −.32 −.3104 −.2983 −.2884 −.2801
yex −1 −.59 −.47 −.41 −.38 −.35 −.3395 −.3247 −.3128 −.3028

This gives that y = −.2801 for x = 10 while the equivalent exact solution is y = .3028. The absolute
error between the two being .0227 and the relative error .075. We can not help but wonder how
much better we could possibly do if we decrease the step size h = .5. In that case of course it would
take us 18 iterations starting at x = 1 to reach x = 10. We display some of these results in the table
below:
n 0 1 2 3 4 ... 15 16 17 18
x 1 1.5 2 2.5 3 ... 8.5 9 9.5 10
yapp. −1 −.66 −.55 −.49 −.45 . . . −.3091 −.3037 −.2989 −.2944
yex −1 −.71 −.59 −.52 −.47 . . . −.3185 −.3128 −.3076 −.3028

This time the absolute error between the exact and approximate solutions for x = 10 is .0084 while
the relative error is just .000003. Huge improvement for a little bit extra work for the computer.

4.3.2 Runge-Kutta Method (not shown in class)


We now present an even more accurate method which although it is slightly more complicated to
program in the computer can also solve an ODE of the type,
0
y = f (x, y)

Usually the Runge-Kutta method is more accurate than the Euler method for the same value of the
step size h. The Runge-Kutta method goes as follows:
1
yn+1 = yn + (k1 + 2k2 + 2k3 + k4 ) where
6
k1 = hf (xn , yn )
1 1
k2 = hf (xn + h, yn + k1 )
2 2
1 1
k3 = hf (xn + h, yn + k2 )
2 2
k4 = hf (xn + h, yn + k3 )

Just so that we can see the differences between the Euler and Runge-Kutta methods we solve the
same exact ODE as before,
0
xy = y 2 , with initial condition y(1) = −1
FMN050–Spring 2014. Claus Führer and Alexandros Sopasakis page 58

for a step size of just h = 1. The results are shown in the table below:
n 0 1 2 3 4 5 6 7 8 9
x 1 2 3 4 5 6 7 8 9 10
yEuler −1 −.5 −.42 −.37 −.34 −.32 −.3104 −.2983 −.2884 −.2801
yR−K −1 −.57 −.46 −.41 −.37 −.35 −.3342 −.3199 −.3083 −.2986
yex −1 −.59 −.47 −.41 −.38 −.35 −.3395 −.3247 −.3128 −.3028
Based on these results you can make up your mind about which method is best and compare the
differences for yourself!

4.4 Higher order ODEs


In fact the numerical schemes just presented are much more powerful than you might think. In this
section we will see that we can use these methods not just for first order ODEs but also for higher
order. We will learn a method which allows us to reduce any higher order ODE into a system of first
order ODEs. The benefit is that once we obtain such a system of first order ODEs we can use an
equivalent version of Euler or Runge-Kutta method in order to solve that system.

4.4.1 Reduction of order


Suppose for instance that we wish to solve a third order ODE such as,
000 0
y + 3y − 2y = 0 (4.2)
The method goes as follows: We start by defining 3 (as many as the derivatives) new variables, u1 , u2
and u3 via,
0
u1 = y, u2 = y , u3 = y 00 , (4.3)
Now we take derivatives on both sides of the above and obtain,
0 0 0 00 0
u1 = y , u2 = y , u3 = y 000 ,
000 000 0
Note that in fact we can replace y above by solving our 3rd order equation (4.2) for y = −3y + 2y.
0 0
Therefore in fact u3 = −3y +2y. But based on (4.3) we can also replace the y’s with the corresponding
u1 or u2 . Therefore we can write u3 as,
0 0
u3 = −3y + 2y = −3u2 + 2u1
Summarizing this analysis we have,
0 0
u1 = y = u2
0 00
u2 = y = u3
0 000
u3 = y = −3u2 + 2u1
We will rewrite the above once more in a nicer format by reordering the u’s and inserting a zero if
no corresponding u exists in that row:
0
u1 = 0u1 + 1u2 + 0u3
0
u2 = 0u1 + 0u2 + 1u3
0
u3 = 2u1 − 3u2 + 0u3 .
FMN050–Spring 2014. Claus Führer and Alexandros Sopasakis page 59

In this format it is not that hard to see that we can write this system into a matrix as follows,
 
0 1 0
0
U = AU where A =  0 0 1 
2 −3 0

In this format it is now clear that our original single 3rd order ODE (4.2) has been transformed to
a reduced 1st order system of three ODEs. In general this method can take a single nth order ODE
and transform it into a system of n first order ODEs. Once you have such a system you can apply
Euler or Runge-Kutta method to solve it. The following simple example should be illustrative of this
procedure.
Example:
Solve the following ODE using Euler’s method. Obtain the solution for x = 1.
00 0
y −y =x with initial conditions: y(0) = 0, y (0) = 1 (4.4)

We start by reducing the 2nd order ODE into a system of 2 first order ODEs. To do this we follow
the procedure outlined previously. We first define 2 new variables, u1 and u2 as follows,
0
u1 = y u2 = y

Now we differentiate both sides,


0 0 0 00
u1 = y u2 = y
00 0 00
and eliminate y by solving (4.4). Thus, u2 = y = x + y and replace y here with u1 . Thus,
0 0
u1 = y = u2 = 0u1 + 1u2
0
u2 = x + y = x + u1 = 1u1 + 0u2 + x

To make the notation clearer we rename u1 = U and u2 = V . Thus we have the following two
equations,
0
U = F (x, U, V ) where F (x, U, V ) = V
0
V = G(x, U, V ) where G(x, U, V ) = x + U
We are now ready to apply Euler’s method for this system. Before we start though we should
also translate the initial conditions to correspond to U and V . Starting with y(0) = 0 and since
0
y = u1 = U then we have that U (0) = 0. Similarly the other initial condition y (0) = 1 becomes
0
V (0) = 1 since y = u2 = V .
Euler’s method for our system is equivalent to the following:

Un+1 = Un + hF (xn , Un , Vn )
Vn+1 = Vn + hG(xn , Un , Vn )

The following table provides the solution assuming a step size of h = .2,

n 0 1 2 3 4 5
x 0 .2 .4 .6 .8 1
U 0 .2 .4 .616 .864 1.1606
V 1 1 1.08 1.24 1.48 1.816
FMN050–Spring 2014. Claus Führer and Alexandros Sopasakis page 60

Thus when x = 1 we obtain the approximate solution to be U = u1 = 1.16 and V = u2 = 1.82. This
solves our problem! Well not really. Remember that the original question was to solve for y not
U, V, u1 or even for u2 . However we know that y = u1 . Thus y ≈ 1.16 when x = 1!
Just to check our solution if we reduce the step size to h = .1 and iterate 10 times we obtain the
solution to be y ≈ 1.24 when x = 1. If the step size becomes h = .01 and we iterate 100 times we
obtain y ≈ 1.3388. Last if we reduce the step size to h = .001 and iterate 1000 times we obtain that
y ≈ 1.3492. In other words we can safely believe that y ≈ 1.34.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy