a a The explicit Euler can be written for this problem as

214 The first step is taken with the fourth-order RK: 1 1 1 1 , 2 1 − = − = = f k 875 . 125 . 1 1 125 . = − = y 861328 . 875 . , 125 . 2 − = = f k 89233 . 125 . 861328 . 1 125 . = − = y 87839 . 89233 . , 125 . 3 − = = f k 78040 . 25 . 87839 . 1 25 . = − = y 73163 . 78040 . , 25 . 4 − = = f k 86851 . 6 73163 . 87839 . 861328 . 2 1 − = − − − + − = φ 0.7828723 25 . 86851 . 1 25 . = − = y This result compares favorably with the analytical solution. The second step can then be implemented with the non-self-starting Heun method: Predictor: 633028629 . 5 . 7828723 . 25 . 7828723 . 1 5 . 2 = − + = y Corrector: First iteration: 63178298 . 25 . 2 633028629 . 5 . 633028629 . 7339 . 7828723 . 5 . 2 = − + − + = y Corrector: Second iteration: 0.63189976 25 . 2 63178298 . 5 . 63178298 . 7339 . 7828723 . 5 . 2 = − + − + = y The iterative process can be continued with the final result converging on 0.63188975.

19.5 a

h 2100,000 = 2 × 10 −5 . b The implicit Euler can be written for this problem as h e y y y i t i i i 1 999 , 99 000 , 100 1 1 + − + + + − + = 215 which can be solved for h h e y y i t i i 000 , 100 1 999 , 99 1 1 + + = + − + The results of applying this formula for the first few steps are shown below. A plot of the entire solution is also displayed t y 0 0 0.1 1.904638 0.2 1.818731 0.3 1.740819 0.4 1.67032 0.5 1.606531 1 2 1 2 19.6 The implicit Euler can be written for this problem as h t y t y y i i i i i 1 1 1 1 cos 3 sin 30 + + + + + − + = which can be solved for h h t h t y y i i i i 30 1 cos 3 sin 30 1 1 1 + + + = + + + The results of applying this formula are tabulated and graphed below. t y t y t y t y 0 0 1.2 0.952306 2.4 0.622925 3.6 -0.50089 0.4 0.444484 1.6 0.993242 2.8 0.270163 4 -0.79745 0.8 0.760677 2 0.877341 3.2 -0.12525 216 -1 -0.5

0.5 1

1.5 1 2 3 4

19.7 a The explicit Euler can be written for this problem as

h x x x x i i i i , 2 , 1 , 1 1 , 1 1999 999 + + = + h x x x x i i i i , 2 , 1 , 2 1 , 2 2000 1000 − − + = + Because the step-size is much too large for the stability requirements, the solution is unstable, t x 1 x 2 dx 1 dt dx2dt 0 1 1 2998 -3000 0.05 150.9 -149 -147102 147100 0.1 -7204.2 7206 7207803 -7207805 0.15 353186 -353184 -3.5E+08 3.53E+08 0.2 -1.7E+07 17305943 1.73E+10 -1.7E+10 b The implicit Euler can be written for this problem as x x x x h i i i i 1 1 1 1 1 2 1 999 1999 , , , , + + + = + + x x x x h i i i i 2 1 2 1 1 2 1 1000 2000 , , , , + + + = + − − or collecting terms , , , , , , 1 999 1999 1000 1 2000 1 1 2 1 1 1 1 2 1 2 − − = + + = + + + + h x hx x hx h x x i i i i i i or substituting h = 0.05 and expressing in matrix format − − ⎡ ⎣⎢ ⎤ ⎦⎥ ⎧ ⎨ ⎩ ⎫ ⎬ ⎭ = ⎧⎨ ⎩ ⎫ ⎬ ⎭ + + 48 95 99 95 50 101 1 1 2 1 1 2 . . , , , , x x x x i i i i Thus, to solve for the first time step, we substitute the initial conditions for the right-hand side and solve the 2x2 system of equations. The best way to do this is with LU decomposition since we will have to solve the system repeatedly. For the present case, because its easier to display, we will use the matrix inverse to obtain the solution. Thus, if the matrix is inverted, the solution for the first step amounts to the matrix multiplication, 217 { } { } x x i i 1 1 2 1 1886088 186648 0 93371 0 9141 1 1 3 752568 184781 , , . . . . . . + + ⎧ ⎨ ⎩ ⎫ ⎬ ⎭ = − − ⎡ ⎣⎢ ⎤ ⎦⎥ = − For the second step from x = 0.05 to 0.1, { } { } x x i i 1 1 2 1 1886088 186648 0 93371 0 9141 3 752568 184781 3 62878 181472 , , . . . . . . . . + + ⎧ ⎨ ⎩ ⎫ ⎬ ⎭ = − − ⎡ ⎣⎢ ⎤ ⎦⎥ − = − The remaining steps can be implemented in a similar fashion to give t x 1 x 2 0 1 1 0.05 3.752568 -1.84781 0.1 3.62878 -1.81472 0.15 3.457057 -1.72938 0.2 3.292457 -1.64705 The results are plotted below, along with a solution with the explicit Euler using a step of 0.0005. -2 2 4

0.1 0.2

x 1 x 2 19.8 a The exact solution is 08 . 4 . 2 5 + + + = t t Ae y t If the initial condition at t = 0 is 0.8, A = 0, 08 . 4 . 2 + + = t t y Note that even though the choice of the initial condition removes the positive exponential terms, it still lurks in the background. Very tiny round off errors in the numerical solutions bring it to the fore. Hence all of the following solutions eventually diverge from the analytical solution. b 4 th order RK. The plot shows the numerical solution bold line along with the exact solution fine line. 218 -10 -5 5 10 15 1 2 3 4 c function yp = dyt,y yp = 5y-t2; tspan = [0,5]; y0 = 0.08; [t,y] = ode45dy1,tspan,y0; d [t,y] = ode23sdy1,tspan,y0; e [t,y] = ode23tbdy1,tspan,y0; -30 -20 -10 10 20 30 1 2 3 4 5 RK4 Analytical ODE45 ODE23s ODE23tb

19.9 a As in Example 17.5, the humps function can be integrated with the quad function as in