College of Engineering and Computer ScienceMechanical Engineering DepartmentMechanical Engineering 501ASeminar in Engineering AnalysisFall 2004 Number: 17472 Instructor: Larry CarettoNovember 16 Homework SolutionsKreyszig, page 955, problem 5 – Solve the problem y’ = -0.2xy with y(0) = 1 for ten steps, with h = 0.1, using the Adams-Moulton method. Compare the errors with the exact solution. Use the Runge-Kutta method to get the starting values.The exact solution can be found by separating the differential equation. This gives dy/y = -0.2xdxso that ln y = -0.1 x2 + C. Setting y(0) = 1 gives ln(1) = 0 + C or C = 0. Thus, the exact solution isy = e-0.1x2. The Adam-Moulton method uses the following algorithm. First we predict a new value at the forward (i+1) step. iiiiiPiffffhyy 5559379241231The derivative at xi+1, computed with this predicted y value is then used to obtain the final (corrected) value of yi+1 by the following equation. ),(91952411121PiiiiiiCiyxffffhyySince this algorithm depends on having values at three previous steps, we need a starting method, for which we can use the fourth-order Runge-Kutta algorithm, shown below.),(2,22,2),(622311421131112111143211kyhxfhkkyhxfhkkyhxfhkyxfhkhxxkkkkyyiiiiiiiiiiiiiiiiiiiiFor this problem, fi = -0.2xiyi, and we use this in computing the various fi terms in both algorithms. Here we have to use the Runge-Kutta algorithm to get enough values of fi to start the Adams-Moulton method. The details of this calculation are shown in the table below. In this table, the initial conditions are shown in the first row. This row shows the k values required to compute y1, the first value computed in the Runge-Kutta solution. The actual value of y1 is shown in the second row. This process continues until the k values in the row for i = 2 are used to compute the value of y3. i xiyiexact yierror fik1k2k3k4Engineering Building Room 1333 Mail Code Phone: 818.677.6448Email: [email protected] 8348 Fax: 818.677.70620 0 1 1 0 0 0 -0.004 -0.00399 -0.007971 0.2 0.996008 0.996008 1.07E-11 -0.03984 -0.00797 -0.0119 -0.01188 -0.015752 0.4 0.984127 0.984127 1.04E-10 -0.07873 -0.01575 -0.01953 -0.01949 -0.023153 0.6 0.96464 0.96464 3.38E-10 -0.11576The values of y3 and x3 in this table are used to compute f3, which is required in the Adams-Moulton procedure. The first step in this procedure is shown in detail below. Here, we take the general formulas on the previous page and apply them for i = 3. 93801.0)11576.0(55)07873.0(59)03984.0(37)0(9242.0960795.0555937924321034 ffffhyyPWe can use this predicted value to compute the estimated derivate at point i + 1, using the formula that f = -0.2xy for the differential equation considered here. 15008.0)93801.0)(8.0)(2.0(2.0,1111PiiPiiyxyxfWith this derivative value we can apply the corrector equation to compute the final value for y4. (Here again we apply the general formula from the previous page for i = 3.) 936833.0)15008.0(9)11576.0(19)07873.0(5)03984.0(242.0960795.0),(9195244432134PCyxffffhyyThe results of these calculations to get y4 and the results of subsequent steps are shown in the table below. Note that each new step in the Adams method starts with an evaluation of the derivative, fn, based on the values of xn and ynC. The derivative evaluation based on the predictor is not used to start the new step.i xiyiexact yierror fiPiy1 Piiyxf11,0 0 1 1 0 01 0.2 0.996008 0.996008 1.07E-11 -0.039842 0.4 0.984127 0.984127 1.04E-10 -0.078733 0.6 0.96464 0.964640 3.38E-10 -0.11576 0.93801 -0.150084 0.8 0.938004 0.938005 5.7E-07 -0.15008 0.904844 -0.180975 1 0.904836 0.904837 1.31E-06 -0.18097 0.865896 -0.207816 1.2 0.865886 0.865888 2.18E-06 -0.20781 0.822021 -0.230177 1.4 0.822009 0.822012 3.13E-06 -0.23016 0.77415 -0.247738 1.6 0.774138 0.774142 4.07E-06 -0.24772 0.723258 -0.260379 1.8 0.723245 0.72325 4.96E-06 -0.26037 0.670327 -0.2681310 2 0.670314 0.67032 5.73E-06 -0.26813 0.616318 -0.2711811 2.2 0.616307 0.616313 6.32E-06 -0.27118 0.562146 -0.2698312 2.4 0.562136 0.562142 6.69E-06 -0.26983 0.508649 -0.264513 2.6 0.508641 0.508648 6.82E-06 -0.26449Hoffman, page 424, problem 161 – Solve the problem y’ = ty2 with y(0) = 1 from t = 0 to t = 1 using h = 0.2 and h = 0.1. Use the exact solution y = -2/(t2 – 2/y0) to compute the ratio of Engineering Building Room 1333 Mail Code Phone: 818.677.6448Email: [email protected] 8348 Fax: 818.677.7062the errors for the two step sizes at t = 1. Use the implicit Euler method with time linearization.The implicit Euler method is given by the equation yn+1 = yn + hfn+1. With time linearization we write the derivative function in a Taylor series and drop all terms that are O(h2).. )(211hOyyyfhtfffnnnnnnSubstituting this result into the implicit Euler equation and rearranging gives. nnnnnnnnnyyyfhtffhyhfyy111 nnnnnnnnnnnnyfhtfhhfyyyyyfhtfhhfyy121121We can use the following expression to advance one time step: nnnnnyfhtfhhfyy121.For this problem, f = ty2, ∂f/∂t = y2 and ∂f/∂y = 2ty. Substituting these values into the general implicit Euler expression with time linearization gives the following equation to be solved for this problem.nnnnnnnythyhyhtyy212221The first two steps with h = 0.2 give the following results.04.1)1)(0)(2.0(21)1()2.0()1)(0)(2.0(1212220020220001yhtyhyhtyy13438.1)04.1)(2.0)(2.0(21)04.1()2.0()04.1)(2.0)(2.0(1212221121221112yhtyhyhtyyThe table below shows the results from the two steps above as well as the remaining steps to theend of the integration at t = 1. At this point the exact solution is y = -2/(1 – 2) = 2 and the error is 1.0829n t y f df/dt df/dy0 0 1 0 1 01 0.2 1.04 0.21632 1.0816 0.4162 0.4 1.13438 0.514728 1.286819 0.9075043 0.6 1.323041 1.050262 1.750437 1.587649Engineering Building Room 1333 Mail Code Phone: 818.677.6448Email: [email protected] 8348 Fax: 818.677.70624 0.8 1.733417 2.403789 3.004736
View Full Document