3.3 The Runge-Kutta Method

In general, if \(k\) is any positive integer and \(f\) satisfies appropriate assumptions, there are numerical methods with local truncation error \(O(h^{k+1})\) for solving an initial value problem

\begin{equation} y'=f(x,y),\quad y(x_0)=y_0. \tag{3.3.1}\end{equation}

Moreover, it can be shown that a method with local truncation error \(O(h^{k+1})\) has global truncation error \(O(h^k)\). In Sections 3.1 and 3.2 we studied numerical methods where \(k=1\) and \(k=2\). We’ll skip methods for which \(k=3\) and proceed to the Runge-Kutta method, the most widely used method, for which \(k=4\). The magnitude of the local truncation error is determined by the fifth derivative \(y^{(5)}\) of the solution of the initial value problem. Therefore the local truncation error will be larger where \(|y^{(5)}|\) is large, or smaller where \(|y^{(5)}|\) is small. The Runge-Kutta method computes approximate values \(y_1\), \(y_2\), …, \(y_n\) of the solution of (3.3.1) at \(x_0\), \(x_0+h\), …, \(x_0+nh\) as follows: Given \(y_i\), compute

\begin{eqnarray*} k_{1i}&=&f(x_i,y_i), \\ k_{2i}&=&f\left(x_i+{h\over2},y_i+{h\over2}k_{1i}\right), \\ k_{3i}&=&f\left(x_i+{h\over2},y_i+{h\over2}k_{2i}\right), \\ k_{4i}&=&f(x_i+h,y_i+hk_{3i}), \end{eqnarray*}

and

\[ y_{i+1}=y_i+{h\over6}(k_{1i}+2k_{2i}+2k_{3i}+k_{4i}). \]

The next example, which deals with the initial value problem considered in Examples 3.1.1 and 3.2.1, illustrates the computational procedure indicated in the Runge-Kutta method.

Example 3.3.1

Use the Runge-Kutta method with \(h=0.1\) to find approximate values for the solution of the initial value problem

\begin{equation} y'+2y=x^3e^{-2x},\quad y(0)=1, \tag{3.3.2}\end{equation}

at \(x=0.1,0.2\).

Solution Again we rewrite (3.3.2) as

\[ y'=-2y+x^3e^{-2x},\quad y(0)=1, \]

which is of the form (3.3.1), with

\[ f(x,y)=-2y+x^3e^{-2x},\ x_0=0,\mbox{\ and}\ y_0=1. \]

The Runge-Kutta method yields

\begin{eqnarray*} k_{10} & = & f(x_0,y_0) = f(0,1)=-2, \\ k_{20} & = & f(x_0+h/2,y_0+hk_{10}/2)=f(.05,1+(.05)(-2)) \\ &=& f(.05,.9)=-2(.9)+(.05)^3e^{-.1}=-1.799886895, \\ k_{30} & = & f(x_0+h/2,y_0+hk_{20}/2)=f(.05,1+(.05)(-1.799886895)) \\ &=& f(.05,.910005655)=-2(.910005655)+(.05)^3e^{-.1}=-1.819898206, \\ k_{40} & = & f(x_0+h,y_0+hk_{30})=f(.1,1+(.1)(-1.819898206)) \\ &=&f(.1,.818010179)=-2(.818010179)+(.1)^3e^{-.2}=-1.635201628, \\ y_1&=&y_0+{h\over6}(k_{10}+2k_{20}+2k_{30}+k_{40}), \\ &=&1+{.1\over6}(-2+2(-1.799886895)+2(-1.819898206) -1.635201628)=.818753803, \\[12pt] k_{11} & = & f(x_1,y_1) = f(.1,.818753803)=-2(.818753803))+(.1)^3e^{-.2}=-1.636688875, \\ k_{21} & = & f(x_1+h/2,y_1+hk_{11}/2)=f(.15,.818753803+(.05)(-1.636688875)) \\ &=& f(.15,.736919359)=-2(.736919359)+(.15)^3e^{-.3}=-1.471338457, \\ k_{31} & = & f(x_1+h/2,y_1+hk_{21}/2)=f(.15,.818753803+(.05)(-1.471338457)) \\ &=& f(.15,.745186880)=-2(.745186880)+(.15)^3e^{-.3}=-1.487873498, \\ k_{41} & = & f(x_1+h,y_1+hk_{31})=f(.2,.818753803+(.1)(-1.487873498)) \\ &=&f(.2,.669966453)=-2(.669966453)+(.2)^3e^{-.4}=-1.334570346, \\ y_2&=&y_1+{h\over6}(k_{11}+2k_{21}+2k_{31}+k_{41}), \\ &=&.818753803+{.1\over6}(-1.636688875+2(-1.471338457)+2(-1.487873498)-1.334570346) \\ &=&.670592417. \end{eqnarray*}

The Runge-Kutta method is sufficiently accurate for most applications.

Example 3.3.2

Table 3.3.1 shows results of using the Runge-Kutta method with step sizes \(h=0.1\) and \(h=0.05\) to find approximate values of the solution of the initial value problem

\[ y'+2y=x^3e^{-2x},\quad y(0)=1 \]

at \(x=0\), \(0.1\), \(0.2\), \(0.3\), …, \(1.0\). For comparison, it also shows the corresponding approximate values obtained with the improved Euler method in Example 3.2.2, and the values of the exact solution

\[ y={e^{-2x}\over4}(x^4+4). \]

The results obtained by the Runge-Kutta method are clearly better than those obtained by the improved Euler method in fact; the results obtained by the Runge-Kutta method with \(h=0.1\) are better than those obtained by the improved Euler method with \(h=0.05\).

Table 3.3.1. Numerical solution of \(y'+2y=x^3e^{-2x},\ y(0)=1\), by the Runge-Kuttta method and the improved Euler method.
\(x\)\(h=0.1\)\(h=0.05\)\(h=0.1\)\(h=0.05\)Exact
0.01.0000000001.0000000001.0000000001.0000000001.000000000
0.10.8200409370.8190505720.8187538030.8187513700.818751221
0.20.6727344450.6710864550.6705924170.6705884180.670588174
0.30.5525976430.5505438780.5499282210.5499232810.549922980
0.40.4551606370.4528906160.4522104300.4522050010.452204669
0.50.3766812510.3743357470.3736334920.3736278990.373627557
0.60.3139709200.3116522390.3109587680.3109532420.310952904
0.70.2642876110.2620676240.2614045680.2613992700.261398947
0.80.2252677020.2231942810.2225759890.2225710240.222570721
0.90.1948795010.1929817570.1924168820.1924123170.192412038
1.00.1713880700.1696806730.1691734890.1691693560.169169104
Improved EulerRunge-KuttaExact

Example 3.3.3

Table 3.3.2 shows analogous results for the nonlinear initial value problem

\[ y'=-2y^2+xy+x^2,\ y(0)=1. \]

We applied the improved Euler method to this problem in Example 3.

Table 3.3.2. Numerical solution of \(y'=-2y^2+xy+x^2,\ y(0)=1\), by the Runge-Kuttta method and the improved Euler method.
\(x\)\(h=0.1\)\(h=0.05\)\(h=0.1\)\(h=0.05\)“Exact”
0.01.0000000001.0000000001.0000000001.0000000001.000000000
0.10.8405000000.8382883710.8375871920.8375847590.837584494
0.20.7334308460.7305566770.7296444870.7296421550.729641890
0.30.6616008060.6585521900.6575824490.6575805980.657580377
0.40.6159618410.6128844930.6119033800.6119019690.611901791
0.50.5916347420.5885589520.5875767160.5875756350.587575491
0.60.5860069350.5829272240.5819432100.5819423420.581942225
0.70.5977121200.5946180120.5936304030.5936296270.593629526
0.80.6260088240.6228982790.6219083780.6219075530.621907458
0.90.6703512250.6672376170.6662519880.6662509420.666250842
1.00.7300696100.7269858370.7260173780.7260159080.726015790
Improved EulerRunge-Kutta“Exact”

Example 3.3.4

Tables 3.3.3 and 3.3.4 show results obtained by applying the Runge-Kutta and Runge-Kutta semilinear methods to to the initial value problem

\[ y'-2xy=1,\ y(0)=3, \]

which we considered in Examples 3.1.4 and 3.2.4.

Table 3.3.3. Numerical solution of \(y'-2xy=1,\ y(0)=3\), by the Runge-Kutta method.
\(x\)\(h=0.2\)\(h=0.1\)\(h=0.05\)“Exact”
0.03.0000000003.0000000003.0000000003.000000000
0.23.3278464003.3278516333.3278519523.327851973
0.43.9660449733.9660585353.9660593003.966059348
0.65.0669967545.0670371235.0670393965.067039535
0.86.9365341786.9366906796.9367003206.936700945
1.010.18423225210.18487773310.18492099710.184923955
1.216.06434480516.06691558316.06709869916.067111677
1.427.27877183327.28860521727.28933895527.289392347
1.649.96055366049.99731396650.00016574450.000377775
1.898.83433781598.97114614698.98213670298.982969504
2.0211.393800152211.908445283211.951167637211.954462214
Table 3.3.4. Numerical solution of \(y'-2xy=1,\ y(0)=3\), by the Runge-Kutta semilinear method.
\(x\)\(h=0.2\)\(h=0.1\)\(h=0.05\)“Exact”
0.03.0000000003.0000000003.0000000003.000000000
0.23.3278532863.3278520553.3278519783.327851973
0.43.9660617553.9660594973.9660593573.966059348
0.65.0670426025.0670397255.0670395475.067039535
0.86.9367040196.9367011376.9367009576.936700945
1.010.18492617110.18492409310.18492396310.184923955
1.216.06711196116.06711169616.06711167816.067111677
1.427.28938941827.28939216727.28939233527.289392347
1.650.00037015250.00037730250.00037774550.000377775
1.898.98295551198.98296863398.98296945098.982969504
2.0211.954439983211.954460825211.954462127211.954462214

The Case Where \(x_0\) Isn’t The Left Endpoint

So far in this chapter we’ve considered numerical methods for solving an initial value problem

\begin{equation} y'=f(x,y),\quad y(x_0)=y_0 \tag{3.3.3}\end{equation}

on an interval \([x_0,b]\), for which \(x_0\) is the left endpoint. We haven’t discussed numerical methods for solving (3.3.3) on an interval \([a,x_0]\), for which \(x_0\) is the right endpoint. To be specific, how can we obtain approximate values \(y_{-1}\), \(y_{-2}\), …, \(y_{-n}\) of the solution of (3.3.3) at \(x_0-h, \dots,x_0-nh\), where \(h=(x_0-a)/n\)? Here’s the answer to this question:

Consider the initial value problem

\begin{equation} z'=-f(-x,z),\quad z(-x_0)=y_0, \tag{3.3.4}\end{equation}

on the interval \([-x_0,-a]\), for which \(-x_0\) is the left endpoint. Use a numerical method to obtain approximate values \(z_1\), \(z_2\), …, \(z_n\) of the solution of \(\eqref{eq:3.3.4}\) at \(-x_0+h\), \(-x_0+2h\), …, \(-x_0+nh=-a\). Then \(y_{-1}=z_1\), \(y_{-2}=z_2\), \(\dots\), \(y_{-n}=z_n\) are approximate values of the solution of \(\eqref{eq:3.3.3}\) at \(x_0-h\), \(x_0-2h\), …, \(x_0-nh=a\).

The justification for this answer is sketched in Exercise 23. Note how easy it is to make the change the given problem (3.3.3) to the modified problem (3.3.4): first replace \(f\) by \(-f\) and then replace \(x\), \(x_0\), and \(y\) by \(-x\), \(-x_0\), and \(z\), respectively.

Example 3.3.5

Use the Runge-Kutta method with step size \(h=0.1\) to find approximate values of the solution of

\begin{equation} (y-1)^2y'=2x+3,\quad y(1)=4 \tag{3.3.5}\end{equation}

at \(x=0\), \(0.1\), \(0.2\), …, \(1\).

Solution We first rewrite (3.3.5) in the form (3.3.3) as

\begin{equation} y'={2x+3\over(y-1)^2},\quad y(1)=4. \tag{3.3.6}\end{equation}

Since the initial condition \(y(1)=4\) is imposed at the right endpoint of the interval \([0,1]\), we apply the Runge-Kutta method to the initial value problem

\begin{equation} z'={2x-3\over(z-1)^2},\quad z(-1)=4 \tag{3.3.7}\end{equation}

on the interval \([-1,0]\). (You should verify that (3.3.7) is related to (3.3.6) as (3.3.4) is related to (3.3.3).) Table 3.3.5 shows the results. Reversing the order of the rows in Table 3.3.5 and changing the signs of the values of \(x\) yields the first two columns of Table 3.3.6. The last column of Table 3.3.6 shows the exact values of \(y\), which are given by

\[ y=1+(3x^2+9x+15)^{1/3}. \]

(Since the differential equation in (3.3.6) is separable, this formula can be obtained by the method of Section 2.2.)

Table 3.3.5. Numerical solution of \(z'=\dst{2x-3\over(z-1)^2},\ z(-1)=4\), on \([-1,0]\).
\(x\)\(z\)
-1.04.000000000
-0.93.944536474
-0.83.889298649
-0.73.834355648
-0.63.779786399
-0.53.725680888
-0.43.672141529
-0.33.619284615
-0.23.567241862
-0.13.516161955
0.03.466212070
Table 3.3.6. Numerical solution of \((y-1)^2y'=2x+3,\ y(1)=4\), on \([0,1]\).
\(x\)\(y\)Exact
0.003.4662120703.466212074
0.103.5161619553.516161958
0.203.5672418623.567241864
0.303.6192846153.619284617
0.403.6721415293.672141530
0.503.7256808883.725680889
0.603.7797863993.779786399
0.703.8343556483.834355648
0.803.8892986493.889298649
0.903.9445364743.944536474
1.004.0000000004.000000000

We leave it to you to develop a procedure for handling the numerical solution of (3.3.3) on an interval \([a,b]\) such that \(a<x_0<b\) (Exercises 26 and 27).

3.3 Exercises

Most of the following numerical exercises involve initial value problems considered in the exercises in Sections 3.2. You’ll find it instructive to compare the results that you obtain here with the corresponding results that you obtained in those sections.

In Exercises 15 use the Runge-Kutta method to find approximate values of the solution of the given initial value problem at the points \(x_i=x_0+ih,\) where \(x_0\) is the point where the initial condition is imposed and \(i=1\), \(2\).

  1. C \(y'=2x^2+3y^2-2,\quad y(2)=1;\quad h=0.05\)

    Show answer

    \(y_1=1.550598190,\; y_2=2.469649729\)

  2. C \(y'=y+\sqrt{x^2+y^2},\quad y(0)=1;\quad h=0.1\)

    Show answer

    \(y_1=1.221551366,\; y_2=1.492920208\)

  3. C \(y'+3y=x^2-3xy+y^2,\quad y(0)=2;\quad h=0.05\)

    Show answer

    \(y_1=1.890339767,\; y_2=1.763094323\)

  4. C \(y'=\dst{1+x\over1-y^2},\quad y(2)=3;\quad h=0.1\)

    Show answer

    \( y_1=2.961316248\)  \( y_2=2.920128958\).

  5. C \(y'+x^2y=\sin xy,\quad y(1)=\pi;\quad h=0.2\)

    Show answer

    \(y_1=2.475605264,\; y_2=1.825992433\)

  6. C Use the Runge-Kutta method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem

    \[ y'+3y=7e^{4x},\quad y(0)=2, \]

    at \(x=0\), \(0.1\), \(0.2\), \(0.3\), …, \(1.0\). Compare these approximate values with the values of the exact solution \(y=e^{4x}+e^{-3x}\), which can be obtained by the method of Section 2.1. Present your results in a table like Table 3.3.1.

    Show answer
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)Exact
    1.054.65450969954.64834401954.64796232854.647937102

  7. C Use the Runge-Kutta method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem

    \[ y'+{2\over x}y={3\over x^3}+1,\quad y(1)=1 \]

    at \(x=1.0\), \(1.1\), \(1.2\), \(1.3\), …, \(2.0\). Compare these approximate values with the values of the exact solution

    \[ y={1\over3x^2}(9\ln x+x^3+2), \]

    which can be obtained by the method of Section 2.1. Present your results in a table like Table 3.3.1.

    Show answer
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)Exact
    2.01.3531917451.3531936061.3531937121.353193719

  8. C Use the Runge-Kutta method with step sizes \(h=0.05\), \(h=0.025\), and \(h=0.0125\) to find approximate values of the solution of the initial value problem

    \[ y'={y^2+xy-x^2\over x^2},\quad y(1)=2 \]

    at \(x=1.0\), \(1.05\), \(1.10\), \(1.15\) …, \(1.5\). Compare these approximate values with the values of the exact solution

    \[ y={x(1+x^2/3)\over1-x^2/3}, \]

    which was obtained in Example 2.2.3. Present your results in a table like Table 3.3.1.

    Show answer
    \(x\)\(h=0.05\)\(h=0.025\)\(h=0.0125\)Exact
    1.5010.49865819810.49990626610.49999382010.500000000

  9. C In Example 2.2.3 it was shown that

    \[ y^5+y=x^2+x-4 \]

    is an implicit solution of the initial value problem

    \[ y'={2x+1\over5y^4+1},\quad y(2)=1. \tag*{\rm(A)} \]

    Use the Runge-Kutta method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of (A) at \(x=2.0\), \(2.1\), \(2.2\), \(2.3\), …, \(3.0\). Present your results in tabular form. To check the error in these approximate values, construct another table of values of the residual

    \[ R(x,y)=y^5+y-x^2-x+4 \]

    for each value of \((x,y)\) appearing in the first table.

    Show answer
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)\(h=0.1\)\(h=0.05\)\(h=0.025\)
    3.01.4560239071.4560234031.4560233790.00001240.0000006110.0000000333
    Approximate SolutionsResiduals

  10. C You can see from Example 2.5.1 that

    \[ x^4y^3+x^2y^5+2xy=4 \]

    is an implicit solution of the initial value problem

    \[ y'=-{4x^3y^3+2xy^5+2y\over3x^4y^2+5x^2y^4+2x},\quad y(1)=1. \tag*{\rm(A)} \]

    Use the Runge-Kutta method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of (A) at \(x=1.0\), \(1.1\), \(1.2\), \(1.3\), …, \(2.0\). Present your results in tabular form. To check the error in these approximate values, construct another table of values of the residual

    \[ R(x,y)=x^4y^3+x^2y^5+2xy-4 \]

    for each value of \((x,y)\) appearing in the first table.

    Show answer
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)\(h=0.1\)\(h=0.05\)\(h=0.025\)
    2.00.4926637890.4926637380.4926637360.0000009020.00000005080.00000000302
    Approximate SolutionsResiduals

  11. C Use the Runge-Kutta method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem

    \[ (3y^2+4y)y'+2x+\cos x=0, \quad y(0)=1 \mbox{\ (Exercise~2.2.~\hspace*{-3pt}\ref{exer:2.2.13})}, \]

    at \(x=0\), \(0.1\), \(0.2\), \(0.3\), …, \(1.0\).

    Show answer
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)“Exact"
    1.00.6599570460.6599576460.6599576860.659957689

  12. C Use the Runge-Kutta method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem

    \[ y'+{(y+1)(y-1)(y-2)\over x+1}=0, \quad y(1)=0 \mbox{\ (Exercise~2.2.~\hspace*{-3pt}\ref{exer:2.2.14})}, \]

    at \(x=1.0\), \(1.1\), \(1.2\), \(1.3\), …, \(2.0\).

    Show answer
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)“Exact"
    2.0-0.750911103-0.750912294-0.750912367-0.750912371

  13. C Use the Runge-Kutta method and the Runge-Kutta semilinear method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of the initial value problem

    \[ y'+3y=e^{-3x}(1-4x+3x^2-4x^3),\quad y(0)=-3 \]

    at \(x=0\), \(0.1\), \(0.2\), \(0.3\), …, \(1.0\). Compare these approximate values with the values of the exact solution \(y=-e^{-3x}(3-x+2x^2-x^3+x^4)\), which can be obtained by the method of Section 2.1. Do you notice anything special about the results? Explain.

    Show answer

    Applying variation of parameters to the given initial value problem yields

    \(y=ue^{-3x}\), where (A) \(u'=1-4x+3x^2-4x^3,\quad u(0)=-3\). Since \(u^{(5)}=0\), the Runge-Kutta method yields the exact solution of (A). Therefore the Euler semilinear method produces the exact solution of the given problem.

    Runge-Kutta method
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)Exact
    0.0-3.000000000-3.000000000-3.000000000-3.000000000
    0.1-2.162598011-2.162526572-2.162522707-2.162522468
    0.2-1.577172164-1.577070939-1.577065457-1.577065117
    0.3-1.163350794-1.163242678-1.163236817-1.163236453
    0.4-0.868030294-0.867927182-0.867921588-0.867921241
    0.5-0.655542739-0.655450183-0.655445157-0.655444845
    0.6-0.501535352-0.501455325-0.501450977-0.501450707
    0.7-0.389127673-0.389060213-0.389056546-0.389056318
    0.8-0.306468018-0.306412184-0.306409148-0.306408959
    0.9-0.245153433-0.245107859-0.245105379-0.245105226
    1.0-0.199187198-0.199150401-0.199148398-0.199148273

    Runge-Kutta semilinear method
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)Exact
    0.0-3.000000000-3.000000000-3.000000000-3.000000000
    0.1-2.162522468-2.162522468-2.162522468-2.162522468
    0.2-1.577065117-1.577065117-1.577065117-1.577065117
    0.3-1.163236453-1.163236453-1.163236453-1.163236453
    0.4-0.867921241-0.867921241-0.867921241-0.867921241
    0.5-0.655444845-0.655444845-0.655444845-0.655444845
    0.6-0.501450707-0.501450707-0.501450707-0.501450707
    0.7-0.389056318-0.389056318-0.389056318-0.389056318
    0.8-0.306408959-0.306408959-0.306408959-0.306408959
    0.9-0.245105226-0.245105226-0.245105226-0.245105226
    1.0-0.199148273-0.199148273-0.199148273-0.199148273

The linear initial value problems in Exercises 1419 can’t be solved exactly in terms of known elementary functions. In each exercise use the Runge-Kutta and the Runge-Kutta semilinear methods with the indicated step sizes to find approximate values of the solution of the given initial value problem at \(11\) equally spaced points (including the endpoints) in the interval.

  1. C \(y'-2y=\dst{1\over1+x^2},\quad y(2)=2\);   \(h=0.1,0.05,0.025\) on \([2,3]\)

    Show answer
    Runge-Kutta method
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)“Exact"
    3.015.28166003615.28198140715.28200330015.282004826

    Runge-Kutta semilinear method
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)“Exact"
    3.015.28200599015.28200489915.28200483115.282004826

  2. C \(y'+2xy=x^2,\quad y(0)=3\);  \(h=0.2,0.1,0.05\) on \([0,2]\) (Exercise 2.1. 38)

    Show answer
    Runge-Kutta method
    \(x\)\(h=0.2\)\(h=0.1\)\(h=0.05\)“Exact"
    2.00.9046781560.9042957720.9042777590.904276722

    Runge-Kutta semilinear method
    \(x\)\(h=0.2\)\(h=0.1\)\(h=0.05\)“Exact"
    2.00.9045922150.9042970620.9042780040.904276722

  3. C \(\dst{y'+{1\over x}y={\sin x\over x^2},\quad y(1)=2;}\)  \(h=0.2,0.1,0.05\) on \([1,3]\) (Exercise 2.1. 39)

    Show answer
    Runge-Kutta method
    \(x\)\(h=0.2\)\(h=0.1\)\(h=0.05\)“Exact"
    3.00.9675231470.9675231520.9675231530.967523153

    Runge-Kutta semilinear method
    \(x\)\(h=0.2\)\(h=0.1\)\(h=0.05\)“Exact"
    3.00.9675231470.9675231520.9675231530.967523153

  4. C \(\dst{y'+y={e^{-x}\tan x\over x},\quad y(1)=0;}\)  \(h=0.05,0.025,0.0125\) on \([1,1.5]\) (Exercise 2.1. 40)

    Show answer
    Runge-Kutta method
    \(x\)\(h=0.0500\)\(h=0.0250\)\(h=0.0125\)“Exact"
    1.500.3438391580.3437848140.3437807960.343780513

    Runge-Kutta semilinear method
    \(x\)\(h=0.0500\)\(h=0.0250\)\(h=0.0125\)“Exact"
    1.000.0000000000.0000000000.0000000000.000000000
    1.050.0281210220.0281210100.0281210100.028121010
    1.100.0553934940.0553934660.0553934650.055393464
    1.150.0821640480.0821639940.0821639900.082163990
    1.200.1088626980.1088625970.1088625910.108862590
    1.250.1360587150.1360585280.1360585170.136058516
    1.300.1645648620.1645644960.1645644730.164564471
    1.350.1956510740.1956502710.1956502190.195650216
    1.400.2315422880.2315401640.2315400270.231540017
    1.450.2768187750.2768110110.2768104910.276810456
    1.500.3438391240.3437848110.3437807960.343780513

  5. C \(\dst{y'+{2x\over 1+x^2}y={e^x\over (1+x^2)^2}, \quad y(0)=1};\)   \(h=0.2,0.1,0.05\) on \([0,2]\) (Exercise 2.1, 41)

    Show answer
    Runge-Kutta method
    \(x\)\(h=0.2\)\(h=0.1\)\(h=0.05\)“Exact"
    2.00.7326332290.7326383180.7326386090.732638628

    Runge-Kutta semilinear method
    \(x\)\(h=0.2\)\(h=0.1\)\(h=0.05\)“Exact"
    2.00.7326392120.7326386630.7326386300.732638628

  6. C \(xy'+(x+1)y=e^{x^2},\quad y(1)=2\);  \(h=0.05,0.025,0.0125\) on \([1,1.5]\) (Exercise 2.1. 42)

    Show answer
    Runge-Kutta method
    \(x\)\(h=0.0500\)\(h=0.0250\)\(h=0.0125\)“Exact"
    1.502.2440256832.2440240882.2440239892.244023982

    Runge-Kutta semilinear method
    \(x\)\(h=0.0500\)\(h=0.0250\)\(h=0.0125\)“Exact"
    1.502.2440250812.2440240512.2440239872.244023982

In Exercises 2022 use the Runge-Kutta method and the Runge-Kutta semilinear method with the indicated step sizes to find approximate values of the solution of the given initial value problem at \(11\) equally spaced points (including the endpoints) in the interval.

  1. C \(y'+3y=xy^2(y+1),\quad y(0)=1\);   \(h=0.1,0.05,0.025\) on \([0,1]\)

    Show answer
    Runge-Kutta method
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)“Exact"
    1.00.0564268860.0564161370.0564155520.056415515

    Runge-Kutta semilinear method
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)“Exact"
    1.00.0564151850.0564154950.0564155140.056415515

  2. C \(\dst{y'-4y={x\over y^2(y+1)},\quad y(0)=1}\);   \(h=0.1,0.05,0.025\) on \([0,1]\)

    Show answer
    Runge-Kutta method
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)“Exact"
    1.054.69590118654.72711185854.72942625054.729594761

    Runge-Kutta semilinear method
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)“Exact"
    1.054.72909996654.72956172054.72959265854.729594761

  3. C \(\dst{y'+2y={x^2\over1+y^2},\quad y(2)=1}\);   \(h=0.1,0.05,0.025\) on \([2,3]\)

    Show answer
    Runge-Kutta method
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)“Exact"
    3.01.3613840821.3613838121.3613838091.361383810

    Runge-Kutta semilinear method
    \(x\)\(h=0.1\)\(h=0.05\)\(h=0.025\)“Exact"
    3.01.3614565021.3613881961.3613840791.361383810

  4. C Suppose \(a<x_0\), so that \(-x_0<-a\). Use the chain rule to show that if \(z\) is a solution of

    \[ z'=-f(-x,z),\quad z(-x_0)=y_0, \]

    on \([-x_0,-a]\), then \(y=z(-x)\) is a solution of

    \[ y'=f(x,y),\quad y(x_0)=y_0, \]

    on \([a,x_0]\).

  5. C Use the Runge-Kutta method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of

    \[ y'={y^2+xy-x^2\over x^2},\quad y(2)=-1 \]

    at \(x=1.1\), \(1.2\), \(1.3\), … \(2.0\). Compare these approximate values with the values of the exact solution

    \[ y={x(4-3x^2)\over4+3x^2}, \]

    which can be obtained by referring to Example 2.4.3.

    Show answer
    \(x\)\(h=.1\)\(h=.05\)\(h=.025\)Exact
    2.00-1.000000000-1.000000000-1.000000000-1.000000000

  6. C Use the Runge-Kutta method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of

    \[ y'=-x^2y-xy^2,\quad y(1)=1 \]

    at \(x=0\), \(0.1\), \(0.2\), …, \(1\).

    Show answer
    \(x\)\(h=.1\)\(h=.05\)\(h=.025\)“Exact"
    1.001.0000000001.0000000001.0000000001.000000000

  7. C Use the Runge-Kutta method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of

    \[ y'+{1\over x}y={7\over x^2}+3,\quad y(1)={3\over2} \]

    at \(x=0.5\), \(0.6\),…, \(1.5\). Compare these approximate values with the values of the exact solution

    \[ y={7\ln x\over x}+{3x\over2}, \]

    which can be obtained by the method discussed in Section 2.1.

    Show answer
    \(x\)\(h=.1\)\(h=.05\)\(h=.025\)Exact
    1.504.1421712794.1421705534.1421705084.142170505

  8. C Use the Runge-Kutta method with step sizes \(h=0.1\), \(h=0.05\), and \(h=0.025\) to find approximate values of the solution of

    \[ xy'+2y=8x^2,\quad y(2)=5 \]

    at \(x=1.0\), \(1.1\), \(1.2\), …, \(3.0\). Compare these approximate values with the values of the exact solution

    \[ y=2x^2-{12\over x^2}, \]

    which can be obtained by the method discussed in Section 2.1.

    Show answer
    \(x\)\(h=.1\)\(h=.05\)\(h=.025\)Exact
    3.016.66666698816.66666668716.66666666816.666666667

  9. Numerical Quadrature (see Exercise 3.1. 23).

    1. Derive the quadrature formula

      \[ \int_a^bf(x)\,dx\approx {h\over6}(f(a)+f(b))+ {h\over3}\sum_{i=1}^{n-1}f(a+ih)+{2h\over3}\sum_{i=1}^n f\left(a+(2i-1)h/2\right) \tag*{\rm(A)} \]

      (where \(h=(b-a)/n)\) by applying the Runge-Kutta method to the initial value problem

      \[ y'=f(x),\quad y(a)=0. \]

      This quadrature formula is called Simpson’s Rule.

    2. L For several choices of \(a\), \(b\), \(A\), \(B\), \(C\), and \(D\) apply (A) to \(f(x)=A+Bx+Cx+Dx^3\), with \(n = 10\), \(20\), \(40\), \(80\), \(160\), \(320\). Compare your results with the exact answers and explain what you find.

    3. L For several choices of \(a\), \(b\), \(A\), \(B\), \(C\), \(D\), and \(E\) apply (A) to \(f(x)=A+Bx+Cx^2+Dx^3+Ex^4\), with \(n=10,20,40,80,160,320\). Compare your results with the exact answers and explain what you find.