AMA126 -1- AMA126 Differential and difference equations University of Sheffield, Dept of Applied Mathematics 2007 AMA126 -2- Revision of Integration (Indefinite Integration) When a function f(x) is known we can differentiate it to obtain its derivative df/dx. The reverse process is to obtain the function f(x) from knowledge of its derivative. This process is called integration and it has numerous applications in all areas of sciences. Suppose we differentiate the function y=x2. We obtain dy 2x dx Integration reverses this process and we say that the integral of 2x is x2. Schematically we can regard the process of integration in the following way differentiate x2 2x integrate In reality the situation is a bit more complicated because differentiating any of x 2 7, x 2 3, x 2 0.5 yields 2x. In fact, any function of the form x2+c, where c is a constant, will be the answer to our question since when we differentiate the constant term we obtain zero. Consequently, when we reverse the process of differentiation, we do not know what the original constant term might have been. So we include in our answer an unknown constant, c say, called the constant of integration and we state that the integral of 2x is x2+c. This constant must always be included when finding an indefinite integral. The solution containing the constant c defines a family of curves all being solutions of the integral. If one of these curves is a solution of the integral, they all are. To select between AMA126 -3- them we need more information. This problem defines so called initial conditions, a topic you will meet later when solving differential equations. The indefinite integration is represented by the symbol ∫ known as an integral sign. Accompanying the integral sign is always a term of the form dx, which indicates the independent variable involved in the integration, in this case x. So we write 2 x dx x 2 c ____________________________________________________ Example (a) State the derivative of x3 (b) Hence find the indefinite integral of 3x2 Solution (a) From our knowledge of differentiation, the derivative of x3 is 3x2. (b) Indefinite integration reverses the process of differentiation, and so we write 3x dx x 2 3 c We always include the additional constant of integration when finding indefinite integrals. Note that our answer can be checked by differentiating x3+c to obtain 3x2. More generally, we have the following relationship between derivatives and indefinite integrals: if d F x f x then dx f x dx F x c In the expression ∫ f(x) dx, the function f(x) is referred to as the integrand. When we have calculated ∫ f(x) dx, we say f(x) has been integrated with respect to x to yield F(x)+c. In what follows we are going to discuss some techniques which can be used to evaluate many types of integrals. I. Integration by parts If f and g are differentiable functions, then by the Product Rule d f ( x) g ( x) f ( x) dg ( x) g ( x) df ( x) dx dx dx d f ( x) g ' ( x) f ( x) g ( x) g ( x) f ' ( x) dx or equivalently where the dash means the differentiation of the function with its argument. Integrating both sides of the previous equation gives us AMA126 -4- f ( x) g ' ( x)dx dx f ( x) g ( x)dx g ( x) f ' ( x)dx d The simplest is to perform the first integral on the right side and the integral is f(x)g(x)+C (why???). Since another constant of integration results from the second integral, it is unnecessary to include C in the formula; that is f ( x) g ' ( x)dx f ( x) g ( x) g ( x) f ' ( x)dx If we let u=f(x) and v=g(x), so that du=f′(x)dx and dv=g′(x)dx, then the preceding formula may be written (integration by part) udv uv vdu ______________________________________________________ Example: Find xe 2x dx Solution There are four possible choices for dv, namely dx, xdx, e2xdx or xe2xdx. If we let dv= e2xdx, then the remaining part of the integrand is u; that is u=x. To find v we integrate dv to obtain v=e2x/2. Note that a constant of integration is not added at this stage of the solution. Since u=x we see that du=dx. For ease of reference it is convenient to display these expressions as follows ux dv e 2 x dx du dx v 1 2x e 2 Substituting these expressions in the definition equation, we obtain xe 2x 1 1 dx x e 2 x e 2 x dx 2 2 The integral on the right hand side may be found using the integrals of exponential functions (see in the table below). This gives us xe 2x 1 1 dx x e 2 x e 2 x C 2 4 AMA126 -5- It takes considerable practice to become proficient in making a suitable choice for dv. To illustrate, if we had chosen dv=xdx, then it would have been necessary to let u=e2x, giving us u e2x dv xdx du 2e 2 x dx v 1 2 x 2 Integrating by parts we obtain xe 2x dx 1 2 2x x e x 2 e 2 x dx 2 Since the exponent associated with x has increased, the integral on the right is more complicated than the given integral. This indicates an incorrect choice of dv. ______________________________________________________ II. Trigonometric integrals In many cases evaluating an integral we can meet trigonometric functions. For example, integrals of the type ∫sinnxdx require new method of solving. If n is an odd positive integer, we begin by writing sin n xdx sin n 1 x sin xdx Since the integer n-1 is even, we may then use the fact that sin2x=1-cos2x to obtain a form which is easy to integrate. ______________________________________________________ Example Evaluate ∫sin5xdx. Solution As discussed earlier we have sin xdx sin x sin xdx (sin (1 2 cos x cos x) sin xdx 5 4 2 2 x) 2 sin xdx (1 cos 2 x) 2 sin xdx 4 We next employ the method of substitution, letting u=cosx and du=-sinxdx. Thus sin 5 xdx (1 2 cos 2 x cos 4 x)( sin x)dx (1 2u 2 u 4 )du 2 1 2 1 u u 3 u 5 C cos x cos 3 x cos 5 x C 3 5 3 5 AMA126 -6- _____________________________________________________ A similar technique can be employed for odd powers of cos x, specifically, we write cos n xdx cos n 1 x cos xdx and use the fact that cos2x=1-sin2x in order to obtain an integrable form. If the integrand is sinnx or cosnx and n is even, then the half-angle formulas 1 cos 2 x 2 sin 2 x or cos 2 x 1 cos 2 x 2 may be used to simplify the integrand. ______________________________________________________ Example Evaluate ∫sin4xdx Solution 1 1 cos 2 x 2 sin xdx (sin x) dx 2 dx 4 (1 2 cos 2 x cos 2 x)dx 2 4 2 2 We apply a half-angle formula again and write cos 2 2 x 1 1 1 (1 cos 4 x) cos 4 x 2 2 2 Substituting in the last integral and simplifying gives us sin 4 xdx 1 3 1 3 1 1 2 cos 2 x cos 4 x dx x sin 2 x sin 4 x C 4 2 2 8 4 32 _____________________________________________________ Integrals of the form ∫sinmxcosnxdx where m and n are positive integers may be found by using variations of the previous techniques. If m and n are both even, then half-angle formulas should be employed first. In n is odd, we can write sin m x cos n xdx sin m x cos n 1 x cos xdx and express cosn-1x in terms of sinx by using the identity cos2x=1-sin2x. The substitution u=sinx then leads to an integrand which can be handled easily. A similar technique can be used if m is odd. III. Trigonometric substitutions AMA126 -7- If an integrand contains the expression substitution x=asinθ leads to a 2 x 2 where a>0, then the trigonometric a 2 x 2 a 2 a 2 sin 2 a 2 1 sin 2 a 2 cos 2 a | cos | When making this substitution or the other trigonometric substitutions in the next examples, we shall assume that θ is in the range of the corresponding inverse trigonometric function. Thus, for the sine substitution above –π/2≤θ≤π/2. Consequently cosθ≥0 and a 2 x 2 a cos . Of course, if make the further restriction –π/2<θ<π/2. a 2 x 2 occurs in a denominator we ______________________________________________________ Example Evaluate 1 x 2 a 2 x 2 dx, a 0 Solution Let x=asinθ , where –π/2<θ<π/2. It follows that a 2 x 2 a 2 a 2 sin 2 a 2 1 sin 2 a cos Since x=asinθ, we have dx=acosθdθ. Substituting in the given integral x 1 2 a x 2 2 dx 1 (a sin )a cos 2 2 a cos d 1 1 1 d 2 cot C 2 2 a sin a It is now necessary to return to the original variable of integration x. A simple method of doing so is to use a geometrical approach. If 0<θ<π/2, then since sinθ=x/a, we may interpret θ as an acute angle of a triangle having opposite side and hypotenuse of lengths x and a, respectively. The length the Pythagorean Theorem. a 2 x 2 of the adjacent side is calculated by means of AMA126 -8- Referring to the triangle we see that a2 x2 x cot It can be shown that this formula is also valid if –π/2<θ<0. Thus the above figure can be used whether θ is positive or negative. Substituting the new form of cotθ in the result obtained for the integral, we have x 1 2 a 2 x2 dx 1 a2 a2 x2 a2 x2 C C x a2 x ______________________________________________________ If an integrand contains a 2 x 2 , where a>0, then the substitution x=atanθ will eliminate the radical sign. When using this substitution it will be assumed that θ is in the range of the inverse tangent function; that is –π/2<θ<π/2. After making this substitution and evaluating the resulting trigonometric integral, it is necessary to return to the original variable, x. The preceding formulas show that tan x a and sec a2 x2 a For integrands containing x 2 a 2 we substitute x=asecθ, where θ is chosen in the range of the inverse secant function; that is either 0≤θ≤π/2 or π≤θ<3π/2. After evaluating the integral, we have to return to the original variable and we use sec x a and tan x2 a2 a ______________________________________________________ AMA126 -9- Example Evaluate x2 9 dx x Solution Let us substitute as follows x 3 sec , dx 3 sec tan d Consequently x 2 9 9 sec 2 9 3 sec 2 1 3 tan and therefore x2 9 3 tan 2 2 x dx 3 sec 3 sec tan d 3 tan d 3 sec 1d 3tan C Since secθ=x/3 we may refer to the changing rule into the old variable and we write x2 9 x2 9 x x dx 3 sec 1 C x 2 9 3 sec 1 C x 3 3 3 _____________________________________________________ III. Partial Fractions It is easy to verify that 2 1 1 x 1 x 1 x 1 2 The expression on the right side of the equation is called the partial fraction decomposition of the expression on the left side. This decomposition may be used to find the indefinite integral of the expression on the left side. We merely integrate each of the fractions which make up the decomposition independently, obtaining x 2 2 1 1 x 1 dx dx dx ln | x 1 | ln | x 1 | C ln C x 1 x 1 x 1 1 It is theoretically possible to write any rational expression f(x)/g(x) as a sum of rational expressions whose denominators involve powers of polynomials of degree not greater than two. More specifically, if f(x) and g(x) are polynomials and the degree of f(x) is less than the degree of g(x), then it follows from a theorem in algebra that AMA126 - 10 - f ( x) F1 F2 Fk g ( x) where each of Fi has one of the forms A px q m or ax Cx D 2 bx c n for some non-negative integers m and n, and when ax2+bx+c is irreductible, in the sense that this quadratic expression has no real roots, that is b2-4ac<0. To find the fraction decomposition of a rational expression f(x)/g(x) it is essential that f(x) have lower degree than g(x). If this is not the case, then long division should be employed to arrive at such expression. For example, given x 3 6 x 2 5x 3 x2 1 we obtain, by long division, x 3 6 x 2 5x 3 6x 9 x6 2 2 x 1 x 1 The partial fraction decomposition is then found for the last term in the right side. In order to obtain the decomposition of a rational expression of the form f(x)/g(x), we begin by expressing the denominator g(x) as a product of factors px+q or irreductible quadratic factors ax2+bx+c. Repeated factors are then collected so that g(x) is a product of different factors of the form (px+q)m or (ax2+bx+c)n, where m and n are non-negative integers and the quadratic forms are irreductible. We then apply the following rules Rule 1. For each factor of the form (px+q)m where m≥1, the partial fraction decomposition contains a sum of m partial fractions of the form Am A1 A2 2 px q px q px q m where each of Ai is a real number. Rule 2. For each of the factor of the form (ax2+bx+c)n where n≥1 and b2-4ac<0, the partial fraction decomposition contains n partial fractions of the form AMA126 - 11 - A1 x B1 A2 x B2 2 ax bx c ax 2 bx c 2 An x Bn ax 2 bx c n where each of Ai and Bi are real numbers. _____________________________________________________ Example Evaluate 3x 3 18 x 2 29 x 4 x 1x 23 dx Solution By Rule 1, there is a partial fraction of the form A/(x+1) corresponding to the factor x+1 in the denominator of the integrand. For the factor (x-2)3 we apply Rule 1 (with m=3), obtaining a sum of three partial fractions B/(x-2), C/(x-2)2, and D/(x-2)3. Consequently, the partial fraction decomposition has the form 3x 3 18 x 2 29 x 4 x 1x 2 3 A B C D 2 x 1 x 2 x 2 x 2 3 Multiplying both sides by (x+1)(x-2)3 gives us 3x 3 18 x 2 29 x 4 A x 2 Bx 1x 2 C x 1x 2 Dx 1 3 2 Two of the unknown constants may be determined easily. If we let x=2 then 24-72+58-4=3D, 6=3D, and D=2 Similarly, letting x=-1 we obtain -3-18-29-4=-27A, -54=-27A, and A=2 The remaining constants may be found by comparing the coefficients. If the right side of the decomposition is expanded and like powers of x collected, we see that the coefficient of x3 is A+B. This must equal the coefficient of x3 on the left, that is A+B=3 Since A=2, it follows that B=1. Finally, we compare the constant terms by letting x=0. This gives us -4=-8A+4B-2C+D Substituting the values we have already found for A, B and D leads to AMA126 - 12 - -4=-16+4-2C+2 which has the solution C=-3. The partial fraction decomposition is, therefore 3x3 18 x 2 29 x 4 2 1 3 2 3 2 x 1 x 2 x 2 x 23 x 1x 2 To find the given integral we integrate each of the partial fractions on the right side of the last equation. This gives us 3 1 E x 2 ( x 2) 2 ______________________________________________________ Obviously, there are many characteristic types of indefinite integrals with their own rules. To see them all, please consult any book on calculus. 2 ln | x 1 | ln | x 2 | Differential equations Definition: A differential equation is an equation which involves derivatives or differentials. Since the equations we are going to study contain only one variable, these equations are called ordinary differential equations. The primary objective of this lecture is to develop techniques for solving certain basic types of ordinary differential equations. Introduction An equation of the form F x,y,y' ,y' ' ,... y ( n ) 0 , 2.1 where F is a function of n+2 variables, y is a function of x, and y(k) denotes the k-th derivative of y with respect to x, is called an ordinary differential equation of order n. The following are examples of ordinary differential equations of orders 1, 2, 3, and 4, respectively: y' 2 x 3 d2y dy x 2 15 y 0 2 dx dx y' ' '4 x 2 y' '5 4 xy xe x 2 d4y dy 4 1 x 3 dx dx AMA126 - 13 - If, in (2.1), F is a polynomial function, then by definition the degree of the differential equation is the greatest exponent associated with the highest order derivative y(n). The degrees of the preceding differential equations are 1, 1, 4, and 2, respectively. If a function f has the property that when f(x) is substituted for y in a differential equation, the resulting expression is an identity for all x in some interval, then f(x) (or simply f) is called a solution of the differential equation. For example, if C is any real number, then a solution of y’=2x is f x x 2 C because substitution of f(x) for y leads to the identity 2x=2x. We call x2+C the general solution of y’=2x, since every solution has this form. ___________________________________________ Example If C1 and C2 are any real numbers, prove that f x C1e 5 x C 2 e 5 x is a solution of y’’-25y=0. Solution Since f ' x 5C1e 5 x 5C2 e 5 x f ' ' x 25C1e 5 x 25C2 e 5 x 25 f x we have f″(x)-25f(x)=0. This shows that f(x) is a solution of the equation y″-25y=0. The solution given in the above Example is called the general solution of y″-25y=0. Observe that the differential equation is of the order 2 and the general solution contains two arbitrary parameters C1 and C2 (for connections to integrals, see why these parameters arise in the recap about integrals). It can be shown that the general solution of the n-th order differential equation contains n independent parameters C1, C2, …, Cn. A particular solution is obtained by assigning specific values to the parameters. ___________________________________________ Example Find the particular solution of y’=2x which satisfies the condition that y=5 if x=2. Solution Let us write the general solution of y’=2x in the form y=x2+C. If the given condition is to be satisfied, then necessarily 5=4+C or C=1. Hence the desired particular solution is y=x2+1. AMA126 - 14 - ___________________________________________ Conditions of the type stated in the previous Example are called boundary conditions for the differential equation. If the general solution contains one parameter, one boundary condition is sufficient to find the particular solution. If, as in the first Example, the general solution contains two parameters, then two boundary conditions are needed for particular solutions. Similar statements hold if more than two parameters are involved. The solutions we have considered express y explicitly in terms of x. Solutions of certain differential equations are stated implicitly. In this case, implicit differentiation is used to check the solution, as illustrated in the following example ___________________________________________ Example Show that x3+x2y-2y3=C is an implicit solution of x 2 6 y 2 y'3x 2 2 xy 0 Solution If the first equation is satisfied by y=f(x), then differentiating implicitly, 3x 2 2 xy x 2 y'6 y 2 y' 0 or x 2 6 y 2 y'3x 2 2 xy 0 Thus y=f(x) satisfies the differential equation. ___________________________________________ The simplest type of differential equation is one which can be written in the form M x N y y ' 0 2.2 where M and N are continuous functions. If y=f(x) is a solution of the equation (2.2), then M x N f x f ' x 0 If f′(x) is a continuous function, then indefinite integration leads to M x dx N f x f ' x dx C or equivalently, M x dx N y dy C The last equation is an (implicit) solution of (2.2). A device which is useful for remembering this method of solution is to write equation (2.2) as AMA126 - 15 - M x N y dy 0 dx and then change to the following differential form M xdx N y dy 0 2.3 The solution is then found by formally integrating each term. The differential equation (2.2) is said to be separable, since the variables x and y may be separated as indicated in (2.3). ___________________________________________ Example Solve the differential equation 2 xy 6 x x 2 4 y' 0. Solution The given equation may be written as 2 x y 3 x 2 4 dy 0. dx Assuming that (y+3)(x2-4)≠0, we may divide both sides by this product and express the equation in the differential form (2.3) as follows 2x 1 dx dy 0. y3 x 4 2 Thus the given differential equation is separable, and integration gives us ln x 2 4 ln y 3 C1 or ln x 2 4 y 3 C1 This may also be written as x 2 4 y 3 e C1 C 2 . It can be shown, furthermore, that the solution is x 2 4 y 3 C for every nonzero C. In explicit form, AMA126 y - 16 - C 3. x 4 2 Since it was assumed that (y+3)(x2-4)≠0, the cases x=±2 and y= -3 require special attention. Direct substitution shows that y= -3 is a solution of the given differential equation; however, y′ is undefined if x=±2. Consequently, the above solution given in explicit form is the solution if C is any real number. ___________________________________________ Example Prove that y=ex(C1cos x+C2sin x) is a solution of the differential equation y ' '2 y '2 y 0 Example Solve the differential equation x 2 y' yx 2 y Sometimes a substitution is necessary to turn an equation into separable variables, e.g. use the substitution z=2x+y to solve the ordinary differential equation dy tan( 2 x y ) 2 dx Obviously, first we will need to see how the new variable (and its derivative) will look like. For this we differentiate the new variable with respect to x dy dz 2 dx dx AMA126 - 17 - So the original differential equation is transformed into dz tan z dx which now can be solved by variable separation. Integrating we have dz tan z dx or cos z sin z dz dx and the solution can be found solving the following chain ln(sin z ) x C ln(sin[ 2 x y ]) x C sin( 2 x y ) Ae x 2 x y sin 1 ( Ae x ) y sin 1 ( Ae x ) 2 x A very important case (i.e. with many applications in various fields) is the differential equation dy ky dt This equation can be solved by variable separation. Supposing that y≠0, we have dy kdt y ln y kt C y e C kt Ae kt The above equation is an example of an ordinary differential equation with constant coefficients. This type of equation will play a very important role in the second chapter of this course (population dynamics). Let us discuss some of the properties of this differential equation 1. Set t=0, then y(0)=A, so y(t)=y(0)ekt 2. If k>0, we have an exponential growth, if k<0 we have an exponential decay 3. Half-life (when k<0) AMA126 - 18 - We set ek=2-1/T, in other words k 1 ln 2 ln 2 or T 0 T k then y (t ) y (0)2 t T y (T ) y (0)2 1 y (2T ) y (0)2 2 y (0) 2 y (0) y (T ) 4 2 T is called the “half-life” and it is widely used in sciences and engineering (e.g. radioactive decay) The snowfall problem: Before noon snow starts to fall at a steady rate. At noon a snow plough begins ploughing forward along a straight road of constant width. It shifts a constant volume of snow per unit time. It clears a two mile stretch by one o’clock and a further one mile by two o’clock. At what time did the snow begin to fall? Solution Let the snow begin to fall at time T. Then the depth of snow at time t (≥T) is c(t-T). Let the snow plough advance from x to x+Δx in the time interval t to t+Δt. The volume of snow removed in this time interval is ωc(t-T)Δx, where ω is the width of the plough. Thus the rate of snow removal is c(t T ) x dx c(t T ) t dt which is a constant. Thus we have (t-T)dx/dt=C, or dx k dt t T (t T ) This differential equation can be solved by separating the variables as x k dt k ln( t T ) A t T which can be rewritten as AMA126 - 19 - xA k x A 1k x A k t T exp e e k x t T Ba ln( t T ) where B=e-A/k and a=e1/k. We have three unknown constants (T, B, a) which must be determined. We have to use the initial conditions, i.e. x 0 at t 0 x 2 at t 1 x 3 at t 2 Using these conditions we have 0 T B 2 1 T Ba 2 T Ba 3 From the first equation we have B=-T, which introduced back into the remaining two equations yields 1 T (1 a 2 ) 2 T (1 a 3 ) Calculating the ratio between these two expressions we have 1 a3 1 a a2 2 1 a 1 a2 2 2a 1 a a 2 a2 a 1 0 1 1 4 1 5 2 2 1 2 5 5 3 5 a2 4 2 a AMA126 - 20 - Having this constant, we can determine T as 1 2 2 2 5 1 T 2 1 a 2 (3 5 ) 1 5 5 1 5 1 2( 5 1) ( 5 1) 4 2 Calculating this ratio, we obtain T= –0.618 hours=-37.1 min. Accordingly, the snow started to fall at 11.23 am. HOMOGENEOUS DIFFERENTIAL EQUATIONS A function f of two variables is said to be homogeneous of degree n if f tx,ty t n f x, y 3.1 for every t>0 such that (tx, ty) is in the domain of f. For example, if f x, y 2 x 4 x 2 y 2 5 xy3 then f is homogeneous of degree 4, since f tx,ty 2tx tx ty 5txty 4 2 2 3 t 4 2 x 4 x 2 y 2 5 xy3 t 4 f x, y Similarly, if f x, y x 1 y e 2 2 x y then f is homogeneous of degree -2, since tx 1 f tx,ty 2 2 e ty t 2 f x, y 2 2 t x t y A homogeneous differential equation is an equation which can be written in the form Px, y dx Qx, y dy 0 3.2 where P and Q are homogeneous functions of the same degree. Equations of this type can be transformed into separable equations by means of substitutions AMA126 - 21 - y xv, where v vx 3.3 and dy vdx xdv Thus, substitution of xv for y in (3.2) yields Px, xvdx Qx, xvvdx xdv 0 If P and Q are homogeneous functions of degree n, then Px, xvdx x n P1,v and Qx, xv x n Q1,v Substituting in the preceding differential equation and dividing both sides by x n we obtain P1,v dx Q1,v vdx xdv 0 This equation can be written in the separable form 1 Q1,v dx dv 0 x P1,v vQ1,v 3.4 provided non-zero denominators occur. We have proved that if y=xv is a solution of (3.2), then v is a solution of (3.4). Conversely, if v is a solution of (3.4), then reversing our argument shows that y=vx is a solution of (3.2). It is not advisable to memorize the final form of (3.4). Instead, remember the substitution y=xv which is used to simplify the homogeneous equation. ___________________________________________ Example Solve the differential equation y 2 xy dx x 2 dy 0. Solution If P(x,y)=y2-xy and Q(x,y)=x2, then the functions P and Q are both homogeneous of degree 2. Hence the differential equation is homogeneous and we substitute y xv, dy vdx xdv. This leads to the following chain of equations AMA126 - 22 - x v x v dx x vdx xdv 0 x v v dx x vdx xdv 0 v v dx vdx xdv 0 2 2 2 2 2 2 2 2 v 2 dx xdv 0 1 1 dx 2 dv 0 x v Integrating each term gives us ln x 1 x x C1 ln | x | C1 y v y ln | x | C1 Example Solve the differential equation 2 xydx y 2 x 2 dy 0 LINEAR DIFFERENTIAL EQUATIONS OF THE FIRST ORDER A first-order linear differential equation is an equation of the form y' P( x) y Q( x) 3.5 where P and Q are continuous functions. If Q(x)=0 for all x, then equation (3.5) is separable and we may write y' P( x) y provided y≠0. Integrating, we obtain ln y P( x)dx ln C . We have expressed the constant of integration as ln|C| in order to change the form of the last equation as follows: AMA126 - 23 - ln y ln C P( x)dx ln y P( x)dx C P ( x ) dx y e C ye P ( x ) dx C We next observe that d P ( x ) dx P ( x ) dx P( x) ye P ( x ) dx ye y ' e dx e P ( x ) dx y' yP( x). Consequently, if we multiply both sides of (3.5) by e∫P(x)dx, then the resulting equation may be written as d P ( x ) dx P ( x ) dx . ye Q ( x ) e dx This gives us the following (implicit) solution of (3.5) ye P ( x ) dx Q ( x )e P ( x ) dx D. 3.6 Solving this equation for y leads to an explicit solution. The expression e∫P(x)dx is called an integrating factor of (3.5). We have shown that multiplications of both sides if (3.5) by this expression leads to an equation which has the solution (3.6). ___________________________________________ Example Solve the differential equation x 2 y '5 xy 3 x 5 0 where x≠0. Solution In order to find the integrating factor we begin by expressing the given differential equation in the “standardized” form (3.5), where the coefficient of y′ is 1. Thus, dividing both sides by x2 we obtain AMA126 y ' - 24 - 5 y 3x 3 x which has the form (3.5) with P(x)=5/x and Q(x)=- 3x3. From the preceding discussion, the required integrating factor is e P ( x ) dx 5 e5 ln x eln x x . 5 If x>0 then |x|5=x5, whereas if x<0 then |x|5=-x5. In either case, multiplying both sides of the standardized form by |x|5 gives us x 5 y '5 x 4 y 3x 8 or d 5 ( x y ) 3 x 8 . dx Thus a solution is x9 x4 C . C or y 5 3 3 x ___________________________________________ x5 y A generalization of the (3.5) is the Bernoulli equation y ' P( x) y Q( x) y n , 3.7 where n≠0. Evidently y=0 is a solution. If y≠0 we may divide both sides by yn, obtaining y n y ' P( x) y1 n Q( x). 3.8 If we let w=y 1-n, then w' dw (1 n) y n y ' dx and hence y n y' 1 w'. 1 n Replacing y-n y′ in (3.8) by the last expression gives us AMA126 - 25 - 1 w' P( x) w Q( x). 1 n This first-order linear diff. eq. may be solved for w using the integrating factor technique. After w was found, the solution (3.7) is given by y 1-n=w (and y=0). __________________________________________ Example Solve the differential equation y ' 2y x6 y 3. x Solution The equation has the Bernoulli form (3.6) with n=3. If, as in the previous discussion, we multiply both sides by y-3 and substitute w=y1-n=y-2 we obtain 2 x6 2 xy 1 2w w' x6 2 x 4w w' 2 x 6 x y 3 y ' Since the integrating factor for the last equation is e ( 4 / x ) dx e 4 ln x eln x 4 x 4 x4 supposing that x>0 (in fact it can be shown that considering x<0, eventually we would obtain the same result). Now we can write x 4 w'4 x 5 w 2 x 2 . Consequently x4w 2 x3 2 x7 C or w Cx 4 . 3 3 Finally, since w=y-2, the solution of the given equation is AMA126 y 2 - 26 - 2x 7 2x 7 Cx 4 or Cx 4 y 2 1 3 3 ___________________________________________ Differential equations are indispensable in sciences (mathematics, physics, chemistry, engineering, biology, etc). The application of the theory of differential equations for physical problems will be solved in other modules and later in this module for population dynamics. Example Solve the differential equations xy x y e x y y y 2 e x Linear differential equations of the second order If f1, f2, … , fn and k are functions of one variable which have the same domain, then an equation of the form y n f 1 x y n 1 f n 1 x y ' f n x y k x 4.1 is called a linear differential equation of order n. If k(x)=0 for all x, the equation is said to be homogeneous. Notice that this meaning of the word homogeneous is different from that we met earlier. If k(x)≠0 for some x, then the equation (4.1) is said to be nonhomogeneous. We shall restrict our work to second-order equations in which f1 and f2 are constant functions. First we are going to discuss the homogeneous case. The general second-order homogeneous differential equation with constant coefficients has the form ay ' 'by 'cy 0 4.2 where a, b and c are constants. Before attempting to find particular solutions let us establish the following result. Theorem: (the superposition principle) If y=f(x) and y=g(x) are solutions of the differential equation ay″+by′+cy=0, then y C1 f ( x) C2 g ( x) 4.3 AMA126 - 27 - is a solution for all real numbers C1 and C2. Proof: By hypothesis af ' ' ( x) bf ' ( x) cf ( x) 0 ag ' ' ( x) bg ' ( x) cg ( x) 0 If we multiply the first of these equations by C1, the second by C2, and add, the result is aC1 f ' ' ( x) C2 g ' ' ( x) bC1 f ' ( x) C2 g ' ( x) cC1 f ( x) C2 g ( x) 0 Thus C1f(x)+C2g(x) is a solution. It can be shown that if the solutions f and g in above Theorem have the property that f(x)≠Cg(x) for all real numbers C, and if g(x) is not identically 0, then y=C1f(x)+C2g(x) is a general solution of ay″+by′+cy=0. Thus, to determine the general solution it is sufficient to find two such functions f and g and employ Eq. (4.3). In our search for solution of (4.2) we shall use y=Aemx as a trial solution, where A is an arbitrary constant and we need to find m. Then dy Ame mx ; dx d2y Am 2 e mx 2 dx Substituting in Eq. (4.2) gives am 2 bm c Ae mx 0 or, since emx≠0 and we are interested in non-trivial solutions (A≠0) am 2 bm c 0 4.4 The equation (4.4) is called the auxiliary equation of eq. (4.2). It can be obtained from this differential equation by replacing y″ by m2, y′ by m and y by 1. In simple cases, the roots of the auxiliary equation can be found by factoring. If the factorisation is not obvious, then applying the quadratic formula, we see that the roots of the auxiliary equation are given by m b b 2 4ac 2a 4.5 AMA126 - 28 - According to the sign of b2-4ac in eq. (4.5), we could have three different cases (i) (ii) (iii) Eq. (4.4) has distinct real roots (b2-4ac>0) Eq. (4.4) has distinct complex roots (b2-4ac<0) (see later for this case) Eq. (4.4) has repeated real roots (b2-4ac=0) Theorem 1: If the roots m1 and m2 of the auxiliary equation are real and unequal, then the general solution of ay″+by′+cy=0 is y C1e m1x C 2 e m2 x 4.6 ___________________________________________ Example Solve the differential equation y″+10y′+16y=0 Solution The auxiliary equation is m 2 10m 16 0 or (m 8)(m 2) 0 which means that m1=-8 and m2=-2. Since the roots of the auxiliary equations are real and unequal, it follows from Theorem 1 that the general solution is y C1e 8 x C 2 e 2 x with C1 and C2 two arbitrary constants. To find the two constants we need two boundary (or initial) conditions. For example, we may give two points the solution passes through or one point and the gradient for some value of x, or two gradients. In this case, if y=0 and dy/dx=1 when x=0, using the general solution given above we have C1 C 2 0 8C1 2C 2 1 which eventually will lead to C1=-1/6 and C2=1/6. So, the final form of the solution is y 1 e 8 x e 2 x 6 ________________________________________________ Theorem 2: If the auxiliary equation has a double root m, then the solution of the equation ay″+by′+cy=0 is AMA126 - 29 - y C1e mx C2 xemx e mx C1 C2 x 4.7 Proof: Using (4.5) with b2-4ac=0, we obtain m=-b/2a or 2am+b=0. Since m satisfies the auxiliary equation, y=emx is a solution of the differential equation. According to the remark following the proof of Theorem (4.3), it is sufficient to show that y=xemx is also a solution. Substitution of xemx for y in ay″+by′+cy=0 gives us am a 2me mx m 2 xemx b mxemx e mx cxemx 2 bm c xemx 2am b e mx 0 xemx 0e mx 0 which is what we wished to show. ________________________________________________ Example Solve the differential equation y″-6y′+9y=0 Solution The auxiliary equation is m2-6m+9=0, or equivalently (m-3)2=0, has a double root 3. Hence by Theorem (4.7), the general solution is y C1e 3 x C 2 xe3 x e 3 x C1 C 2 x Example: Solve the differential equation: y 5 y 6 y 0 Solution The final case to consider is that in which the roots of the auxiliary equation are complex numbers. For many of you the notion of complex numbers might sound a bit strange but it is included in one of the module (SOM104) which runs parallel with this lecture. The second case when deciding the nature of solution for a second order homogeneous differential equation corresponds to the case when b2-4ac<0. In this case the auxiliary equation is said to have complex roots. AMA126 - 30 - Complex numbers may be represented by expressions of the form a+ib, where a and b are real numbers, and i is a symbol which may be manipulated in the same manner as a real number, but has the additional property that i2=-1. Two complex numbers a+ib and c+id are said to be equal, and we write a+ib=c+id, if and only if a=c and b=d. Operations of addition, subtraction, multiplication and division are defined just as in the case of real numbers; in the case of complex numbers all letters denote real numbers, with the additional stipulation that whenever i2 occurs, it may be replaced by –1. For example, the formulas for addition and multiplication of two complex numbers a+ib and c+id are a ib c id a c ib d a ib c id ac bd iad bc We may regard the real numbers as a subset of the complex numbers by identifying the real number a with the complex number a+i0. A complex number of the form 0+ib is called an imaginary number. Complex numbers are often required for solving equations of the form f(x)=0, where f(x) is a polynomial. For example, if only real numbers are allowed, then the equation x2=-4 has no solutions. However, if complex numbers are allowed, then the equation has a solution 2i, since 2i 2 2 2 i 2 4 1 4 Similarly, -2i is a solution of the equation x2=-4. Since i2=-1, we sometimes use the symbol √(-1) in place of i and write 13 i 13 , 2 25 2 i 25 2 5i and so on. A quadratic equation ax2+bx+c=0, where a, b and c are real numbers and a≠0, has roots given by the quadratic formula x b b 2 4ac . 2a If b2-4ac<0, then the roots are complex numbers. To illustrate, if we apply the quadratic formula to the equation x2-4x+13=0 we obtain AMA126 x - 31 - 4 16 52 4 36 4 6i 2 3i 2 2 2 Thus the equation has two complex roots 2+3i and 2-3i. The complex number a-bi is called the conjugate of the complex number a+bi. We see from the quadratic formula that if a quadratic equation with real coefficients has complex roots, then they must be conjugate complex numbers. It follows from the previous discussion that if the auxiliary equation am2+bm+c=0 has complex roots, then they are of the form z1 s it z 2 s it and where s and t are real numbers. We may anticipate, from Theorem (4.6), that the general solution of the differential equation ay″+by′+cy=0 is y C1e z1x C2 e z2 x C1esit x C2 esit x 4.8 In order to handle such complex exponents it is necessary to extend some of the concepts of calculus to include functions whose domain includes complex numbers. Since a complete development is beyond the scope of our work, we shall merely outline the main ideas. The Euler’s Theorem For every complex number e iz cos z i sin z It can be shown that the Laws of Exponents are true for complex numbers. In addition, formulas for derivatives developed earlier can be extended to functions of a complex variable z. One such formula is dekz/dz=kekz, where k is a complex number. Reminder: Laws of exponents a m a n a mn am a mn n a a m n m a mn am a m b b (ab) m a m b m AMA126 - 32 - It can be proved that the general solution of ay″+by′+c=0, where the roots of the auxiliary equation are complex numbers s±ti, is given by Eq. (4.8). The form of this solution may be changed as follows: y C1e z1x C2 e z2 x C1e s it x C2 e s it x C1e sxtxi C2 e sxtxi C1e sx e txi C2 e sx e txi 4.9 e sx C1e itx C2 e itx This can be further simplified by using Euler’s Formula. Specifically, we see from (4.8) that eitx cos tx i sin tx e itx cos tx i sin tx from which it follows that cos tx e itx e itx e itx e itx ; sin tx 2 2i 4.10 If we let C1=C2=1/2 in (4.9) and use (4.10) we obtain the particular solution y=esx costx of ay″+by′+cy=0. Letting C1= - i/2 and C2=i/2 gives us the particular solution y=esx sintx. This is a particular proof of the next theorem. ________________________________________________ Example: Evaluate e i 1 ________________________________________________ Theorem If the auxiliary equation am2+bm+c=0 has distinct complex roots s±ti, then the general solution of ay″+by′+cy=0 is y e sx (C1 cos tx C2 sin tx) 4.11 ________________________________________________ Example Solve the differential equation y ' '10 y '41 y 0 Solution AMA126 - 33 - The roots of the auxiliary equation m2-10m+41=0 are m 10 100 164 10 64 10 8i 5 4i 2 2 2 Hence by Theorem (4.11), the general solution of the differential equation is y e5 x C1 cos 4 x C2 sin 4 x ________________________________________________ Example Find the particular solution of the differential equation 2y″-3y′+2y=0 which satisfies the boundary condition y=0 and y′=2 when x=0. Solution The roots of the auxiliary equation 2m2-3m+2=0 are m 3 9 16 3 7 3 i 7 4 4 4 According to (4.11), the solution of the given differential equation can be written as 3x 7 7 y e 4 C1 cos x C 2 sin x 4 4 This solution contains two constants which can be determined using the boundary conditions. It is obvious that y(0)=C1=0. In order to use the second boundary condition we have differentiate the solution y(x) with respect to x 3x 3x 3 7 7 7 7 7 7 y ' e 4 C1 cos x C 2 sin x e 4 C1 sin x C 2 cos x 4 4 4 4 4 4 4 Taking into account that C1=0, we obtain that y ' (0) 7 C2 2 4 Solving this equation for C2, we obtain that C2 8 8 7 7 7 The final form of the solution will be AMA126 - 34 3x 8 7 4 7 y e sin x 7 4 Example: Solve the differential equation: y 6 y 13 y 0; y (0) 2, y (0) 3 ________________________________________________ A special second order homogeneous differential is the Euler-Cauchy differential equation: x 2 y bxy cy 0 where a and b are constants. Although this equation does not seem to be an equation with constant coefficients, it can be reduced to that form using a new variable x et or t ln | x | Since we changed the variable, we have to change y′ and y″, as well. To do so, we use the chain rule : dy dy dt dy 1 dy t e dx dt dx dt x dt 2 2 d 2 y dy d 2t d 2 y dt dy 1 d 2 y 1 2 t dy 2t d y e e dx 2 dt dx 2 dt 2 dx dt x 2 dt 2 x 2 dt dt 2 Introducing all derivatives back into the original equation, we have d 2 y 2t dy 2t dy e e e 2t e be t e t cy 0 2 dt dt dt d2y dy (b 1) cy 0 2 dt dt 2t AMA126 - 35 - which now is a second order homogeneous differential equation with constant coefficients. Therefore, we use the previous results to solve this equation. The auxiliary equation is m 2 (b 1)m c 0 and the solution of the Euler-Cauchy differential equation can be found according to the nature of the roots of the auxiliary equation. a. Real and distinct roots (m1 and m2) y A e m1t Be m2t Ae m1 ln|x| Be m2 ln|x| A | x |m1 B | x |m2 b. Real but equal roots y ( A Bt )e mt ( A B ln | x |)e m ln| x| ( A B ln | x |) | x | m c. Complex roots (m12=α±iβ) y e t (C1 cos t C2 sin t ) e ln|x| (C1 cos ln | x | C2 sin ln | x |) | x | (C1 cos ln | x | C2 sin ln | x |) Example Solve the differential equation x 2 y xy y 0 with Solution y(1) 1, y(e) 0 AMA126 - 36 - Non-homogeneous linear differential equations In this section we shall consider second-order non-homogeneous linear differential equations with constant coefficients, that is, equations of the form ay ' 'by 'cy k ( x) 5.1 where a, b and c are constants and the function k(x) is continuous. The function k(x) is often called the forcing term or the source term. It is convenient to use the differential operator symbol D and D2 where if y=f(x), then Dy y' f ' ( x), D 2 y y' ' f ' ' ( x) We shall also employ the linear differential operator L aD 2 bD c where by definition L( y) aD 2 bD c y aD 2 y bDy cy ay' 'by'cy. Using this notation, equation (5.1) can be written in the compact form L(y)=k(x). It is easy to verify that for every real number C, L(Cy) CL( y ) 5.2 Also, if y1=f1(x) and y2=f2(x), then it can be shown that L( y1 y2 ) L( y1 ) L( y2 ) 5.3 Given the differential equation (5.1), that is, L(y)=k(x), the corresponding homogeneous equation L(y)=0 is called the complementary equation. Suppose that yp is a particular solution of L(y)=k(x) and yc is any solution of the complementary equation. Since L(yp)=k(x) and L(yc)=0 L( y p y c ) L( y p ) L( yc ) k ( x) 0 k ( x) which means that yp+yc is a solution of (5.1). Theorem If yp is a particular solution of the differential equation L(y)=k(x) and if yc is a general solution of the complementary equation L(y)=0, then the general solution of L(y)=k(x) is y=yc+yp. (5.4) AMA126 - 37 - If we use the results of the previous section to find the solution yc of L(y)=0, then according to the above theorem all that is needed to determine the general solution of L(y)=k(x) is one particular solution yp. Example Solve the differential equation y″-4y=6x-4x3. Solution We see by inspection that yp=x3 is a particular solution of the given equation. The complementary equation y″-4y=0 which by (4.6), has solution y C1e 2 x C2 e 2 x Applying the theorem, the general solution of the given non-homogeneous differential equation is y C1e 2 x C2 e 2 x x 3 . In most cases a particular solution of (5.1) cannot be found by inspection as it was done in the previous Example. Given the differential equation L( y) ay' 'by'cy e nx where enx is not a solution of L(y)=0, it is reasonable to expect that there is a particular solution of the form yp=Aenx, since enx is the result of finding ay″+by′+cy=0. This suggests that we use Aenx as a trial solution in the given equation and attempt to find the value of the coefficient A. This technique is called the method of undetermined coefficients, and is illustrated in the next example Example Solve the differential equation y″+2y′-8y=e3x. Solution Since the auxiliary equation m2+2m-8=0 of y″+2y′-8y=0 has roots 2 and -4 it follows that the general solution of the complementary equation is yc C1e 2 x C2 e 4 x . AMA126 - 38 - From the preceding remarks we seek a particular solution of the form yp=Ae3x. Since yp′=3Ae3x and yp″=9Ae3x, substitution in the given equation leads to 9 Ae3 x 6 Ae3 x 8 Ae3 x e 3 x . Dividing both sides by e3x we obtain 9 A 6 A 8 A 1 or 1 A . 7 Thus yp=(1/7)e3x and by Theorem (5.4), the general solution is 1 y C1e 2 x C 2 e 4 x e 3 x . 7 After all, the method of undetermined coefficients is based on ‘guessing’ the right form for yp. The ‘guess’ is based on experience and comes down to a few rules: 1. If k(x) is a polynomial of degree q, try y p aq x q aq1 x q1 a1 x a0 i.e. a polynomial of the same degree. 2. If k(x)=acosmx+bsinmx (including the cases when a=0 or b=0), try y p A cos mx B sin mx 4. If k(x)=aepx and p is not a root of the auxiliary equation, try y p Ae px 5. If k(x)=aepx and p is a root of the auxiliary equation, try y p Axe px 6. If k(x)=xepx and p is not a solution of the auxiliary equation then try a particular solution of the form y p ( A Bx )e px 7. If k(x)=esxsintx or k(x)=esxcostx and s+ti is not a solution of the auxiliary equation, then try a particular solution of the form y p Aesx cos tx Be sx sin tx. AMA126 - 39 - 8. If k(x) is a sum of simpler functions in the list above, find the particular integral for each of these simpler functions and add them together. Example Find the general solution of the equation d2y dy 13 12 y 2t 1 2 dt dt Solution The characteristic equation is m 2 13m 12 0 m 12m 1 0 or m1 1, m2 12 which means that the complementary solution is y c Ae t Be 12t For the particular solution, try yp=at+b. Accordingly, yp′=a, yp″=0. We substitute back into the equation 0 13a 12at b 2t 1 12at 12b 13a 2t 1 a 1 6 b7 72 This means that general solution y Ae t Be 12t t 7 6 72 Example: Solve the non-homogeneous differential equation d2y y 1; y(0) 0, dx 2 Solution: y=1-sinx-cosx y 0 2 AMA126 - 40 - Example Solve the differential equation d2y dy 3 2 y e 4t 2 dt dt Solution The characteristic equation is m 2 3m 2 0 m 2m 1 0 or m1 1, m2 2 The complementary solution is yc Ae 2t Be t Since m≠4, we try a particular solution of the form yp=ae4t, i.e. yp′=4ae4t, yp″=16ae4t. Introducing these expressions back into the original equation we have 16a 12a 2a e 4t e 4t , i.e. 6a 1, a 1 6 Finally, the general solution is y Ae 2t Be t e 4t 6 Example Solve the differential equation d2y dy 3 2 y e 2t given that y=0 and dy/dt=0 when t=0. 2 dt dt AMA126 - 41 - Solution The characteristic equation is m 2 3m 2 0 m 2m 1 0 or m1 1, m2 2 so yc Ae 2t Be t Here e-2t is part of the complementary solution so we must try a particular solution of the form yp=ate-2t. Accordingly a 2e y 'p a e 2t 2te 2t a1 2t e 2t y 'p' 2t 21 2t e 2t a 4e 2t 4te 2t Introducing back into the original equation, the left hand side will look like LHS a 4e 2t 4te 2t 3e 2t 6te 2t 2te 2t ae 2t Note that the terms in te-2t cancel out, this will always happen. Comparing the two sides of the equation we obtain that a=-1. So, the general solution of the equation is y Ae2t Be t te2t Now we have to find the two constants, A and B, using the initial conditions given. When t=0, y=0, i.e. 0=A+B. To use the other condition we calculate y 2 Ae 2t Be t e 2t 2te 2t . When t=0, we have 0=-2A-B-1. Combining the two relations obtained for the two constants we obtain A=-1 and B=1. So, the final solution is y e2t et te2t . Example Solve the differential equation d2y dy 3 2 y sin 2t and describe the behaviour of the solution as t→∞. 2 dt dt Solution AMA126 - 42 - Population dynamics Population dynamics is concerned with numbers in populations and factors which cause them to change. In addition to natural curiosity, population dynamics is useful in studying problems involving economic and social situations, e.g. farming, fishing, spread of epidemics, conservation (killing of whales, Amazon rain forests, etc. ). In studying population dynamics we shall be concerned with either one species (e.g. humans) or two interacting/competing species (rabbits and foxes). Population dynamics tries to answer questions like: What will be the population of a certain country in 10 years? How are we protecting the resources from extinction? To try to answer to these types of questions we construct simple mathematical models of real life situation then use models to predict future changes. Models simplify the real situation and aim to isolate the main factors and study their effect on the main population. These models may be crude but they can give surprisingly accurate predictions. In order to be able to model these situations we have to make some assumptions: 1. the number of individuals in a given area can be represented by a single variable, x, measured in terms of some chosen unit of population, so x is the population density. By treating the population as a whole, we ignore age and sex differences. 2. x is a continuous and differential function of t, taken as a continuous variable. This may seen a surprising assumption since we might expect to take x as an integer, the population of any species changing by integer amounts. However if a given population is very large and it is increased by a few in short time intervals, those changes are very small compared to the total population and a graph of x with respect to t looks like a continuous function and indeed a differentiable function and as we assume that it is. We have in mind populations such as the human population which has no fixed breeding season. Some species such as sheep have a single breeding season and for these it may be AMA126 - 43 - more sensible to measure x at discrete time intervals, the ends of the breeding seasons, for example. This leads to difference equation models which will be studied later. One species models (e.g. number of people in the world, number of bacteria in an experiment, number of trees in the forest, etc.) Let x(t) the number of members of a population. Large population if increase/decrease not too drastically than it is reasonable to approximate the function x(t) by a continuous and differentiable function of t. Let the number, x(t), of members of a population at time t be large enough for x(t) to be continuous. If x(t0) is known, can the number be predicted at subsequent times? In general the time scale depends on the population type: for humans in years, for bacteria in hours or days. To model the growth we consider the rate at which the population changes. The instantaneous growth rate at time t is dx/dt. The instantaneous relative growth (or rate of change per individual) is r (t ) 1 dx x dt The population dynamics operate with a few models which are surprisingly accurate. In order to model the problem, we are going to use two types of first order differential equations already presented previously. In what follows we are revising the methods of solving these types of equations 1. Separation of variables: if the differential equation can be written as dx f (t ) g ( x) dt dx g ( x) f (t )dt 2. The integrating factor: if the differential equation can be written as dx P(t ) x Q(t ) dt then the equation is solved by using the integrating factor exp P(t )dt Example1 1. Solve the differential equation x′(t)=ax, where a is a constant for x≥0 such that (i) x=x0 when t=0 AMA126 (ii) - 44 x=x0 when t=t0 Solution This equation can be solved by variable separation dx a dt x Integrating both parts we have ln x at A or x e at A or x Ce at which is the general solution, A is an arbitrary constant. Now we are going to use the initial conditions (i) of x=x0 when t=0, then we have x0 Ce0 C i.e. x x0eat which is a particular solution (ii) if x=x0 when t=t0, then x0 Ceat 0 i.e. C x0e at 0 so x x0ea t t 0 Example2 Find the solution of the differential equation x′(t)=ax(b-x), where a and b (b>0) are constants for 0≤x≤b which satisfies x(0)=x0. Solution This equation can be solved again using variable separation. Accordingly we write dx xb x a dt Now, the integrand of left-hand side can be decomposed as 1 A B xb x x b x or 1 Ab x Bx This equation must be valid for all values of x. Putting first x=0 we have 1=Ab, so A=1/b. Then we put x=b and we obtain 1=Bb, so B=1/b. Using these values, the integrand can be decomposed as 1 1 1 1 xb x b x b x AMA126 - 45 - which means that the integral is dx 1 dx 1 dx 1 1 ln x ln(b x) x b bx b b x(b x) b 1 x ln b b x since 0≤x≤b. Returning to the differential equation obtained after separating the variables we have 1 x x ln at A' or ln abt A b b x b x x Ce abt Cect bx where A=A′b, A′ and c=ab are constants. If x=x0 when t=0 x0 x x C 0 ect b x0 b x b x0 xb x0 x0 b x ect x b x0 x0ect bx0ect x bx0 x0 b x0 e ct Example Find the general solution of the differential equation dx ax Aebt dt where a, b and A are constants. Solution This is a linear differential equation with P(t)=a and Q(t)=Aebt. Therefore the integrating factor is e adt eat Multiplying the original differential equation by the integrating factor gives AMA126 eat - 46 - dx aeat x Aebt eat Ae( a b )t dt Since we have multiplied the differential equation by the integrating factor, the left-hand side of the above relation can be written as d at e x dt since d at e x eat dx x d eat eat dx aeat x dt dt dt dt and so d xeat Ae ( a b )t dt Integrating both sides with respect to t gives xeat A ( a b )t e B ab where B is an arbitrary constant. From above relation, x can be expressed as x A bt e Be at ab Exponential model (The Malthusian model) Is the simplest model when we suppose that the instantaneous relative growth, r(t), is constant (a) 1 dx a or x dt dx ax dt This model says that the rate of change of the population is proportional to the existing population. If x=x0 when t=t0, we obtained AMA126 - 47 - x x0ea t t 0 If a>0 then this result gives an exponential growth a<0 then this result gives an exponential decay and a is called growth (decay) rate here x(t)=P(t) and x0=2 and a=0.2 A useful measure of the growth of a population is the doubling time. If t1-t0= time required for population to double, then at t=t1, x=2x0 and so 2 x0 x0e a t 1 t0 ln 2 at1 t0 1 t1 t0 ln 2 a Example: (Application to world human population) In 1961 the world population was 3.06x109. Over the next 10 years it increased at relative growth rate of 2% per year. Calculate the doubling time. Solution Applying the formula, with t0=1961, a=0.02, x0=3.06x109, we have x 3.06 109 e0.02t 1961 and the doubling time is ln2/0.02=34.7 years. Estimates from 1700 to 1961 suggest that the doubling time was 35 years, which means that this model gives good agreement with reality. AMA126 - 48 - What about future predictions: In 1991 a population of 5,575 million, in 2389 a population of 15,969,164 million (the surface area of the Earth is approximately 16,700,500 million m2) That means that the exponential model gives unreasonable predictions for the future. For positive growth rate, when time tends to infinity, the population number tends to infinity which is in contradiction with the available resources or environment limitations. Therefore it is obvious that a new model has to be used which can give reasonable results for large times. The logistic model (Verhulst-Pearl model) The exponential model (besides that it gives too large predictions for large times) does not reflect the competition between individuals, the limits of the resources and food supply. For many species with a finite food supply the population tends to an upper limit which depends on the environment conditions. The idea behind the logistic model says that while the population will continue to grow as time goes on, the rate at which it does this growing gets smaller. Let us denote by c the reproductive parameter, x(t) the population density and k the carrying capacity of the environment (or a limiting size of population). Then the proposed logistic equation (Verhulst 1844) is dx x cx1 dt k In general, k is large. For small values of x, cx2/k is negligible compared to cx and initially the population grows exponentially. When x is large, the cx2/k term is no longer small and slows down the rate of increase of x. The logistic equation can be interpreted if we expand out the logistic equation dx c cx x 2 dt k which suggests a situation when the birth rate is still constant cx, but in which there is a mortality term, cx2/k, that dominates when the population is high. If x>k, then dx/dt<0 and the population decreases, when x=k then the population growth is a constant. Now AMA126 - 49 - dx c xk x axb x dt k putting a=c/k, b=k ab=c, using Example2 x kx0 x0 k x0 e ct Since e ct 0 as t for c 0 it follows from the above form of the solution that xk as t∞ for any x0. (here c≡r) Let us take the logistic equation dx x cx1 dt k This equation has two population levels x=0 and x=k for which dx/dt=0. These are called equilibrium levels. Suppose that the population is closed to one of these levels at some time and we want to see whether it will remain close to that level for all t? If it does, we say that the population is locally stable, if it does not remain close then it is unstable. From the graph, the point x=k is locally stable but x=0 is unstable. We can gain this information without sketching the graph as follows: For x=k write x=k+X(t), where X(t) is a small quantity; then dx/dt=dX/dt, since k=constant, and from the logistic equation AMA126 - 50 - dX cX 2 kX X ck X 1 ck X cX dt k k k Since X(t) is a small quantity we can neglect the term containing the X2 term, so dX cX X Ae ct dt Since c>0, X→ 0 as t→∞, i.e. x remains close to x=k and so is locally stable. Harvesting The population of fish in the North Sea can be described by the logistic equation dx x cx1 cx sx2 dt k putting s=c/k a positive number. Suppose that the fish are caught (harvested) at a constant rate h, i.e. in the absence of all other factors dx h dt To account for harvesting the logistic equation must be modified to dx cx sx2 h dt Let us first discuss the equilibrium levels of this model. The equilibrium levels are at x=xe, such that dxe/dt=0, i.e. sxe2 cxe h 0 or xe2 kxe h 0 s Solving this second order equation we obtain xe k k2 4h 2 2 s k k h 2 4 s (*) AMA126 - 51 - Case (a) If the determinant is positive, i.e. k2/4-h/s>0, then h sk 2 (moderate 4 fishing). In this case, there are two positive real roots (i.e. two equilibrium levels) x1 and x2 where x1 k k2 h 2 4 s k k k2 h x2 2 4 s x2 x1 k and dx h s x 2 kx s x x1 x x 2 . dt s Case (b) If the determinant is negative i.e. k2/4-h/s<0, then h sk 2 (over intensive 4 fishing). In this case there are no real roots, i.e. there are no equilibrium levels. Completing the squares, dx/dt can be written as (**) 2 dx h k k 2 h 2 s x kx s x 0 dt s 2 4 s 0 dx/dt< 0 for all values of x, i.e. since dx/dt never reaches 0, we have no equilibrium levels. Case (c) If the determinant is zero, i.e. . k2/4-h/s=0. Equation (*) has a repeated root xe k 2 From equation (**) 2 dx k for all values of x except x=xe. s x 0 dt 2 AMA126 - 52 - (ii) Local stability. First we consider case (a) where we have two equilibrium levels. Let x=xe+X(t), where xe=x1 or x2. Then dx dX sxe X x1 xe X x2 dt dt When xe=x1 dX sX x1 x2 X s( x1 x2 ) X OX 2 dt Neglecting terms proportional to X2, we arrive at a simple first order differential equation which can be solved by separating the variables X Ae s x x 1 2 t where A is a constant. Since x1>x2, X0 as t∞ and so x1 is locally stable. When xe=x2 dX s x2 x1 X X Be s x dt as t 2 x1 t and so x2 is unstable. (iii) Graph of x(t) First of all we note that dx s x x1 x x2 dt For x>x1 x2<x<x1 0<x<x2 s 0 dx/dt<0 => x decreasing dx/dt>0 => x increasing dx/dt<0 => x decreasing AMA126 - 53 - Here x0=x(0). If x0<x2, the graph intersects x=0 at a finite time T. From dx s x x1 x x2 dt 0 T dx x x x x s dt sT x 0 1 2 0 x0 1 dx T s 0 x x1 x x2 Case (b) k2 h sk 2 or h 4 s 4 In this case we have no equilibrium levels, i.e. dx/dt <0 for all values of x. In either case x becomes zero in a finite time. Case (c) h=sk2/4. The graph can be obtained easily from case (a) when the two roots are identical, i.e. x1=x2. AMA126 - 54 - Conclusions: Although limited, this modelling of harvesting indicates that there is a maximum harvesting rate h sk 2 1 c 2 1 k ck 4 4k 4 at which the population can sustain itself in equilibrium. Any greater rate leads to a depletion of stock eventually to zero. At h=ck/4 the equilibrium level is k/2 (not the equilibrium level k of the logistic model). Any harvesting of depleted species will result in extinction. Two species model. Predator-prey Suppose an island supports a crop of foliage and populations of foxes and rabbits. The foxes eat the rabbits. The rabbits eat the foliage (i.e. limited supply). What happens with the populations??? Assuming no other interference with the system, we might expect the two populations to oscillate. Let x(t) be the population of rabbits at time t. With no foxes around, we assume that x(t) obeys the logistic equation dx ax bx2 , a 0, b 0 dt a/b being the carrying capacity or saturation level. Let y(t) be the population of foxes at time t. Assuming that the number of encounters per unit time between foxes and rabbits is proportional to x and y and that a certain proportion of these results in rabbit being eaten, i.e. the rate of decrease in the rabbit population is proportional to xy. In this case the differential equation becomes AMA126 - 55 - dx ax bx 2 cxy, a, b, c 0 dt (1) If no rabbits are present, we assume foxes die out exponentially, i.e. dy py, dt p0 With rabbits present, the rate of increase of foxes is proportional to the number of successful encounters with rabbits and so the differential equation becomes dy py qxy, dt p, q 0 (2) The two populations are therefore determined by the coupled pair of nonlinear ordinary differential equations (1) and (2). Putting b=0 (=> an abundance of foliage) gives the Lotka-Volterra (LV) equations dx ax cxy dt dy py qxy dt (3) (4) Equilibrium populations. Let x=xe and y=ye the equilibrium populations and they are given by the usual conditions dxe/dt=0, dye/dt=0, i.e. xe a cye 0 ye p qxe 0 (5) (6) Equation (5) is satisfied by xe=0 or ye=a/c. If xe=0, then from Eq. (6) we obtain that ye=0. If ye=a/c, then from Eq. (6) we obtain that -p+qxe=0 => xe=p/q. The equilibrium populations are therefore xe 0, ye 0 and xe p a , ye q c Are these equilibrium populations stable? Let us take the Lotka-Volterra equations (Eqs. (3) and (4)) and we consider AMA126 x - 56 - p a X, y Y q c where the quantities X and Y are small increments. These expressions are introduced back into the Lotka-Volterra equations and we obtain dx dX p pc a X a c Y Y dt dt q q c dy dY a p qa Y p q X X dt dt c q c => dX pc Y dt q dY qa X dt c (7) (8) This is a system of two coupled first order ordinary differential equations. In order to solve this system, we use the usual procedure, i.e. first we differentiate Eq. (7) with respect to t and we use the derivative of Y with respect to t from Eq. (8) d2X pc dY pc qa X apX , ap 0 2 q dt q c dt (9) To find the governing equation for Y, we follow the same way, i.e. we differentiate Eq. (8) with respect to t and use Eq. (7) d 2Y qa dX qa pc Y apY dt 2 c dt c q (10) The general solution of (10) is Y Acost B sin t (11) putting ω2=ap. To find the solution for X, we use Eq. (8) which gives qa dY X A sin t B cos t c dt c A sin t B cos t X aq (12) AMA126 - 57 - [Using Eq. (9) to find X introduces extra constants which are connected to A and B via Eq. (8)] Suppose that at t=0, X=X0 and Y=Y0. Then A=Y0 and B=X0aq/cω, so that X X 0 cost c Y0 sin t aq aq Y Y0 cost X 0 sin t c The above equations show that X and Y are bounded and so stay close to x=p/q, y=a/c for all t, so this point is locally stable. Also Y R sin cos t R cos sin t R sin t (13) putting R sin Y0 , X c aq R cos aq X0 c and R sin sin t cos cos t X c aq R cost Y R cos t 2 where we have used the trigonometrical identity cos cos cos sin sin sin 2 2 2 For the other equilibrium level (0,0), we put AMA126 - 58 - x=0+X=X, y=0+Y=Y then from Eqs. (3) and (4) we have dX dY aX cXY , pY qXY. dt dt Having in mind that X and Y are small quantities, we can neglect the 2nd order terms XY dX aX dt X Aeat X grows exponentially in time since a>0, i.e. X∞ as tω the point (0,0) is unstable N.B. Only need either X or Y to grow exponentially for an unstable point. Summary I. One species I.a Exponential model: dx ax x Aeat (comparison with data dt I.b Logistic model: limited resources, saturation level k dx x cx1 dt k -solution -graph I.c Harvesting: constant rate h, the rate proportional to x and the differential equation of the form similar to the logistic model Equilibrium levels (x=xe): dxe/dt=0 Local stability (instability): take x=xe+X(t) and neglect second order terms in X II. Two species II.a Predator-prey (notes) II.b Competing species (example sheet 9, 11) Equilibrium levels and stability Discrete Mathematics and Difference Equations Discrete mathematics is the branch of mathematics dealing with objects that can assume only distinct, separated values. The term "discrete mathematics" is therefore used in contrast with "continuous mathematics," which is the branch of mathematics dealing with AMA126 - 59 - objects that can vary smoothly (and which includes, for example, calculus). Whereas discrete objects can often be characterized by integers, continuous objects require real numbers. The study of topics in discrete mathematics usually includes the study of algorithms, their implementations, and efficiencies. Discrete mathematics is the mathematical language of computer science, and as such, its importance has increased dramatically in recent decades. Mathematical computations frequently are based on equations that allow us to compute the value of a function recursively from a given set of values. Such an equation is called a “difference equation” or “recurrence equation”. These equations occur in numerous settings and forms, both in mathematics itself and in its applications to statistics, computing, electrical circuit analysis, dynamical systems, economics, biology, etc. Example In 1626, Peter Minuit purchased Manhattan Island for goods worth $24. If the $24 could have been invested at an annual interest rate of 7% compounded quarterly, what would it have been worth in 2004? Solution Let y(t) be the value of the investment after t quarters of a year. Then y(0)=24. Since the interest rate is 1.75% per quarter, y(t) satisfies the difference equation y (t 1) y (t ) 0.0175 y (t ) 1.0175 y (t ) t 0,1,2, Computing y recursively, we have y (1) 24(1.0175) y (2) 24(1.0175) 2 y (t ) 24(1.0175) t In 378 years, or 1512 quarters, the value of the investment is y(1512)=24(1.0175)1512≈5.9x1012 (about 5.9 trillion dollars!) Example It is observed that the decrease in the mass of a radioactive substance over a fixed time period is proportional to the mass that was present at the beginning of the time period. If the half life of radium is 1600 years, find a formula for its mass as a function of time. Solution Let m(t) represent the mass of the radium after t years. Then AMA126 - 60 - m(t+1)-m(t)=-km(t) where k is a positive constant. Then m(t+1)=(1-k)m(t), t=0,1,2… Using iteration as in the previous example, we find m(t ) m(0)(1 k ) t Since the half life is 1600 years 1 1 1 1600 m(1600) m(0)(1 k )1600 m(0) 1 k 2 2 so t 1 1600 m(t ) m(0) 2 (In physics, this problem is usually solved using an integral of a differential equation. The solution presented here is somewhat shorter and employs only elementary algebra) The starting equations in the above examples were all difference equations. By definition, an equation which expresses the value an of a sequence {an} as a function of the term an-1 is called first-order difference equation. If we can find a function f such that an=f(n), n=1, 2, 3…, then we will have solved the difference equation. Both examples had a general difference equation of the form xn1 Axn , n 0,1, 2, From the above examples, it is obvious that if x0 is the initial value, then x n A n x0 Given the constants A and B, a difference equation of the form x n1 Axn B, n 0,1, 2, is called a first-order linear difference equation. Note that the linear difference equation reduces to the difference equation if B=0. In order to solve this type of equation, we write AMA126 - 61 - x n Ax n 1 B A( Ax n 2 B) B A 2 x n 2 B( A 1) A 2 ( Ax n 3 B) B( A 1) A 3 x n 3 B( A 2 A 1) A n x 0 B( A n 1 A n 2 A 2 A 1). Note that if A=1, this gives us x n x0 nB, n 0,1, 2, as the solution of the difference equation xn+1=xn+B. If A≠1, we know that A n 1 A n 2 A 2 A 1 1 An 1 A Hence 1 An x n A x0 B 1 A n is the solution of the first-order linear difference equation xn+1=Axn+B, when A≠1. ____________________________________________________ Example (Newton’s law of cooling) If T0 represents the initial temperature of the object, S the constant temperature of the surrounding environment and Tn the temperature of the object after n units of time, then the change in the temperature over one unit of time is given by Tn 1 Tn k Tn S where k is a constant which depends upon the object. This difference equation is known as Newton’s law of cooling. Suppose a cup of tea, initially at a temperature of 82 C, is placed in a room which is held at a constant temperature of 26 C. Moreover, suppose that after one minute the tea has cooled to 80 C. What will the temperature be after 20 minutes? Solution If we let Tn be the temperature of the tea after n minutes and we let S be the temperature of the room, then we have T0=82, T1=80, and S=26. Newton’s law of cooling states that Tn 1 Tn k Tn 26, n 0,1, 2, where k is the constant which we have to determine. To do so, we make use of the information given about the change in the temperature of the tea during the first minute. When n=0, we have AMA126 - 62 - T1 T0 k T0 26 or 80 82 k (82 26) so k 0.035 Thus, the original equation reduces to Tn 1 Tn 0.035(Tn 26) 0.035Tn 0.91 so Tn 1 Tn 0.035Tn 0.91 0.965Tn 0.91 Now the last equation is in the standard form of a first-order linear difference equation, so from the solution (according to the method of solving presented earlier) 1 0.965n 0.965n (82) 26(1 (0.965) n ) Tn 0.965n (82) 0.91 1 0.965 26 56(0.965) n In particular, T20 26 56(0.965) 20 53.5 So after 20 minutes the tea has cooled to just below 54 C. ____________________________________________________ An equation of the type au n 2 bu n 1 cu n f (n) where a, b and c are constants and f(n) a given function is called a second order constant coefficient difference equation. The equation is said to be homogeneous if f(n)=0 and inhomogeneous if f(n)≠0. a. Homogeneous second order difference equations We can have an idea on how these equations can be solved by looking first at first-order equation with constant coefficient u n 1 cu n 0 which has the solution u n Ac n where A is any constant. With this in view, we attempt to find solutions of AMA126 - 63 - au n 2 bu n1 cu n 0 in the form un p n where p is a constant. Thus au n 2 bu n 1 cu n ap n 2 bp n 1 cp n (ap 2 bp c) p n 0 for all n. The solution p=0 leads to the trivial solution un=0. We are interested in the roots of the equation in the brackets which is called the characteristic equation. According to the nature of the roots of the characteristic equation, we can have different solutions. Case 1: Distinct roots The general solution of the second-order difference equation for distinct roots p1 and p2 of ap2+bp+c=0 is u n Ap1n Bp 2n for any constant A and B. Example Find the general solution of u n 2 u n 1 6u n 0 Solution The characteristic equation is p2-p-6=0 or (p-3)(p+2)=0. This means that the roots are p1=3 and p2=-2. Hence the general solution is u n A 3n B 2 n Example Find the solution of un2 2un1 3un 0 that satisfies u0=1, u1=2. Solution The characteristic equation is AMA126 - 64 - p 2 2 p 3 0 or ( p 3)( p 1) 0 The roots are p1=-3 and p2=1. Hence the general solution is u n A 3 B 1n A 3 B n n Using the initial conditions u 0 1 A B, u1 2 3 A B Hence A=-1/4 and B=5/4. The required solution is u n 1 3n 5 4 4 Case 2: Equal roots(p1=p2=p) The general solution of au n 2 bu n1 cu n 0 is u n ( A Bn ) p n (please note the difference in the form of the second-order difference equation) Case 3: Complex roots The general complex solution of au n 2 bu n1 cu n 0 , where b2<4ac, is u n A i B i n n This solution can be written in other form by writing the complex numbers in polar coordinates (r,θ). The connection between the two forms of writing a complex number is r 2 2 , cos r , sin r , tan So the general solution of a second-order homogeneous difference equation with complex roots can be also written as u n r n C cos n D sin n Example Obtain the general solution of u n 2 u n 0 AMA126 - 65 - Solution The characteristic equation is p2+1=0, giving roots p1=i and p2=-i. Therefore u n Ai n B i n In polar form, r=1 and sin 1 k 2 where k is an integer number. So, the solution is u n C cos n 2 D sin n 2 b. Inhomogeneous second-order difference equations The general inhomogeneous equation is au n 2 bu n1 cu n f (n) We write un=vn+qn, where vn is the general solution of the corresponding homogeneous equation. Substitute this form of un into the general equation avn 2 q n 2 bvn1 q n1 cvn q n f (n) or avn2 bvn1 cvn aqn2 bqn1 cqn f (n) Since vn satisfies the homogeneous equation, it follows that aqn 2 bqn1 cqn f (n), which means that qn must be a particular solution of the inhomogeneous equation. As in the theory of differential equations, vn is known as the complementary function. We construct particular solutions by appropriate choices of functions usually containing adjustable parameters which are suggested by the form of the function f(n). In the following table you will find the suggested forms of particular solutions AMA126 - 66 - k (a const ) C ; or Cn, if C fails ; Cn 2 , if C and Cn fail ; etc kn Ck n ; or Cnk n , if Ck n fails ; etc n C 0 C1 n n p ( p int eger ) C 0 C1 n C p n p sin kn or cos kn C1 cos kn C 2 sin kn Example Obtain the general solution of u n 2 u n 1 6u n 4 Solution From the example solved earlier, the complementary solution is v n 3 n A (2) n B For the particular solution, we try qn=C (see the table above). Then q n 2 q n 1 6q n 4 C C 6C 4 6C 4 0 C 2 3 Hence qn=-2/3, and the general solution is u n 3 n A (2) n B 2 3 Example Obtain the general solution of un2 2un1 3un 4 Solution From a previous example, we know that the complementary solution is vn (3) n A B In this case we expect a particular solution of the form qn=C. However, if we introduce this form into the general solution, we would obtain that the left-hand side of the equation is identical zero. That means that this choice of the particular solution fails, so we are choosing qn=Cn. Then AMA126 - 67 - qn2 2qn1 3qn 4 C (n 2) 2C (n 1) 3C 4 4C 4 0 C 1 Hence the general solution is u n (3) n A B n Numerical methods for solving ordinary differential equations. Most ordinary differential equations arising in real-world applications cannot be solved exactly. These equations can be analyzed qualitatively. However, qualitative analysis cannot give accurate answers. A numerical method can be used to get an accurate approximate solution to a differential equation. 1. Euler’s method We will focus on this method as the simplest numerical method used for solving ordinary differential equations. In order to emphasize the importance of numerical methods, let us take first an example: solve the equation y′=2x with y(0)=0. It is obvious that this simple equation has as solution y=x2, i.e. a formulaic solution. On the other hand, say we were to use a numerical technique. The resulting numerical solution would be a table of values. To have a better idea of these two solutions, let us compare them side by side, along with the graphs Notice that the graph derived from the formulaic solution is smoothly continuous, consisting of infinite number of points on the interval shown. On the other hand, the graph based on the numerical solution consists of just a few points as the numerical method apparently only found the value of the solution for x-increments of size 0.2. The first question you could ask is “ then what good is the numerical solution if it leaves out so much of the real answer?”. Well, we can answer to this question in several ways: 1. The numerical solution still looks like it is capturing the general trend of the ‘real’ solution => if we are looking for a qualitative view of the solution, we can still get it from the numerical solution. 2. The numerical solution can be even improved by playing ‘join-the-dots’ with the set of points it produces. 3. Using a numerical approach, we can find the value of the solution at a specific point. AMA126 - 68 - 4. If a formulaic expression for solution is not possible, here the numerical solutions are the only possibility to find solutions (errors) In what follows we will concentrate mainly on first order equations only. In order to develop a technique for solving first order differential equations when the initial values are given (or initial value problems). We assume that the studied equation has the form y′=f(x,y) with y(x0)=y0. Our goal is to find a numerical solution, i.e. we must find a set of points which lie along the initial value problem’s solution. This means that we actually know one point of the solution, i.e. (x0,y0)-initial value. Now, remember we do not know the true solution of the problem, but let us act as if we do know this elusive solution for a moment. Let us pretend that its ‘ghostly graph’ could be superimposed onto our previous picture to get this Since we are after a set of points which lie along the true solutions, we must now derive a method of generating more solutions in addition to the initial condition. Let use the other part of the problem, namely the form of the differential equation itself. Remember that one interpretation of the quantity y′ appearing in this expression is as the slope of the tangent line to the function y. But the function y is exactly what we are looking for as solution of the problem, i.e. slope of the function=f(x,y) Now we have to think how can we use this slope to find subsequent points on the graph. Actually, we can obtain the slope by substituting values for x and y into the function f. These values, of course, must be the coordinates of a point lying on the solution’s AMA126 - 69 - graph—they cannot just be the coordinates of any point anywhere in the plane. Therefore we use the initial value as starting point, i.e. we can find the slope of the graph at the initial value slope of the solution at (x0,y0)=f(x0,y0) Remembering that this gives us the slope of the function’s tangent line at the initial point we could put this together with the initial point itself to build the tangent line at the initial point Looking at the two graphs, we can observe that close to the initial value the two curves are every close to each other. Let us say we move a short distance away, to a new xcoordinate of x1. Then we could locate the corresponding point lying on our tangent line. It might look like this Notice that our new point, called (x1,y1), is not too far away from the true value of the solution at this x-coordinate, up on the curve. So we now have two points as part of our numerical solution a. (x0,y0): an exact value, known to lie on the solution curve b. (x1,y1): an approximate value, known to lie on the solution curve’s tangent line through (x0,y0). We must now attempt to continue our quest for points on the solution curve. Next we will repeat our last step, constructing a tangent line at our new point AMA126 - 70 - There is a problem here: since our new point did not actually lie on the true solution, we cannot actually produce a tangent line to the solution at this point. But we can still substitute our new point (x1,y1), into the formula slope of the function=f(x,y) to get the slope of a pseudo-tangent line to the curve at (x1,y1). We hope that our approximate point, is close enough to the real solution that the pseudo-tangent line is pretty close to the unknown real tangent line. We now attempt to use this new pseudotangent line to get another point in the approximate solution. As before, we move a short distance away from our last point, to a new x-coordinate of x2. Then we locate the corresponding point lying on our pseudo-tangent line. The result might look something like this We now have three points in our approximate solution: a. (x0,y0): an exact value, known to lie on the solution curve b. (x1,y1): an approximate value, known to lie on the solution curve’s tangent line through (x0,y0) c. (x2,y2): an approximate value, known to lie on the solution curve’s pseudo-tangent line through (x1,y1). This method can be repeated making new points for as long as we like. Now let us see what the theoretical background of the Euler’s method is. We are solving the initial value problem y f ( x, y), y( x0 ) y 0 AMA126 - 71 - As said before, the basic idea is to use a known point as a starter, and then use the tangent line through this known point to jump to a new point. Let us use the names (xn,yn) for the known point (xn+1,yn+1) for the new point Our picture, based on the previous experience, should look like something like this Our task is to find formulas for the coordinates of the new point, xn+1. Clearly, it lies on the tangent line, and this tangent line has a known slope, namely f(xn,yn). Let us mark the sizes of the jumps in the x and y direction as we move from the known point to the new point. From the formula relating xn and xn+1 is obvious that x n 1 x n h Also we know from basic algebra that slope=rise/run, so applying this idea to the triangle in our picture, the formula becomes f x n , y n y h which can be rearranged to solve for Δy giving y hf xn , yn But, we are really after a formula for yn+1. Looking at the picture, it is obvious that yn+1=yn+Δy. Replacing Δy by our new formula, this becomes y n 1 y n hf x n , y n . Example AMA126 - 72 - Solve the initial value problem y x 2 y y (0) 0 numerically, finding a value for the solution at x=1, and using steps of size h=0.25. Solution We apply the theoretical formulas found before. The interval we want to find intermediate points is [0,1]. In our case f(x,y)=x+2y and the starting point is x0=0, y0=0. We generate values for x1, y1. The x-iteration formula, with n=0 gives x1 x0 h 0 0.25 0.25 The y-iteration formula, with n=0 gives y1 y 0 hf x0 , y 0 y 0 h( x0 2 y 0 ) 0 0.25(0 2 * 0) 0 So the second point in our numerical solution is x1=0.25, y1=0. We move on to get the next point in the solution, (x2,y2), n=1. x2 x1 h 0.25 0.25 0.5 y2 y1 hf x1 , y1 y1 h( x1 2 y1 ) 0 0.25(0.25 2 * 0) 0.0625 So the third point is x2=0.5, y2=0.0625. The x-iteration and y-iteration, with n=2 gives x3 x2 h 0.5 0.25 0.75 y3 y2 hf x2 , y2 y2 h( x2 2 y2 ) 0.0625 0.25(0.5 2 * 0.0625) 0.21875 So the fourth point is x3=0.75, y3=0.21875 Carrying on with the same method we obtain that the fifth point is x4=1, y4=0.515625. We could summarise the results of all our calculations in a tabular form, as follows AMA126 - 73 - n xn yn 0 0.00 0.000000 1 0.25 0.000000 2 0.50 0.062500 3 0.75 0.218750 4 1.00 0.515625 A question you should always ask yourself at this point using a numerical method to solve a problem is “How accurate is my solution?” Sadly, the answer is “Not very!”. The true solution of the given initial value problem turns out to be y 0.25e 2 x 0.5x 0.25 If we use this formula to generate a table similar to the one above, we can see just how poorly our numerical solution did x y 0.00 0.000000 0.25 0.037180 0.50 0.179570 0.75 0.495422 1.00 1.097264 We can get an even better feel for the inaccuracy we have incurred if we compare the graphs of the numerical and true solutions, as shown here The numerical solution gets worse and worse as we move further to the right. We might even be prompted to ask the question “What good is a solution that is bad?” The answer is “Very little good at all!”. So should we quit using this method? No! The reason our numerical solution is so inaccurate is because our step-size is so large. To improve the solution, we have to shrink the step-size. For h=0.02 we would get a much better agreement (see the graph). As you can see, the accuracy of this numerical solution is much higher than before, but so is the amount of work needed. AMA126 - 74 - DIFFERENTIAL EQUATIONS AND MAPLE Maple’s diversity makes it particularly well suited to performing many calculations encountered when solving many ordinary and partial differential equations. In many cases, Maple’s built-in functions can immediately solve a differential equation by providing an explicit, implicit, or numerical solution. The advantages of using Maple in the study of differential equations are numerous, but perhaps the most useful is that of being able to produce the graphics associated with solutions of differential equations. In what follows you will see how we can solve various types of differential equations using Maple. By now you already have a vast knowledge of Maple (SOM104), so we can start directly with applications without introducing basic concepts about Maple. Generally, the command dsolve -Solves ordinary differential equations (ODEs) Calling sequences: dsolve(ODE, y(x), extra_args) dsolve({ODE, ICs}, y(x), extra_args) dsolve({sysODE,ICs},{funcs}. extra_args) Parameters ODE y(x) ICs {sysODE} {funcs} -an ordinary differential equation - any indeterminate function of one variable - initial conditions - a set with a system of ODEs - a set with indeterminate functions attempts to solve the given differential equation for the specified function of one variable. Example Verify that the differential equation y′=-ycosx has infinitely many solutions Solution We use dsolve to solve the first-order linear equation and name the result sol. We interpret the result to mean that if C is any number, a solution to the equation is y=Ce-sinx. Thus, the equation has infinitely many solutions >sol:=dsolve(diff(y(x),x)=-y(x)*cos(x),y(x)); sol:=y(x)=_C1e(-sin(x)) We can plot several solutions using the plot command AMA126 - 75 - >pict:={seq(subs(_C1=I,rhs(sol)), i=-5..5)}: plot(pict,x=0..4*Pi); In many applications we are given not only the differential equation to solve but also one or more conditions that must be satisfied by the solution(s) as well. In the calling sequence of dsolve, ICs means initial conditions. The following commands illustrate how to plot some members of the family of solutions by substituting various values of C into the general solution. We also plot the solution to the problem dy 2 3x 4 x dx y (1) 4 First we use seq to generate a table of functions x3-2x2+C for C=-10, -8,…,8, 10, naming the resulting set of function toplot. The set of functions toplot is not displayed (for length reasons) because a colon (:) is included at the of the command > cvals:=seq(2*I,i=-5..5): toplot:={seq(x^3-2*x^2+c,c=cvals)}: plot(toplot,x=-2..3,view=[-2..3,-15..15]) AMA126 - 76 - Example (The Logistic Equation) The logistic equation is y (t ) (r ay (t )) y (t ), where r and a are constants, subject to the condition y(0)=y0. This equation can be also written as y′=ry-ay2, where the term –y2 represents an inhibitive factor. Under the AMA126 - 77 - assumptions made, the population is allowed neither to grow out of control not to grow or decay constantly. The logistic equation is separable and, thus, can be solved by separation of variables: dy dt (r ay ) y a r r ay a r ay 1 r dy dt y 1 dy rdt y ln r ay ln y rt c ln y e rt c Ke rt r ay y rt c r ay 1 y r e rt a K 1 Applying the initial condition y(0)=y0 and solving for K, we find y0 K r ay 0 After substituting this value into the general solution and simplifying, the solution can be written as y ry 0 ay 0 (r ay 0 )e rt We are also able to use dsolve to solve this initial-value problem. First, we use dsolve to solve the initial-value problem, naming the resulting output Sol. > y:=′y′: Sol:=dsolve({diff(y(t),t)=(r-a*y(t))*y(t), y(0)=y0},y(t)); Sol : y (t ) a e ( rt ) r ( r y 0a ) y0 Then we use assign to name y(t) the result obtained in Sol and simplify to simplify y(t) > assign(Sol): simplify(y(t)); y 0r y 0r e r e ( rt ) y 0a ( rt )