Difference Equations to Differential Equations Section 1.4 Difference Equations At this point almost all of our sequences have had explicit formulas for their terms. That is, we have looked mainly at sequences for which we could write the nth term as an = f (n) for some known function f . For example, if an = n+1 , n2 + 3 11 101 then it is an easy matter to compute explicitly, say, a10 = 103 or a100 = 10003 . In such cases we are able to compute any given term in the sequence without reference to any other terms in the sequence. However, it is often the case in applications that we do not begin with an explicit formula for the terms of a sequence; rather, we may know only some relationship between the various terms. An equation which expresses a value of a sequence as a function of the other terms in the sequence is called a difference equation. In particular, an equation which expresses the value an of a sequence {an } as a function of the term an−1 is called a 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. In this section we will consider a class of difference equations that are solvable in this sense; in the next section we will discuss an example where an explicit solution is not possible. Example Suppose a certain population of owls is growing at the rate of 2% per year. If we let x0 represent the size of the initial population of owls and xn the number of owls n years later, then xn+1 = xn + 0.02xn = 1.02xn (1.4.1) for n = 0, 1, 2, . . .. That is, the number of owls in any given year is equal to the number of owls in the previous year plus 2% of the number of owls in the previous year. Equation (1.4.1) is an example of a first-order difference equation; it relates the number of owls in a given year with the number of owls in the previous year. Hence we know the value of a specific xn once we know the value of xn−1 . To get the sequence started we have to know the value of x0 . For example, if initially we have a population of x0 = 100 owls and we want to know what the population will be after 4 years, we may compute x1 = 1.02x0 = (1.02)(100) = 102, x2 = 1.02x1 = (1.02)(102) = 104.04, x3 = 1.02x2 = (1.02)(104.04) = 106.1208, and x4 = 1.02x3 = (1.02)(106.1208) = 108.243216. 1 c by Dan Sloughter 2000 Copyright 2 Difference Equations Section 1.4 700 600 500 400 300 200 100 20 40 60 80 100 Figure 1.4.1 Plot of (n, xn ), n = 0, 1, 2, . . ., where x0 = 100 and xn+1 = 1.02xn Thus we would expect about 108 owls in the population after 4 years. Note that although it is not possible to have a fractional part of an owl, it is nevertheless important to keep the fractional part in intermediary calculations. We may work backwards to find x4 explicitly in terms of x0 : x4 = 1.02x3 = (1.02)(1.02)x2 = (1.02)(1.02)(102)x1 = (1.02)(1.02)(1.02)(1.02)x0 = (1.02)4 x0 . This is interesting because it indicates that we can compute x4 without reference to the values of x1 , x2 , and x3 , provided, of course, that we know the value of x0 . If we do this in general, then we have solved the difference equation xn+1 = 1.02xn . Namely, we have, for any n = 1, 2, 3, . . ., xn = 1.02xn−1 = (1.02)2 xn−2 = (1.02)3 xn−3 = · · · = (1.02)n x0 . For example, if x0 = 100 as above, then we can compute x20 = (1.02)20 (100) ≈ 149, or even x150 = (1.02)150 (100) ≈ 1, 950, without having to compute any intermediate values. (1.4.2) Section 1.4 Difference Equations 3 For a geometric feeling of how the population is changing with time, Figure 1.4.1 shows a plot of the points (n, xn ) for n = 0, 1, 2, . . . 100. Of course, whether or not our model will provide an accurate prediction of the owl population 100 or 200 years into the future is an entirely different question. Frequently, a simple population model like this will be valid only for a short span of time during which the rate of growth of population remains stable. By replacing 1.02 with an arbitrary constant α in (1.4.2), we arrive at the general result that the solution of the difference equation xn+1 = αxn , (1.4.3) xn = αn x0 , (1.4.4) n = 0, 1, 2, . . ., is given by n = 0, 1, 2, . . .. Note that this difference equation, and its solution, are useful whenever we are interested in a sequence of numbers where the (n + 1)st term is a constant proportion of the nth term. Our first example, where a population was assumed to grow at a constant rate, is a common example of this type of behavior. Another common example is when a quantity decreases at a constant rate over time. This behavior is discussed in the next example in the context of radioactive decay. Example Radium is a radioactive element which decays at a rate of 1% every 25 years. This means that the amount left at the beginning of any given 25 year period is equal to the amount at the beginning of the previous 25 year period minus 1% of that amount. That is, if x0 is the initial amount of radium and xn is the amount of radium still remaining after 25n years, then xn+1 = xn − 0.01xn = 0.99xn (1.4.5) for n = 0, 1, 2, . . .. Since this is a difference equation of the form of (1.4.3) with α = 0.99 , we know that the solution is of the form (1.4.4). Namely, xn = (0.99)n x0 for n = 0, 1, 2, . . .. For example, the amount left after 100 years is given by x4 = (0.99)4 x0 = 0.9606x0 , where we have rounded the answer to four decimal places. That is, approximately 96% of the initial amount of radium will be left after 100 years. A plot of the amount of radium left versus number of years, assuming an initial amount of 500 grams, is given in Figure 1.4.2. The half-life of a radioactive element is the number of years required for one-half of an initial amount to decay. Suppose that, for this example, N is the smallest integer for which xN is less than one-half of the initial amount of radium. This would mean that 1 x0 ≥ (0.99)N x0 , 2 4 Difference Equations Section 1.4 500 400 300 200 100 2000 4000 6000 8000 10000 Figure 1.4.2 Plot of amount of radium versus number of years which implies that 1 ≥ (0.99)N . 2 Taking logarithms, we have 1 ≥ log10 (0.99)N , log10 2 which implies that 1 log10 ≥ N log10 (0.99). 2 Solving for N , and remembering that log10 (0.99) < 0, we have 1 log10 2 N≥ = 68.98, log10 (0.99) rounding to two decimal places. Hence, since N must be an integer, we have N = 69. Recalling that we are working with 25 year units of time, this shows that the half-life of radium is approximately (25)(69) = 1725 years. For example, this means that if we started with an initial amount of 100 grams of radium, after 1725 years we would still have 50 grams left. It would then take an additional 1725 years until the remaining amount would be reduced to 25 grams. Section 1.4 Difference Equations 5 Although we have stated the results of the preceding example in discrete time units, namely, units of 25 years each, later we will see that the results hold for continuous time as well. In other words, although the difference equation (1.4.5) has been set up for nonnegative integer values of n, the solution (1.4.6) is valid for arbitrary nonnegative values of n. We will hold off discussion of these ideas until we consider differential equations, the continuous time versions of difference equations, in Chapter 6. It is interesting to compare the plots in Figures 1.4.1 and 1.4.2. The first is an example of exponential growth, whereas the second is an example of exponential decay. In the first, the steepness of the graph increases with time; in the second, the graph flattens out over time. The difference equation (1.4.3) will always lead to the first behavior when α > 1 and to the second when 0 < α < 1. First-order linear difference equations Given constants α and β, a difference equation of the form xn+1 = αxn + β, (1.4.6) n = 0, 1, 2, . . ., is called a first-order linear difference equation. Note that the difference equation (1.4.3) is of this form with β = 0. A procedure analogous to the method we used to solve (1.4.3) will enable us to solve this equation as well. Namely, xn = αxn−1 + β = α(αxn−2 + β) + β = α2 xn−2 + β(α + 1) = α2 (αxn−3 + β) + β(α + 1) = α3 xn−3 + β(α2 + α + 1) .. . = αn x0 + β(αn−1 + αn−2 + · · · + α2 + α + 1). Note that if α = 1, this gives us xn = x0 + nβ, (1.4.7) n = 0, 1, 2, . . ., as the solution of the difference equation xn+1 = xn + β. If α 6= 1, we know from Section 1.3 that αn−1 + αn−2 + · · · + α2 + α + 1 = Hence n xn = α x0 + β 1 − αn 1−α 1 − αn . 1−α , (1.4.8) n = 0, 1, 2, . . ., is the solution of the first-order linear difference equation xn+1 = αxn + β when α 6= 1. 6 Difference Equations Section 1.4 We have seen examples of first-order linear equations in the population growth and radioactive decay examples above. Another interesting example arises in modeling the change in temperature of an object placed in an environment held at some constant temperature, such as a cup of tea cooling to room temperature or a glass of lemonade warming to room temperature. 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 temperature over one unit of time is given by Tn+1 − Tn = k(Tn − S), (1.4.9) n = 0, 1, 2, . . ., where k is a constant which depends upon the object. This difference equation is known as Newton’s law of cooling. The equation says that the change in temperature over a fixed unit of time is proportional to the difference between the temperature of the object and the temperature of the surrounding environment. That is, large temperature differences result in a faster rate of cooling (or warming) than do small temperature differences. If S is known and enough information is given to determine k, then this equation may be rewritten in the form of a first order-linear difference equation and, hence, solved explicitly. The next example shows how this may be done. Example Suppose a cup of tea, initially at a temperature of 180◦ F, is placed in a room which is held at a constant temperature of 80◦ F. Moreover, suppose that after one minute the tea has cooled to 175◦ F. What will the temperature be after 20 minutes? 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 = 180, T1 = 175, and S = 80. Newton’s law of cooling states that Tn+1 − Tn = k(Tn − 80), (1.4.10) n = 0, 1, 2, . . ., where k is a constant which we will 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. Namely, applying (1.4.10) with n = 0, we must have T1 − T0 = k(T0 − 80). That is, 175 − 180 = k(180 − 80). Hence −5 = 100k, and so k=− 5 = −0.05. 100 Thus (1.4.10) becomes Tn+1 − Tn = −0.05(Tn − 80) = −0.05Tn + 4. Hence Tn+1 = Tn − 0.05Tn + 4 = 0.95Tn + 4 (1.4.11) Section 1.4 Difference Equations 7 200 175 150 125 100 75 50 25 10 20 30 40 50 60 Figure 1.4.3 Tea temperature decreases asymptotically toward room temperature for n = 0, 1, 2, . . .. Now (1.4.11) is in the standard form of a first-order linear difference equation, so from (1.4.8) we know that the solution is 1 − (0.95)n n Tn = (0.95) (180) + 4 1 − 0.95 = 180(0.95)n + 80(1 − (0.95)n ) = 80 + 100(0.95)n for n = 0, 1, 2, . . .. In particular, T20 = 80 + 100(0.95)20 = 115.85, where we have rounded the answer to two decimal places. Hence after 20 minutes the tea has cooled to just under 116◦ F. Also, since lim (0.95)n = 0, n→∞ we see that lim Tn = lim (80 + 100(0.95)n ) = 80. n→∞ n→∞ (1.4.12) That is, as we would expect, the temperature of the tea will approach an equilibrium temperature of 80◦ F, the room temperature. In Figure 1.4.3 we have plotted temperature Tn versus time n for n = 0, 1, 2, . . . , 60, along with the horizontal line T = 80. As indicated by (1.4.12), we can see that Tn decreases asymptotically toward 80◦ F as n increases. 8 Difference Equations Section 1.4 Problems 1. Compute the next five terms of each of the following sequences from the given information. 1 yn (a) x0 = 10, xn+1 = xn + 4 (b) y0 = −1, yn+1 = (c) x0 = 40, xn+1 = 2xn − 20 (d) z0 = 2, zn+1 = zn2 − zn 1 (f) x0 = 15, xn = xn−1 + 2 3 (e) x0 = 2, x1 = 3, xn+2 = xn+1 + xn 2. Solve the following difference equations with the given initial condition. Use your solution to find x10 . (c) xn+1 = 1.8xn + 10, x0 = 20 3 xn , x0 = 100 4 (d) 4xn+1 − 2xn = 12, x0 = 6 (e) xn+1 − xn = 3xn + 4, x0 = 2 (f) 5xn+1 − 3xn = 2xn+1 − xn , x0 = 100 (a) xn+1 = 2xn , x0 = 5 (b) xn+1 = 3. A population of weasels is growing at rate of 3% per year. Let wn be the number of weasels n years from now and suppose that there are currently 350 weasels. (a) Write a difference equation which describes how the population changes from year to year. (b) Solve the difference equation of part (a). If the population growth continues at the rate of 3%, how many weasels will there be 15 years from now? (c) Plot wn versus n for n = 0, 1, 2, . . . , 100. (d) How many years will it take for the population to double? (e) Find lim wn . What does this say about the long-term size of the population? n→∞ Will this really happen? 4. If the rate of growth of the weasel population in Problem 3 was 5% instead of 3%, how many years would it take for the population to double? 5. Suppose that the weasel population of Problem 3 would grow at a rate of 3% a year if left to itself, but poachers kill 6 weasels every year for their fur. (a) Write a difference equation which describes how the population changes from year to year. (b) Solve the difference equation of part (a). How many weasels will there be in 15 years? (c) Find lim wn . What does this say about the long-term size of the population? n→∞ (d) Will the population eventually double? If so, how long will this take? (e) Plot wn versus n for n = 0, 1, 2, . . . , 100. Section 1.4 Difference Equations 9 6. Suppose that the weasel population of Problem 3 would grow at a rate of 3% a year if left to itself, but poachers kill 15 weasels every year for their fur. (a) Write a difference equation which describes how the population changes from year to year. (b) Solve the difference equation of part (a). How many weasels will there be in 15 years? (c) Find lim wn . What does this say about the long-term size of the population? n→∞ (d) Will the population eventually double? If so, how long will this take (e) Will the population eventually die out? If so, how long will this take? (f) Plot wn versus n for n = 0, 1, 2, . . . , 100. 7. A radioactive element is known to decay at the rate of 2% every 20 years. (a) If initially you had 165 grams of this element, how much would you have in 60 years? (b) What is the half-life of this element? (c) Suppose that the bones of a certain animal maintain a constant level of this element while the animal is living, but the element begins to decay as soon as the animal dies. If a bone of this animal is found and is determined to have only 10% of its original level of this element, how old is the bone? 8. Repeat Problem 7 if the element decays at the rate of 3% every 10 years. 9. A cup of coffee has an initial temperature of 165◦ F, but cools to 155◦ F in one minute when placed in a room with a temperature of 70◦ F. Let Tn be the temperature of the coffee after n minutes. (a) Write a difference equation, in standard first order linear form, which describes the change in temperature of the coffee from minute to minute. (b) Solve the difference equation from part (a). (c) Find the temperature of the coffee after 25 minutes. (d) Find lim Tn . n→∞ (e) Plot Tn versus n for n = 0, 1, 2, . . . 120. (f) Does the temperature ever reach 70◦ F? 10. A glass of lemonade, initially at a temperature of 42◦ F, is placed in a room with a temperature of 78◦ F. If the lemonade warms to 45◦ F in 30 seconds, what will its temperature be in 10 minutes? 11. An iron ingot, heated to a temperature of 300◦ C, is placed in a liquid bath held at a constant temperature of 90◦ C. If the ingot cools to 250◦ C in two minutes, what will its temperature be in 20 minutes? 12. A glass of ginger ale is left in a room. Initially, the ginger ale has a temperature of 45◦ F, but after one minute the temperature has increased to 50◦ F and after two minutes it has increased to 54◦ F. What is the temperature of the room? 10 Difference Equations Section 1.4 13. In his book Liber Abaci (Book of the Abacus), Leonardo of Pisa, also know as Fibonacci, posed the following question: How many pairs of rabbits will be produced in a year, beginning with a single pair, if in every month each pair bears a new pair which becomes productive from the second month on? (See A History of Mathematics by Carl B. Boyer, Princeton University Press, 1985, page 281). (a) Let fn be the number of pairs of rabbits in the nth month. Explain why f1 = 1 and f2 = 1. (b) Explain why fn+2 = fn+1 + fn for n = 1, 2, 3, . . .. (c) Compute fn for n = 3, 4, 5, 6, 7, 8 by hand. (d) Compute fn for n = 1, 2, 3, . . . , 100. (e) What is lim fn ? n→∞ (f) Compute rn = fn fn+1 for n = 1, 2, 3, . . . , 100. Do you think lim rn exists? If so, what is a good approxn→∞ imation for this limit to five decimal places? (g) Show that 1 rn+1 = . 1 + rn (h) Using (g) and assuming that lim rn exists, show that n→∞ √ lim rn = n→∞ 5−1 , 2 the golden section ratio. 14. Given x0 = 0 and x10 = 20, show that xn = 2n satisfies the difference equation xn = xn−1 + xn+1 2 for n = 1, 2, 3, . . . , 9. This difference equation is a discrete model for the equilibrium heat distribution along a a straight piece of wire running from 0 to 10 with the temperature at 0 held at 0◦ and the temperature at 10 held at 20◦ . 15. How would the solution to Problem 14 change if we changed the boundary conditions to x0 = 10 and x10 = 50? 16. An approximate solution of a two-dimensional version of the model in Problem 14 may be found using a spreadsheet. For example, you might set cells A1-A20 and H1-H20 equal to 10 and cells B1-G1 and B20-G20 equal to 0. This would represent a flat rectangular piece of metal with the temperature along the vertical sides held fixed at 10◦ and the temperature along the horizontal sides held fixed at 0◦ . Now set the value of every cell inside the rectangle to be equal to the average of the values of its four Section 1.4 Difference Equations 11 neighboring cells. For example, you would put the formula (A2+C2+B1+B3)/4 in cell B2 and then copy this cell to all the cells in the block from B2 to G19. Now have the spreadsheet repeatedly compute the values of the cells until they stabilize (that is, until they no longer change values when you recompute). If you format the cell values so that they are all integers, this should not take too long. What you have now is the equilibrium heat distribution for the metal plate. Now try different boundary conditions to obtain different equilibrium heat distributions.