16
Elementary Mathematics Differential Equation models This is an article from my home page: www.olewitthansen.dk Ole Witt-Hansen 2008

Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Elementary Mathematics

Differential Equation models

This is an article from my home page: www.olewitthansen.dk

Ole Witt-Hansen 2008

Page 2: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Contents

3. Issues that lead to differential equations ................................................................................1 3.1 The dependence of the atmospheric pressure on height ......................................................1 3.2 The suspended chain ............................................................................................................2 4. Numerical integration of differential equations .....................................................................4

5. Differential equation models..................................................................................................7 5.1 The course of an influenza epidemic. ..................................................................................7 5.2 Interaction between two animal species.............................................................................10 5.3 Competing species ............................................................................................................12

Page 3: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 1

3. Issues that lead to differential equations In all science, but also in economy certain issues lead to the set up of differential equations. First we shall deal with two examples collected from physics.

3.1 The dependence of the atmospheric pressure on height We consider a (mathematical) rectangular box placed in the atmosphere. The area of the horizontal faces is A. The box is located at the height y over the ground. The thickness of the box is Δy. The pressure on the upper side and on the lower side are denoted p(y+ Δy) and p(y) respectively. The density of the air in the height y is ρ(y). We recall that the force on a plane surface, having area A is F = pA, where p is the pressure on the surface. We shall then express the difference of the forces on upper side and on the lower side is equal to the gravity of the mass of the air inside the box, (assuming that the air in the box is at rest). p(y)A - p(y+ Δy)A = mair g = ρ(y)Vairg = ρ(y)AΔyg

Dividing the equation by AΔy we find:

(3.1) gydy

dp

y

ypyyp)(

)()(

If we shall solve this equation, we must, however, know another relation between ρ(y) and p(y). This can, however, be obtained from:

1. The equation of state for ideal gasses: PV = nRT,

2. The definition of the mass of a mole: M

mnnMm

3. The definition of density: VmV

m .

If (2) and (3) are inserted in the equation of state, we have:

P

RT

MRT

M

VPV

RTM

VRT

M

mnRTPV

This expression for the density is then inserted in (3.1), which hereafter becomes:

(3.2) pRT

Mg

dy

dp

As you know the temperature decreases about 1oC for every 200 m, you go up in the atmosphere.

Page 4: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 2

In the first approximation, we shall however assume that the temperature is constant. The solution to the differential equation is well known.

(3.3) y

RT

Mg

epyp

0)(

If we insert known values for the physical constants: M =29 g/mol, g = 9.82 m/s2, R=8.31 J/(mol K) and T = 273 K:

(3.4) yepyp42610.1

0)(

Where the height y is measured in meters. This implies a pressure drop, which is 1.3% per 100 m and 12% per 1000 m. Next we look at the solution to the differential equation if the temperature decreases linearly with 10C, per 200 m. The temperature at the ground is set to 20 0C = 293 K. The temperature at the height y is therefore: T = T(y) = 293 – y/200. The differential equation then becomes:

(3.5) pR

Mg

dy

dpy )293(

200

This equation is the solved by the usual methods by separating the variables, and integrating.

yp

p

dyyR

Mg

p

dp

0 200293

1

0

200293

1

1

1

293 00

withdyyR

Mg

p

dp yp

p

The equation is integrated to give:

(3.6) )ln(0p

p

R

Mg

yppyR

Mg 2930 )1()1ln(

293

If the pressure is calculated after (3.6) it only causes deviations from (3.4) of about 0.1 – 0.2 %.

3.2 The suspended chain

Page 5: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 3

The suspended chain is the designation for the curve y = f(x), that a ”chain” (rope, cable) will follow when it is suspended in two points.

)(xF

denotes the tangential force by which the chain is influenced at x. The horizontal component of the force F0 is independent of x, since the chain is at rest in the horizontal direction.

The vertical component of the force Fy(x0) = 0 in the minimum point x = x0, since )(xF

is horizontal at that point. From This follows that Fy(x) is equal to the gravitational force, which act on the chain from x0 to x. For the length of the curve, we have the expression (from the integral calculus).

(3.7) dxxfxlx

x 0

2)('1)(

If the mass per unit length of the chain is μ, then the gravity of the piece l equal to μ∙l∙g, where g as usual is the acceleration of gravity: g = 9.82 m/s2. The force Fy(x) = F0 tanθ, where θ is the slope of the tangent in x, and thus Fy(x) = F0 f ’(x). Summarizing:

gxlxfFxFanddxxfxl y

x

x)()(')()('1)( 0

2

0

dxxfgxfFx

x0

20 )('1)('

(3.8) dxxfF

gxf

x

x 0

2

0

)('1)('

From the equation (3.8) we can see that )(' xf is an integral to 2

0

)('1 xfF

g

, and therefore:

2

0

)('1)('' xfF

gxf

,

which is a differential equation of the type:

(3.9) 2'1'' yky , where 0F

gk

is a positive constant.

To solve (3.9) we put z = y’ and thus: z’ = y’’, reducing the equation to a first order equation.

(3.10) 21' zkz The equation (3.10) can be solved, but it requires knowledge of the hyperbolic functions.. 3.11 Example. Hyperbolic functions. The hyperbolic functions cosh x and sinh x are defined as:

(3.12) )(2

1sinh)(

2

1cosh xexexogxexex

Page 6: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 4

Their resemblance in names with cos x and sin x , although the functions are very different, comes from that they share some (almost) common properties with the trigonometric functions. For example, we get by differentiating: (3.13) (cosh x)’ = sinh x and (sinh x)’ = cosh x Furthermore , the hyperbolic functions satisfy the basic relation: cos2x + sin2x = 1 in a slightly modified form.

1)4(4

12)(4

12)(4

12sinh2cosh xexexexexexexx

So, we have:

(3.14) 12sinh2cosh xx We then solve the differential equation (3.10) by separating the variables.

kdxz

dzzk

dx

dzzkz

21

2121'

kdxz

dz

21

Evaluating the integral, we make the substitutions:

z = sinh t => dz = cosht dt and t = sinh-1z.

Using these substitutions, we have:

kdxt

tdtkdx

z

dz22 sinh1

cosh

1

111cosh

coshckxtckxdtckxdt

t

t

)sinh(sinh 111 ckxzckxz

Since y’ = z , the last equation is integrated to: 2)1cosh(1

)( cckxk

xfy

If we substitute 0F

gk

back in the original equation, we finally obtain.

(3.15) 210

0 )cosh()( ccxF

g

g

Fxfy

The last equation demonstrates that the curve, the last expression (3.15) shows that the curve a chain will follow is tuned to a hyperbolic cosine. The constants c1 and c2 are determined by the initial conditions.

4. Numerical integration of differential equations As pointed out in the section on differential equations there are only a few types of differential equations that can be solved analytically. Analytically means that the solution y = f(x) can be expressed by already known functions. In the opposite case, one is referred to numerical methods, which means that you start with the initial conditions, that is, the line element: );,( 00 yx , such that )(')( 000 xfandxfy , and

then calculating forward in small steps of length h. The method is called numerical analysis.

Page 7: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 5

Numerical analysis is a huge area within mathematics. We have for example in the section of differential calculus derived Simpson’s formula apt for integrating a function, and Newton Raphson’s method for determining the zero points 0)( xf of a function. Solving first order differential equations numerically, we shall only look at the oldest and most simple method called Eulers method. Euler’s method is based on the approximating of a first degree polynomial, which was described in the section on differential calculus. That a function y = f(x) is differentiable in x0 is equivalent to the writing: (4.1) f(x0+h) = f(x0)+ f ’(x0)h+ ε(h)h, Here ε(h) is an epsilon-function defined by: ε(h) ─> 0 for h ─> 0. In the equation (4.1) f(x0+h) is approximated by three terms. The first term is of zero’th order in h, (is a constant). The next term is of first order in h (is proportional to h) and the last term is of higher order than one in h, (proportional to ε(h)h). If h is a small number e.g. h=0.01, then h2 =10-4, and for that reason it becomes less significant and the significance decreases the less h is. Assuming that we have a general first order differential equation. y' = g(y,x) If ),( 00 yx is the initial point and ),( 11 yx is the next point, then Euler’s method is about to find an

approximation to f(x1) using the first degree approximation polynomial:

f(x1) = f(x0+h) with f(x1) = f( x0 )+ f ’( x0 )h. This will result in the following values: y0 = f( x0 ) (4.2) y1 = f(x1) = f(x0+h) = f(x0)+ f ’( x0 )h = y0 + g( y0, x0)h

y2 = f(x2) = f(x1+h) = f( x1)+ f ’(x1)h = y1 + g( y1, x1)h The error is in each step proportional to h2, but if f ’(x) has the same sign in all steps then the errors will accumulate in the same direction and eventually bring the solution astray. A considerable more accurate method is due to Aitken, it requires that we as the initial values

know )()2

( 00 xfandh

xf . )(20

hxf may for example be found by Euler’s method using ½h as

the step length. Then the calculations proceed as follows:

hxygxfhxfxfxfxfhhh

),()()(')()()( 0000001 222

hxygxfhxfxfxfxfhhh

),()()(')()()( 1111112 222

Page 8: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 6

One may show that the error is of order h3, by making a Taylor expansion of )2

( 0

hxf

and )2

( 0

hxf of the equation:

hxygh

xfh

xf ),()2

()2

( 0000

222020020 )())(('')(')()( hhxfxfxfxf hhh

222020020 )())(('')(')()( hhxfxfxfxf hhh

Subtracting the last equation from the first we have:

2102020 )()(')()( hhhxfxfxf hh

We can see that the error in the determination of )(

20hxf is of order h3. In contrast to the Euler

method where: f(x0+h) = f( x0 )+ f ’( x0 )h+ ε(h)h. (order of h2) above we have sought to illustrate the two methods graphically In practice even more advanced methods are used, and the method that rules almost everywhere is the so called Runge-Kutta 4. order method, where the error is proportional to h4 . The explanation of this method is, however, far beyond “elementary mathematics” Example As an example of using Eulers method, we shall solve a differential equation both analytically and using Runge-Kutta.

The differential equation xx

yy

dx

dy

2 has one solution: y = x∙tan(x).

Page 9: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 7

Below the graph of the solution is shown, together with the graph from the numerical solution using Runge-Kutta But as you can see, except for extremely small deviations, there is only one curve.

5. Differential equation models When we talk about a mathematical ”model”, we refer to a mathematical expression or differential equation, which may describe some empirical data, which are not based or derived from first principles, that is, laws of nature. One may also establish several different models, in contrast to a theory, which cannot be duplicated or improved within its area of validity.

5.1 The course of an influenza epidemic. The propagation of an epidemic is in general a very complex process, often caused by accidental events. The deadly SARS, propagating in various countries worst in China and in vest Canada was caused by a salesman dealing with poultry, who spend the night in an international hotel, and after which the disease spread to various countries through air port terminals etc. Inherently it is not possible to establish a mathematical model for such a series of accidental events. A far better example, are the flu epidemics, which occasionally hit Europe, USA and the rest of the world Here it is possible to establish a (crude) model of how the epidemic will propagate and finally fade out. The model is most adequate for cities, having a large population. This is so because the flu is propagated by drop infection, and to do so it is required that many people are in fairly close contact with each other. We shall make some designations. H(t) = ”Healthy”: The number in the population, which has not been infected yet at time t. S(t) = ”Sick: The number in the population at time t, which has been infected, and still can transfer the infection to others.

Page 10: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 8

R(t) = ”Recovered”. The number in the population at time t, which has been infected, but has now recovered. If N is the size of the population, then in all cases: H(t)+ S(t) + R(t) = N Since the model is based on probability arguments, we shall invent the corresponding fractions.

N

tHth

)()( : The fraction of “healthy” persons.

N

tSts

)()( : The fraction of ”ill” persons.

N

tRtr

)()( : The fraction of ”recovered” persons.

At all times we must have: h(t)+ s(t) + r(t) = 1 As always differentiation with respect to time indicates a velocity or a rate with which a quantity change. If there is at least one that is ”ill”, then h(t) will be a decreasing function of time. The speed with which it decreases will (under the most general assumptions) be proportional to the probability that a healthy encounters an ill. So we have the equation (where a is a constant)

(5.1) )()( tsthadt

dh

Since a person that has become ill, after some time gets healthy (or dies), then the velocity with which they recover must be proportional with the fraction of the ill. (b is a constant)

(5.2) )(tbsdt

dr

To establish a differential equation for s(t),we shall apply the normalization condition:

h(t)+ s(t) + r(t) = 1, Which we differentiate:

dt

dr

dt

dh

dt

ds

dt

dr

dt

ds

dt

dh 0

Inserting the already established expressions for dt

drand

dt

dh

(5.3) )()()( tbststhadt

ds

Page 11: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 9

We may also argue for the equation (5.3), since a person, which is no longer healthy has become ill. So the fraction of the ill increases with that rate )()( tstha , but decreases at the same time proportional with s(t), since an ill eventually recovers (or dies) after a certain period. The three coupled differential equations (5.1) – (5.3) have no known analytic solution, and we must resort to a numerical solution performed by a computer. (The graphs below is made by my own DOS-based program, written in Turbo 7.0 from Borland in 1995) The determination of the constants a and b can for example be taken from empirical data. On the first graph we have rather arbitrarily (to illustrate the capacity of the model) chosen a=0.5 and b=0.33. The choice of b = 0.33 can be argued, because an infected person can only infect others in the time of incubation, which is set to 3 days, so that a third of them can not infect others after one day. On the second graph, we have again chosen a=0.5, but assumed that the time of incubation is 7 days b=0.141 (=1/7). In both cases we see that the number of infected is increased, passing a max until it begins to fall with almost the same pace. Notice that the model assumes that the epidemic can develop freely, and that there are no medical counter measure such as vaccination or isolation of the infected, as it was the case both with the SARS and the Ebola epidemics. In the first case the maximum infected becomes is 8%, whereas in the second case it is 38%. The time of incubation (where an infected person can infect others) is of vital importance. In the first case 58% become infected in all, whereas in the second case it is 96%! If we adjust a, one gets other results of course. The model may be applied to give an estimate of the duration of an epidemic if one, from the start of the epidemic, has gathered sufficient data to estimate a and b.

Page 12: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 10

5.2 Interaction between two animal species. One of the classical mathematical models is the one which describes the interaction between two different species. We shall deal with two different kinds of interaction namely predators and prey, and two species competing on the same access to food. As in the previous case the models build on some general assumptions, which do not take into account the details and statistical deviations. Let us assume that in the woods live foxes and mice. The number of foxes at the time t we denote r(t), while the number of mice is m(t). If there was unlimited access to food for both parties, and if none of the species were prey for the other, then both r(t) and m(t), would develop exponentially, and therefore satisfy the differential equations.

(5.4) )()( tmkdt

dmandtrk

dt

drmr

Now for the foxes their access to food is dependent on the number of mice, and this we can build into the model, by making kr = kr(m) a function of m= m(t), the number of mice. How kr(m) depend on m, we do not know, except that kr(m) must be an increasing function of m. The simplest assumption is that kr(m) is a linear function, such that: (5.5) kr(m) = a∙m - b, a and b are positive constants, which must be determine from the realities behind the model. In a analogous manner one may argue that km = km(r) is a decreasing function r= r(t), of the number of foxes, (where c and d are positive constants). (5.6) km(r)= c - d∙r Inserting in (5.4) we have:

(5.7) mrdcdt

dmandrbma

dt

dr)()(

Notice the structural resemblance with the logistic equation. Both equations would be the logistic equation if we made the swap rm in the first equation and mr in the second equation. The equations (5.7) do not have an analytic solution, but they can be solved numerically. Below is shown a numerical solution fetched from a forest in Sweden, where we haven chosen the initial values (m0, r0) = (9000, 354), and a = 0,00001, b = 0.08, c = 1, d = 0.002.

Page 13: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 11

The two curves represent the foxes and the mice

It is clear that a period having many mice imply a delayed increase in the stock of foxes, and consequently it makes the stock of mice to fall, which eventually makes the stock of foxes to decrease. But then the stock of mice will grow, and the same cycle will be repeated. The two species live in a symbiosis caused by nature. It is notably that even if they are prey and predator neither can survive in the long run without the other. If all the foxes were shot, the number of mice would grow beyond the sustainable amount of food. A situation which could have the result that the mice were exterminated.

Dividing the first differential equation by the last, we have:

(5.8) mrdc

rbma

dm

dr

)(

)(

This equation can however be separated:

(5.9) dmm

bmadr

r

rdc )()(

And if integrated:

(5.10) kmbmadrrcdmm

badrd

r

c)ln()ln()()(

Where k is a constant of integration, which is determined by the initial conditions.

However, the equation (5.10) is a transcendent equation, which cannot be solved, neither with respect r nor m. From (5.10) one may show that both m and r have a max and a min. Instead of showing a graph of r(t) and m(t) in the coordinate system, one could plot the parameter curve (r(t), m(t)). The graph is shown to the left. Here the cyclic character of the solution is clear. The graph to the left is actually not very surprising, but it reflects in a precise way the consequences of some simple assumptions about the interactions between predator and prey.

Page 14: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 12

5.3 Competing species We shall then look into a model where two species are competing about the same limited amount of food. We designate the two populations x and y, so that x(t) is the number of x-individuals At time t and that y(t) is the number of y-individuals at time t. The logistic equation is the equation of development for a population which has available a limited amount of food. So for a start we shall assume a logistic equation for each of the populations.

(5.11) )()( yMyadt

dyandxMxa

dt

dxyyxx

However, the two populations inhibit each other, so we add on the right side an inhibiting term proportional to the size of the other population.

(5.12) )()( xbyMyadt

dyogybxMxa

dt

dxyyyxxx

Before we look at the numerical solutions, we shall make some general considerations based on (5.12). If dx/dt = x’(t)=0, then the x population is constant (is at equilibrium). The same holds for the y-population, so at equilibrium we have the two equations. (5.13) 0)(0)( xbyMyaandybxMxa yyyxxx

Besides the trivial solutions xy MxyorMyx 00 the two equations have the

solutions. (5.13) 00 xbyMandybxM yyxx

or yyxx MxbyandMybx

Each of the two equations exhibit a straight line in the x-y plane. If the two lines intersect each other, then we have a simultaneous equilibrium for the two populations. The determinant for the system of equations is, however:

D = bx by - 1 , so D ≠ 0 bx by ≠1. if bx by = 1 there is no common state of equilibrium for the two populations (other than the trivial ones), and even if there is a common state of equilibrium for the two populations, it is not insured that it is stable. A stable state requires that a small deviation from the equilibrium will lead back to the equilibrium state. Stable and unstable equilibrium may be illustrated by placing a ball at the button of a half sphere, and placing the same ball at the top of same half sphere turned upside down.

Page 15: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 13

Below are shown 4 graphs, where the two lines are drawn for different values of parameters Furthermore the signs for dx/dt and dy/dt marked with arrows. As you can see there is no equilibrium in the first two figures. Any deviation will lead to extermination of one of the species. In figure (5.7) there is a point with common equilibrium, but this equilibrium is not stable. In fig (5.8) however there is a point with stable equilibrium, which can be interpreted in the following way: If we for both species have that the one specie inhibit the other less that it inhibits one self, then there is a possibility for a stable equilibrium.

Page 16: Elementary Matematics differential equation modelsolewitthansen.dk/...differential_equation_models.pdf · 'liihuhqwldo htxdwlrq prghov ,vvxhv wkdw ohdg wr gliihuhqwldo htxdwlrqv ,q

Differential equation models 14

Below is shown examples of a numeric solution of the differential equations. Based on the following values for the parameters

Mx = 10000; ax =0.2; bx =0.8; My = 6000; ay =0.5 ; by =0.5.

Notice that this choice of parameters satisfies the conditions in figure (5.8) To the left is shown a solution, where we have plotted (x(t), y(t)), but with 5 different initial conditions. As you can see all solutions converges to the same state of equilibrium (8400, 1500) . To the right are x(t) and y(t) plotted separately as a function of time. After some rather vivid oscillation in the start, the two populations stabilize after some time in a stable equilibrium.