M2280 - 2 FIRST MAPLE ASSIGNMENT Treibergs Due Jan. 22, 2001. In the first assignment, we shall explore some basic MAPLE capabilities in solving differential equations. If you are unfamiliar with MAPLE, you should work through Prof. Korevaar's MAPLE introduction (http://www.math.utah.edu/~korevaar/2250fall01/2250falltut.mws - versions for .txt and .pdf are also available.) He develops enough tools for doing the third exercise, about the variation of the inside temperature of an unheated Salt Lake City apartment due to outside temperature variations. This follows the Computing Project 1.5 from the text by Edwards and Penney. We start by solving differential equations, following Computer Project 1.6. We illustrate some basic MAPLE constructs. Suppose we wished to check that y(x)= 5e^(3x) - 6e^(-4x) - x^3/12 - x^2/48 - 13 x^2/288 -25/3456 satisfies the differential equation y'' + y' - 12 y - x^3 = 0. Enter a function y(x). Recall that := is the assignment operator, thus the function is named y. > y:= x->5*exp(3*x)-6*exp(-4*x)-x^3/12-x^2/48-13*x/288-25/3456; y := x -> 3 2 13 25 5 exp(3 x) - 6 exp(-4 x) - 1/12 x - 1/48 x - --- x - ---- 288 3456 The value of the function along with the first derivative at zero is > y(0);D(y)(0); -3481 ----- 3456 11219 ----- 288 We form the differential expression, where diff(y(x),x,x) means differentiate the expression y(x) with respect to x twice. > diff(y(x),x,x)+diff(y(x),x) - 12*y(x); 3 x The result is x^3, which is the desired one. We'll see another way to check later, using odetest. Suppose that we wished to show that z(x)= x e^x satisfies x^2 z'' - x(x+1)z' + z = 0 , > z:= x->x*exp(x); z := x -> x exp(x) > x^2*diff(z(x),x,x)-x*(x+1)*diff(z(x),x)+z(x); 2 x (2 exp(x) + x exp(x)) - x (x + 1) (exp(x) + x exp(x)) + x exp(x) This is too complicated. MAPLE can simplify expressions in a number of ways. One way to try is to call the operation simplify(% ). % is MAPLE's way of referring to the previously displayed experession. Simplification yields zero, so the expression is a solution. > simplify(%); 0 There are strong ODE specific tools. First the ODE library is loaded. Then a variable eq1 is storeded with a differential equation involving the unknown expression u(x). I did not call the function y(x) because this already has a different meaning for MAPLE. > with(DEtools): > eq1:= diff(u(x),x,x)+diff(u(x),x) - 12*u(x)-x^3=0; / 2 \ |d | /d \ 3 eq1 := |--- u(x)| + |-- u(x)| - 12 u(x) - x = 0 | 2 | \dx / \dx / Now we see some of MAPLE'S power. Invoking the DE solver we look for the general solution of the ODE. > dsolve(eq1); 25 13 2 3 u(x) = - ---- - --- x - 1/48 x - 1/12 x + _C1 exp(3 x) 3456 288 + _C2 exp(-4 x) WOW! This is the general solution, where _C1 and _C2 are constants of integration. If we wish to add initial conditions, we can. Trying the initial conditions from before, > sol1:=dsolve({eq1,u(0)=-3481/3456, D(u)(0)=11219/288}); sol1 := u(x) = 25 13 2 3 - ---- - --- x - 1/48 x - 1/12 x + 5 exp(3 x) - 6 exp(-4 x) 3456 288 Thus MAPLE finds the solution from the ODE and IC. DEtools also has a routine that plugs functions into differential equations, which we did above in a more bare-hands way. It is the procedure odetest. > odetest(sol1,eq1); 0 From page 71, > dsolve(D(v)(x)-sin(x - v(x)),v(x)); x - 2 - _C1 v(x) = x - 2 arctan(-----------) x - _C1 > M2280 - 2 FIRST MAPLE LAB QUESTIONS. Be sure your name and student number are on your paper. Do not hand in your working through my example problems. Write up solutions in a self contained manner. Use enough comments to explain your analysis. Have MAPLE produce the solutions and graphs. Hand in a printed hard copy of your solutions. 1. Use MAPLE to solve any one of the problems on page 69. 2. Do the investigation from p. 73. Choose numbers p,q two nonzero distinct digits. consider the DE y' = cos( x - qy) / p. (DE) a. Find a symbolic general solution using MAPLE and the techniques listed in the project. b. Determine a symbolic particular solution corresponding to y(x_0)=y_0 for several typical choices of x_0 and y_0. c. Determine the possible values of a and b such that y = a x + b is a solution of (DE). d. Plot the direction field and some typical solution curves. Can you identify the graphs with the symbolic solutions from part b? 3. (Taken from Korevaar's M2250 fall 2001) You are to do the section 1.5 computer project. A preliminary discussion, in which the text discussion of pages 55-57 is expanded to include Maple commands, is found at the end of Prof. Korevaar's tutorial which accompanies this project. It is assumed that you have already worked through that. SCENARIO: It is not summer in Georgia. It is winter in Salt Lake City. We will dream it is early spring, (around equinox), and that the 5-day forecast in the newspaper says the weather will be stable, with lows of 26 degrees, and highs of 60 degrees. As in the text and for the sake of simplicity, we will assume a sinusoidal daily temperature oscillation, except our low will be at 2 a.m, and our high will be at 2 p.m. We must leave town for 3 days, and are deciding whether to turn off the heat while we are gone. The question we wonder about is, will the water pipes in the house freeze if we do turn off the heat? a. Review the model which leads to equation (3) on page 56. Use integrals #49 and 50 and the algorithm for solving first order linear DE's on pages 44-45, to solve (3) by hand, keeping all parameters as letters. Staple your work onto the printout of your completed project which you hand in. Your answer should agree with equation (4) on page 56. You will see that the constant c0 in that answer is the constant C of integration you obtain when you follow the solution recipe for linear DE's. You find its value in terms of the initial condition u(0)=u0 by pluggin in u=u0, t=0, as usual. You will discover that the text writes c0 incorrectly: there is a hidden minus sign which has become glued to the fraction which follows a0, in the book's formula, i.e. the correct formula for c0 is > c[0] := (k*omega*b[1]-k^2*a[1])/(k^2+omega^2)+u[0]-a[0]; b. Use dsolve to have Maple find the solution to (3), with u(0)=u0. You might have already done this in the tutorial, in which case you can copy the appropriate commands from there, paste them in here, and re-execute them. Check that your solution agrees with your hand work above, as well as the (corrected) text. c. Figure out the parameter values for the Salt Lake City temperature, as modeled above. Of course, omega will still be Pi/12, but now you have different daily average temperature, amplitude, and phase than was used in equation (2) on page 56, when summer in Georgia was being modeled. Fill the new values in below. Then work out by hand, using the cosine addition formula, the values you should take for a0, a1, b1, so that A(t) is given by (1) on page 56, and so that the differential equation (3) also has the correct parameter values. Include in your writeup: # # Average Temperature = # Temperature variation amplitude = # Phase delay (was 4 hours in Georgia example) = # > omega:=Pi/12.0; > a0:= > #don't forget the semicolons > a1:= > b1:= > A:=t->a0 + a1*cos(omega*t) + b1*sin(omega*t); # We will assume your house is moderately well-insulated, so that k=0.3: > k:=0.3; d. Find the solution to (3) with the particular parameter choices you made above. You should get a solution function like (5) on page 56, but reflecting the Salt Lake City temperatures and the new insulation parameter. e. Identify the part of your solution which persists as t approaches infinity, i.e. the steady periodic solution. Your formula should have the same character as equation (6) on page 57. f. Write the steady periodic solution in the form of equation (7) on page 57, so that you can see the time delay for the inside temperature. You need to use the cosine addition formula. The text has a discussion on page 315 which may help you. It is shown there that if > x(t) := A*cos(omega*t)+B*sin(omega*t); then also > x(t) := t -> C*cos(omega*t-alpha); where the right triangle of Figure 5.4.4 page 315 summarizes the relationships between A,B, C, and alpha. g. Assume that your heater shut off at midnight, with the inside temperature equal to 70 degrees. Create a plot like Figure 1.5.10 which displays the inside temperature and the outside ambient temperature for the next three days. h. Create a picture like Figure 1.5.9, which also includes the slope field for this differential equation, with our Salt Lake City parameters. Choose initial temperatures between 40 and 70 degrees, in 5 degree increments. Label the maximum and minimum temperature times by hand, on the display printout, before you hand in the project. i. So, based on your work in this project, how likely do you think it is that the pipes will freeze if the heater is turned off for 3 days starting at midnight? Explain your reasoning.