Homework Numerical Diff Eq

download Homework Numerical Diff Eq

of 24

  • date post

    08-Oct-2014
  • Category

    Documents

  • view

    25
  • download

    3

Embed Size (px)

Transcript of Homework Numerical Diff Eq

MATH 337.A Numerical Dierential EquationsSpring 2010HW # 0Due: 01/25/10Problem 1Find the explicit form of the cubic term (i.e. the term with (x)n(y)m, n + m = 3) in expansion(0.6).Problem 2Find the Lipschitz constant L for:(a) f(x, y) = xy2on R : 0 x 3, 1 y 5;(b) f(x, y) = x +[ sin 2y[ on R : 0 x 3, y .Hint: See Remarks after the Theorem.Problem 3Solve the IVPy

= 2y + e3x, y(1) = 4 .Problem 4Findlimh0_ 11 2h_/h.HW # 1Due: 02/01/10Problem 1Consider an IVPy

= ay, y(x0) = y0,where a is a constant. Following the lines of the derivation of the global error (see Eq. (1.4)), nd howthe sign of the global error will depend on the signs of a and y0.Note 1: If the signs of the local truncation error at each iteration are the same, then the sign of theglobal error will be the same as the sign of the local truncation errors1.Note 2: For f(x, y) = ay, one can do more explicit calculations than in Sec. 1.3, and it will be possibleto establish the sign of the error.Verify your answer by solving the above IVP for x [0, 1] 2using the simple Euler method in 4cases: (i) a = 1, y0=1; (ii) a = 1, y0 = 1; (iii) a = 1, y0=1; (iv) a = 1, y0 = 1. Use h = 0.1.Problem 2Find coecient B for the Midpoint method (1.19). Follow the lines of the derivation of coecient Afor the Modied Euler method.Problem 3Derive the expression for the local truncation error of the Midpoint method. Follow the lines of thesimilar derivation for the Modied Euler method.Problem 4The exact (and unique) solution of the IVPy

=y, y(0) = 1is y = (x + 2)2/4. Solve the above IVP for x [0, 1] using three methods: simple Euler, ModiedEuler, and Midpoint. In each case, use two values for the step size: h = 0.1 and h = 0.05. Make atable that will show the error of your numerical solution at x = 1 (i.e., the global error) versus themethod used and the step size. By what factor does the error decrease when the step size decreasesfrom 0.1 to 0.05? (Problem 4 is continued on the next page.)1An additional condition that is required for this to hold is (1 +ah) > 0 (you will see that when you will have carriedout the derivation). Assume that this condition holds for the case(s) in question.2Thus, the initial and nal points of the computation are x0 = 0 and xnal = 1.1Are your results consistent with the expressions for the local truncation errors of these three meth-ods, derived in Lecture 1 and in Problem 3 above? Namely:(i) Do the dependences of these errors on h agree with the theoretical predictions?(ii) Does the sign of the error for the simple Euler method agree with that which follows from thederivation in Sec. 1.3 for this specic y(x)?(iii) Do the signs and relative magnitudes of the errors of the Modied Euler and Midpoint methodsagree with the result of Sec. 1.6 and your result in Problem 3?Problem 5 A sky diver jumps from a plane. Assume that during the time before the parachuteopens, the air resistance is proportional to the divers velocity v. (In reality, it is proportional to vawith a > 1, but we sacrice the physics in exchange for being able to obtain a simple analytical solutionto this problem.)Write down the ODE for the divers velocity. Supply the numerical values for the coecients inthis ODE if it is known that the maximum divers velocity is 80 mph. (This velocity could be achievedonly asymptotically, assuming that the diver will be falling down forever.)Solve the above ODE, assuming that the divers initial velocity is zero. First, nd the analyticalsolution. Then, solve the corresponding IVP by the Modied Euler method for the rst 2 seconds ofthe divers fall. Use the step size of 0.2 sec. Plot both solutions in the same gure.HW # 2Due: 02/05/10Problem 1Derive Eqs. (2.4). Follow the lines of the derivation of coecient A in Sec. 1.4. (In fact, Eq. (1.21)should be used without any changes.)Problem 2(a) Write a function le named yourname_cRK.m that can integrate any given IVP y

= f(x, y),y(x0) = y0 using the classical Runge-Kutta method.Suggestion: You may use as an example a sample codes that invokes the simple Euler method tointegrate the above IVP. These codes are posted on the course website.(b) Consider the IVP you derived in Problem 5 of HW# 1. Solve it using the function yourname_cRK.mwith the same step size as in HW# 1 (i.e., 0.2 sec). Plot your numerical solution along with the exactone. Also, compare the nal error of the cRK method with the error of the Modied Euler method,obtained in HW# 1.Problem 3Consider the following modication of Problem 5 in HW# 1. Asume that at t = 2 sec, the parachuteopens. This results in the air resistance coecient changing abruptly in such a way that the maximumpossible velocity of the parachutist is now 4 mph (versus 80 mph without the parachute).Find the numerical value of the new air resistance coecient and then analytically solve the modiedODE up to t = 4 sec (i.e., the rst 2 seconds without a parachute, as in HW# 1, and the last 2seconds with the parachute). [Hint: You will need to simply patch two analytical solutions in theaforementioned time intervals.]Solve the above IVP up to t = 4 sec using the cRK (and the function le you wrote in Problem 2)with the step sizes of 0.2 sec and 4/21 sec (note that 4/21 < 0.2). Plot the exact and the two numericalsolutions in the same gure. Compute the error for all t [0, 4 sec] and plot it (in a separate gure).Technical note:You will need to supply a function on the r.h.s. of your ODE to yourname_cRK.m. Since this functionis discontinuous at t = 2, the best way to dene it is in a separate M-le. Specically, create an M-leand name it, say, yourname_fun4_hw2_p3. Type the following into the le:function f=yourname_fun4_hw2_p3(t,y)if t >= 0 & t < 2f= "r.h.s. of ODE before parachute opens";elsef= "r.h.s. of ODE after parachute opens";end2(Of course, you supply the actual expressions on the r.h.s.. Please use the same name for your functionas the name of the M-le you store it in.)Problem 4 (worth 2 points)Solve the IVP in Problem 3 above by the Runge-Kutta-Fehlberg method, assuming the accuracyloc = 103mph. Use = 0.8 ( is dened in Sec. 2.2). Plot both the exact and numerical solutionsin the same gure. Compute the error for all t [0, 4 sec] and plot it in a separate gure.Technical notes:1. In order to compute the error for all t, you will have to compute the exact solution on the gridwhich you will create while computing the numerical solution. So, at each step, record the computedvalue of t at this step.2. To plot the analytical solution on the numerically determined t-drig, you will need a numericallydetermined value of the time when the parachute opens. You may obtain its record as follows. At theend of the part of the loop where you compute the solution before the parachute opens, have a linelike topen_numeric=t(i); (you may need to adjust the index i to be consistent with what youare doing in your code). Then topen_numeric will continue being updated until the moment theparachute opens, and so the last recorded value of topen_numeric will be a very good approximationof the opening time.Problem 5Repeat Problem 4 using MATLABs built-in ODE-solver ode45. To see its syntax, type help ode45at MATLABs prompt. As the function for the ode45, supply the same function le as for Problem 3above.Plot both the exact and numerical solutions in the same gure. Compute the error for all t [0, 4 sec] and plot it in a separate gure.Problem 6In a single gure, plot the errors of the numerical solutions obtained in Problems 35. State how thesemethods perform for this ODE relative to one another.Hint: You may rst save the error (or the solution) for each case in a separate le using the commandsave and then load these les (one by one), using the command load, to plot the errors. Typehelp save or help load to nd out the syntax of these commands.Bonus3(worth 0.5 point)Compare the speeds of Runge-Kutta-Fehlberg and ode45 methods. Specically, do the following. First,put your codes for each of these methods into a loop, so that the same calculation is repeated 200times (this is needed for statistical averaging, since the computational speed will uctuate from run torun). Second, use any of the following 3 commands: etime, cputime, or tic and toc. Examples oftheir usage can be found by typing help tic, etc. Which of the two methods appears to be faster?Note: To receive full credit for this problem, you must submit its code(s) to me.HW # 3Due: 02/10/10Problem 1Using Taylor expansions of y

i1 and y

i2 about x = xi, verify thaty

i = y

i2y

i1 + y

i2h2 + O(h) .Problem 2Obtain the counterpart of the linear system (3.15) without assuming that xi = 0. Verify that it actuallycoincides with (3.15).Problem 3Find the coecients b1, b0, b1 inYi+1 = Yi + h(b1fi+1 + b0fi + b1fi1)3The following applies to any Bonus problem assigned in this course. (i) A Bonus problem is considered to be worthone regular problem unless stated otherwise. (ii) A Bonus problem must be done mostly correctly to receive nonzerocredit; that is, no extra credit for it will be given if its solution has major errors or gaps.3that produce a 3rd-order method (called the 3rd-order Adams-Moulton method). Use a technique fromeither Secs. 3.1 or 3.2 (your choice).Problem 4Us