Download Solving First-Order Differential Equations using Euler's Method: A Homework Problem - Prof and more Assignments Mathematics in PDF only on Docsity! Co py rig ht (c) 20 08 Ke vin Lo ng Homework 4, Math 3350 Prof. Kevin Long Assigned problems • 1.4: problems 5 and 6. You will need a calculator or computer to do these problems. • Compute approximate numerical solutions to the following IVPs using Euler’s method. 1. dydx = − 1 2y with y(0) = 1. 2. dydx = − y 1+x with y(0) = 1. Unlike the problems in the book, these problems are rigged to be reasonable for hand calculation through a few steps. For each of these two problems, do the following: 1. Find the exact solutions, and compute (using a calculator if necessary) their numerical values at x = 0.4. 2. Compute an approximate numerical solution at x = 0.4 by making one step of Euler’s method with stepsize h = 0.4. Do this calculation by hand, i.e., without a calculator. 3. Compute an approximate numerical solution at x = 0.4 by making two steps of Euler’s method with stepsize h = 0.2. Do this calculation by hand, i.e., without a calculator. 4. Compute an approximate numerical solution at x = 0.4 by making four steps of Euler’s method with stepsize h = 0.1. Unless your skill at hand calculation is significantly better than mine, you’ll probably want to use a calculator for this one. 5. For each of the three approximate numerical solutions you computed, measure the absolute value of the approximation error, Eh(x) = |yexact(x)− yEuler,h(x)| at x = 0.4. 1 Co py rig ht (c) 20 08 Ke vin Lo ng Solutions to odd problems Problem 1 When doing a numerical solution by hand (or with a calculator) it’s a good idea to draw a worksheet like those shown below; having all intermediate results in a table helps keep your calculations organized. In each table, the Euler approximation to y(0.4) is enclosed in a box. • Numerical solution with h = 0.4. This is easy. i xi yi f(xi, yi) hf(xi, yi) yi + hf(xi, yi) 0 0.00 1.000000000000 -0.500000000000 -0.200000000000 0.800000000000 1 0.40 0.800000000000 • Numerical solution with h = 0.2. You should be prepared to do a numerical solution of roughly this complexity by hand (i.e., no calculators!) on a quiz and/or test. i xi yi f(xi, yi) hf(xi, yi) yi + hf(xi, yi) 0 0.00 1.000000000000 -0.500000000000 -0.100000000000 0.900000000000 1 0.20 0.900000000000 -0.450000000000 -0.090000000000 0.810000000000 2 0.40 0.810000000000 • Numerical solution with h = 0.1. This is getting complicated enough that a computer, or at least a calculator, is pretty much essential. I tried it by hand, and mistakenly put −0.450125 instead of −0.45125 for the fourth entry in the third row. After that, the entire calculation was ruined despite making no further errors. The table shown was done with a calculator. i xi yi f(xi, yi) hf(xi, yi) yi + hf(xi, yi) 0 0.00 1.000000000000 -0.500000000000 -0.050000000000 0.950000000000 1 0.10 0.950000000000 -0.475000000000 -0. 47500000000 0.902500000000 2 0.20 0.902500000000 -0.451250000000 -0.045125000000 0.857375000000 3 0.30 0.857375000000 -0.428687500000 -0.042868750000 0.814506250000 4 0.40 0.814506250000 Exact solution The exact solution is y(x) = e−x/2. You should recognize that the problem is linear and also separable, and by this point should be able to solve it using either separation of variables or the standard method for solving first-order linear equations. You should also be able to check that my solution is in fact correct. The numerical value of the solution at x = 0.4 is 0.818730753078 · · · , which you can compute using your calculator, Mathematica, or Matlab. Error analysis The table shows how the absolute error at x = 0.4 decreases as the stepsize h decreases. h yEuler(0.4) yexact(0.4) |yexact(0.4)− yEuler,h(0.4)| 0.4 0.800000000000 0.818730753078 0.018730753078 0.2 0.810000000000 0.818730753078 0.008730753078 0.1 0.814506250000 0.818730753078 0.004224503078 2