
# 3.3E: The Runge-Kutta Method (Exercises)

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

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 [exer:3.3.1} –[exer:3.3.5} 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$$.

[exer:3.3.1] $$y'=2x^2+3y^2-2,\quad y(2)=1;\quad h=0.05$$

[exer:3.3.2] $$y'=y+\sqrt{x^2+y^2},\quad y(0)=1;\quad h=0.1$$

[exer:3.3.3] $$y'+3y=x^2-3xy+y^2,\quad y(0)=2;\quad h=0.05$$

[exer:3.3.4] $$y'= {1+x\over1-y^2},\quad y(2)=3;\quad h=0.1$$

[exer:3.3.5] $$y'+x^2y=\sin xy,\quad y(1)=\pi;\quad h=0.2$$

[exer:3.3.6] 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 [table:3.3.1}.

[exer:3.3.7] 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 [table:3.3.1}.

[exer:3.3.8] 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

Example $$\PageIndex{1}$$:

Add text here. For the automatic number to work, you need to add the “AutoNum” template (preferably at2.2.3}. Present your results in a table like Table [table:3.3.1}.

[exer:3.3.9] In Example

Example $$\PageIndex{1}$$:

Add text here. For the automatic number to work, you need to add the “AutoNum” template (preferably at2.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. \eqno{\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.

[exer:3.3.10] You can see from Example

Example $$\PageIndex{1}$$:

Add text here. For the automatic number to work, you need to add the “AutoNum” template (preferably at2.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. \eqno{\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.

[exer:3.3.11] 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{eq:exer:2.2.13})},$

at $$x=0$$, $$0.1$$, $$0.2$$, $$0.3$$, …, $$1.0$$.

[exer:3.3.12] 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{eq:exer:2.2.14})},$

at $$x=1.0$$, $$1.1$$, $$1.2$$, $$1.3$$, …, $$2.0$$.

[exer:3.3.13] 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.

[exer:3.3.14] $$y'-2y= {1\over1+x^2},\quad y(2)=2$$;   $$h=0.1,0.05,0.025$$ on $$[2,3]$$

[exer:3.3.15] $$y'+2xy=x^2,\quad y(0)=3$$; $$h=0.2,0.1,0.05$$ on $$[0,2]$$ (Exercise 2.1. [exer:2.1.38})

[exer:3.3.16] $${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. [exer:2.1.39})

[exer:3.3.17] $${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. [exer:2.1.40})

[exer:3.3.18] $${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, [exer:2.1.41})

[exer:3.3.19] $$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. [exer:2.1.42})

[exer:3.3.20] $$y'+3y=xy^2(y+1),\quad y(0)=1$$;   $$h=0.1,0.05,0.025$$ on $$[0,1]$$

[exer:3.3.21] $${y'-4y={x\over y^2(y+1)},\quad y(0)=1}$$;   $$h=0.1,0.05,0.025$$ on $$[0,1]$$

[exer:3.3.22] $${y'+2y={x^2\over1+y^2},\quad y(2)=1}$$;   $$h=0.1,0.05,0.025$$ on $$[2,3]$$

[exer:3.3.23] 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]$$.

[exer:3.3.24] 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

Example $$\PageIndex{1}$$:

Add text here. For the automatic number to work, you need to add the “AutoNum” template (preferably at2.4.3}.

[exer:3.3.25] 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$$.

[exer:3.3.26] 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.

[exer:3.3.27] 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.

[exer:3.3.28] Numerical Quadrature (see Exercise 3.1. [exer:3.1.23}).

$\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) \eqno{\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.$
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.
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.