Chapter 9 · Numerical Analysis

9.3 Numerical Solution of Initial Value Problems

Euler's method, modified Euler (Heun), the midpoint method and the whole two-stage Runge–Kutta family; local truncation error, order and the global error bound; absolute stability for the test equation $y'=\lambda y$, stiffness and the two implicit methods that cure it.

Most initial value problems that arise in practice — the trajectory of a satellite, the concentration of a drug in the blood, the current in a nonlinear circuit, the size of an epidemic — have no solution formula. The Picard–Lindelöf theorem (§6.1, First-Order Equations, Existence–Uniqueness and Linear Equations) guarantees that a unique solution exists; this section is about computing it. A numerical method replaces the unknown function $y(x)$ by a table of numbers $y_0,y_1,y_2,\dots$ with $y_n\approx y(x_n)$ on a grid $x_n=x_0+nh$, produced one step at a time from a rule that uses only values of $f$. Euler's method follows the tangent line; the modified Euler (Heun) and midpoint methods sample the slope twice per step and average cleverly. Two questions decide whether such a method is any good. How fast does the error shrink as $h\to0$? — that is the order: a local error of size $h^{p+1}$ per step accumulates over $\sim1/h$ steps into a global error of size $h^p$. Does the computed solution behave like the true one for the step we actually use? — that is absolute stability, decided by applying the method to the test equation $y'=\lambda y$.

GATE MA examines this material in all three formats. NAT questions ask for one or two steps of Euler, modified Euler or a given Runge–Kutta formula, for a global error at a point, or for the largest step size that keeps a method stable. MCQs ask for the parameters that make a two-stage method second order, or the stability interval of a method. MSQs ask which statements about local error, global error, order and stability are true. This section develops all of it: the methods, the Taylor-expansion proof of the order conditions, the convergence theorem with its error bound, and the stability functions — with a counterexample for each tempting false statement.

Grids, One-Step Methods and Euler's Method

Throughout, we solve the initial value problem

$$y'=f(x,y),\qquad y(x_0)=y_0,\qquad x_0\le x\le X,$$

with $f$ continuous and Lipschitz in $y$ on the strip $[x_0,X]\times\mathbb{R}$ (so a unique solution $y$ exists on all of $[x_0,X]$ by §6.1), and as smooth as each statement requires. When we say "$f$ is smooth" we mean that the partial derivatives we use exist and are continuous; then the solution is smooth too, with $y''=f_x+ff_y$ by the chain rule.

📘 Definition 9.16 — Grid, numerical solution, one-step method

Fix a step size $h\gt0$ and let $x_n=x_0+nh$ for $n=0,1,\dots,N$, where $Nh=X-x_0$. A numerical solution is a sequence $y_0,y_1,\dots,y_N$ intended to approximate $y(x_0),y(x_1),\dots,y(x_N)$; we write $f_n=f(x_n,y_n)$. A one-step method computes each value from the previous one only:

$$y_{n+1}=y_n+h\,\Phi(x_n,y_n;h),$$

where the increment function $\Phi$ is built from values of $f$ (it is an "average slope" over the step). The method is explicit if $\Phi$ can be evaluated directly from $x_n,y_n,h$, and implicit if the formula also involves the unknown $y_{n+1}$, so that an equation has to be solved at every step.

📘 Definition 9.17 — Euler's method

Euler's method (the explicit or forward Euler method) is the one-step method with $\Phi(x,y;h)=f(x,y)$:

$$y_{n+1}=y_n+hf(x_n,y_n).$$

Geometrically, from the point $(x_n,y_n)$ we follow the line with the slope $f(x_n,y_n)$ prescribed by the equation at that point for a horizontal distance $h$. The numerical solution is the polygon through the points $(x_n,y_n)$ — the Euler polygon.

After one step Euler's polygon is tangent to the solution through $(x_n,y_n)$, but after that it follows the slope field of a neighbouring solution: errors made early are carried along. To measure the quality of a method we separate the error committed in a single step from the error accumulated over many.

📘 Definition 9.18 — Local truncation error, order, consistency

The local truncation error of a one-step method at step $n+1$ is the amount by which the exact solution fails to satisfy the method's formula:

$$T_{n+1}=y(x_{n+1})-y(x_n)-h\,\Phi\left(x_n,y(x_n);h\right).$$

Equivalently, $T_{n+1}$ is the error after one step started from the exact value $y_n=y(x_n)$. The method has order $p$ (where $p\ge1$ is an integer) if $T_{n+1}=O(h^{p+1})$ as $h\to0$, uniformly in $n$, for every sufficiently smooth $f$; it has order exactly $p$ if it has order $p$ but not order $p+1$. It is consistent if $\Phi(x,y;0)=f(x,y)$ for all $(x,y)$. (Some books call $T_{n+1}/h$ the local truncation error; it is then $O(h^p)$. In GATE problems, "the local truncation error of Euler's method is $O(h^2)$" uses our convention.)

📐 Theorem 9.25 — The local error of Euler's method; consistency
  1. If the solution $y$ is $C^2$ on $[x_0,X]$, then for each $n$ there is $\xi_n\in(x_n,x_{n+1})$ with $$T_{n+1}=\frac{h^2}{2}\,y''(\xi_n),$$ so $|T_{n+1}|\le\frac{M_2}{2}h^2$ with $M_2=\max_{[x_0,X]}|y''|$. Euler's method has order $1$, and order exactly $1$.
  2. Let $\Phi$ be continuous, and continuously differentiable in $h$ on $[x_0,X]\times\mathbb{R}\times[0,h_0]$. Then a one-step method has order at least $1$ if and only if it is consistent.

Proof. (1) Taylor's theorem with the Lagrange remainder gives $y(x_{n+1})=y(x_n)+hy'(x_n)+\frac{h^2}{2}y''(\xi_n)$, and $y'(x_n)=f(x_n,y(x_n))=\Phi(x_n,y(x_n);h)$. So $T_{n+1}=\frac{h^2}{2}y''(\xi_n)$. For $y'=y$, $y(0)=1$ the error of the first step is $e^h-1-h=\frac{h^2}{2}+O(h^3)$, which is not $O(h^3)$: the order is exactly $1$.

(2) Write $u=y(x_n)$. By Taylor's theorem $y(x_n+h)-u=hf(x_n,u)+O(h^2)$, and by the mean value theorem in $h$, $\Phi(x_n,u;h)=\Phi(x_n,u;0)+O(h)$ (the $O$ is uniform because $\partial\Phi/\partial h$ is bounded on the compact set swept out by the solution). Hence

$$T_{n+1}=h\left[f(x_n,u)-\Phi(x_n,u;0)\right]+O(h^2).$$

If the method is consistent the bracket is $0$ and $T_{n+1}=O(h^2)$. Conversely, if $T_{n+1}=O(h^2)$ for every IVP, the bracket must vanish at every point $(x_n,u)$; since every point of the strip lies on the solution of some IVP, $\Phi(x,y;0)=f(x,y)$ everywhere. ∎

✏️ Example 1 — Three Euler steps and the local error
For $y'=y-x$, $y(0)=2$ (exact solution $y=x+1+e^x$): (a) compute $y_1,y_2,y_3$ by Euler's method with $h=0.1$ and tabulate the errors; (b) compare the error after the first step with Theorem 9.25(1); (c) explain why the error grows faster than "$3\times$ the first error".
(a) Steps $y_1=2+0.1(2-0)=2.2$; $\ y_2=2.2+0.1(2.2-0.1)=2.41$; $\ y_3=2.41+0.1(2.41-0.2)=2.631$.
(a) Errors Exact values $y(0.1)=2.205171$, $y(0.2)=2.421403$, $y(0.3)=2.649859$; errors $e_1=0.005171$, $e_2=0.011403$, $e_3=0.018859$.
(b) Local error The first step starts from the exact value, so $e_1=T_1=\frac{h^2}{2}y''(\xi)=0.005e^{\xi}$ with $\xi\in(0,0.1)$. Indeed $0.005e^0=0.005\lt0.005171\lt0.005e^{0.1}=0.005526$ (here $\xi\approx0.034$).
(c) Accumulation Subtracting $y(x_{n+1})=y(x_n)+h\left(y(x_n)-x_n\right)+T_{n+1}$ from the method gives $e_{n+1}=(1+h)e_n+T_{n+1}$: every old error is amplified by $1+hf_y=1.1$ per step before the new local error is added, and the local errors themselves grow with $y''=e^x$. This is exactly the mechanism behind the global error bound (Theorem 9.28).

Modified Euler and the Second-Order Runge–Kutta Family

Euler's method uses the slope at the start of the step for the whole step. If the solution curves bend, that slope is systematically wrong. The idea of Runge and Kutta is to sample $f$ at a second point inside the step and combine the two slopes so that the Taylor expansions of the method and of the true solution agree to one more power of $h$ — without ever differentiating $f$.

📘 Definition 9.19 — Modified Euler (Heun), midpoint and Ralston methods
Modified Euler (Heun) — predictor $y^{*}_{n+1}=y_n+hf_n$, corrector $$y_{n+1}=y_n+\tfrac h2\left[f_n+f(x_{n+1},y^{*}_{n+1})\right]:$$ average the slopes at the two ends of the step.
Midpoint method — $$y_{n+1}=y_n+hf\left(x_n+\tfrac h2,\ y_n+\tfrac h2f_n\right):$$ use the slope found at the midpoint of an Euler half-step.
Ralston's method — $k_2=f\left(x_n+\tfrac23h,\ y_n+\tfrac23hf_n\right)$, $$y_{n+1}=y_n+\tfrac h4\left(f_n+3k_2\right).$$

Names and notation. Heun's method is also called the improved Euler method and, in most Indian texts and in GATE, the modified Euler method or "RK2"; a few books give the name "modified Euler" to the midpoint method instead. When a formula is printed, use it; when only the name "modified Euler" is given, use Heun. Many texts put $h$ inside the stages: $K_1=hf(x_n,y_n)$, $K_2=hf(x_n+h,y_n+K_1)$, $y_{n+1}=y_n+\tfrac12(K_1+K_2)$ — the same method. Some texts also iterate Heun's corrector, $y^{(k+1)}_{n+1}=y_n+\tfrac h2\left[f_n+f(x_{n+1},y^{(k)}_{n+1})\right]$, until two iterates agree; when $hL\lt2$ this converges to the implicit trapezoidal rule of Definition 9.23.

All three are members of one family, and the family is small enough that we can find all its members of order $2$.

📘 Definition 9.20 — Explicit two-stage Runge–Kutta methods

For real parameters $a,b,\alpha,\beta$ the explicit two-stage Runge–Kutta method is

$$k_1=f(x_n,y_n),\qquad k_2=f\left(x_n+\alpha h,\ y_n+\beta hk_1\right),$$ $$y_{n+1}=y_n+h\left(ak_1+bk_2\right).$$

Its increment function is $\Phi(x,y;h)=af(x,y)+bf\left(x+\alpha h,\,y+\beta hf(x,y)\right)$. Euler is $(a,b)=(1,0)$; Heun is $a=b=\tfrac12$, $\alpha=\beta=1$; midpoint is $a=0$, $b=1$, $\alpha=\beta=\tfrac12$; Ralston is $a=\tfrac14$, $b=\tfrac34$, $\alpha=\beta=\tfrac23$. Each step costs two evaluations of $f$.

📐 Theorem 9.26 — Order conditions for two-stage methods

Let $f$ be $C^3$. The two-stage method of Definition 9.20

  1. has order at least $1$ if and only if $a+b=1$;
  2. has order at least $2$ if and only if $$a+b=1,\qquad b\alpha=\tfrac12,\qquad b\beta=\tfrac12;$$
  3. never has order $3$, whatever $a,b,\alpha,\beta$.

Consequently the methods of order $2$ form the one-parameter family $\alpha=\beta$, $b=\dfrac1{2\alpha}$, $a=1-\dfrac1{2\alpha}$ ($\alpha\ne0$); Heun ($\alpha=1$), midpoint ($\alpha=\tfrac12$) and Ralston ($\alpha=\tfrac23$) have order exactly $2$.

Proof. Fix a step, write $u=y(x_n)$ and let $f,f_x,f_y,f_{xx},\dots$ denote values at $(x_n,u)$. The exact solution. Differentiating $y'=f(x,y(x))$ by the chain rule gives $y''=f_x+ff_y$ and

$$y'''=f_{xx}+2ff_{xy}+f^2f_{yy}+f_y\left(f_x+ff_y\right),$$

so by Taylor's theorem

$$y(x_n+h)-u=hf+\tfrac{h^2}{2}\left(f_x+ff_y\right)+\tfrac{h^3}{6}\,y'''(x_n)+O(h^4).$$

The method. With $y_n=u$, Taylor's theorem in two variables (§1.1) applied to $k_2=f(x_n+\alpha h,\,u+\beta hf)$ gives

$$k_2=f+h\left(\alpha f_x+\beta ff_y\right)+\tfrac{h^2}{2}\left(\alpha^2f_{xx}+2\alpha\beta ff_{xy}+\beta^2f^2f_{yy}\right)+O(h^3).$$

Hence

$$h(ak_1+bk_2)=(a+b)hf+bh^2\left(\alpha f_x+\beta ff_y\right)+\tfrac{b}{2}h^3\left(\alpha^2f_{xx}+2\alpha\beta ff_{xy}+\beta^2f^2f_{yy}\right)+O(h^4).$$

(1) The $h$-terms of $T_{n+1}$ cancel for every $f$ iff $a+b=1$ (take $f\equiv1$ to see necessity). (2) Given that, the $h^2$-terms cancel iff $b\alpha f_x+b\beta ff_y=\tfrac12f_x+\tfrac12ff_y$ for every $f$; taking $f(x,y)=x$ (so $f_x=1$, $f_y=0$) forces $b\alpha=\tfrac12$, and taking $f(x,y)=y$ at a point with $y\ne0$ forces $b\beta=\tfrac12$; conversely these make the $h^2$-terms equal for all $f$. (3) The exact $h^3$-coefficient contains the term $\tfrac16f_y\left(f_x+ff_y\right)$, which involves no second derivatives of $f$, while the method's $h^3$-coefficient contains only second derivatives. For $f(x,y)=y$ all second derivatives vanish: the exact coefficient is $\tfrac{u}{6}$ and the method's is $0$, so $T_{n+1}=\tfrac{h^3}{6}u+O(h^4)$, which is not $O(h^4)$ when $u\ne0$. The family statement solves the equations in (2): $b\ne0$ forces $\alpha=\beta=\frac1{2b}$. ∎

Two special classes of equations explain why the family behaves as it does, and are favourite sources of GATE shortcuts.

📐 Theorem 9.27 — Two-stage methods on quadrature problems and on linear equations
  1. Quadrature. If $f=f(x)$ does not depend on $y$, then Euler, Heun and the midpoint method reduce to the left-rectangle, trapezoidal and midpoint rules on $[x_n,x_{n+1}]$; for $f\in C^2$ their local errors are $\tfrac{h^2}{2}f'(\xi)$, $-\tfrac{h^3}{12}f''(\xi)$ and $\tfrac{h^3}{24}f''(\xi)$ respectively. Over $[x_0,X]$, Heun's method returns exactly $y_0$ plus the composite trapezoidal approximation of $\int_{x_0}^{x_N}f$.
  2. Linear $f$. If $f(x,y)=px+qy+r$ with constants $p,q,r$, then every two-stage method of order $2$ produces the same numbers, namely those of the second-order Taylor method $$y_{n+1}=y_n+hf_n+\tfrac{h^2}{2}\left(p+qf_n\right).$$ In particular, for $y'=\lambda y$ every such method gives $y_{n+1}=\left(1+h\lambda+\tfrac{(h\lambda)^2}{2}\right)y_n$.

Proof. (1) With $f=f(x)$: Euler gives $y_{n+1}-y_n=hf(x_n)$, Heun $\tfrac h2\left[f(x_n)+f(x_{n+1})\right]$ and midpoint $hf\left(x_n+\tfrac h2\right)$, while the exact increment is $\int_{x_n}^{x_{n+1}}f$. The local errors are therefore the errors of the three quadrature rules on one panel, whose error terms are derived in §9.2 (Interpolation, Numerical Differentiation and Integration); summing Heun's increments over the steps gives the composite trapezoidal rule. (2) For linear $f$, $k_2=p(x_n+\alpha h)+q(y_n+\beta hk_1)+r$, which equals $k_1+h\left(\alpha p+\beta qk_1\right)$, so

$$y_{n+1}=y_n+(a+b)hk_1+bh^2\left(\alpha p+\beta qf_n\right),$$

which with $a+b=1$, $b\alpha=b\beta=\tfrac12$ is the displayed formula. Since $y''=f_x+ff_y=p+qf$, it is the Taylor polynomial of degree $2$ in $h$. For $y'=\lambda y$ take $p=r=0$, $q=\lambda$. ∎

✏️ Example 2 — Heun, midpoint and Ralston side by side
For $y'=-2xy^2$, $y(0)=1$ (exact solution $y=\dfrac1{1+x^2}$), compute $y(0.4)$ with $h=0.2$ by (a) Euler, (b) Heun, (c) the midpoint method, and (d) compare the errors with Ralston's value $0.858604$.
(a) Euler $f(0,1)=0$, so $y_1=1$; then $f(0.2,1)=-0.4$ and $y_2=1-0.08=0.92$.
(b) Heun, step 1 $k_1=f(0,1)=0$; predictor $y^*=1$; $k_2=f(0.2,1)=-0.4$; $y_1=1+0.1(0-0.4)=0.96$.
(b) Heun, step 2 $k_1=f(0.2,0.96)=-0.36864$; predictor $y^*=0.96-0.073728=0.886272$; $k_2=f(0.4,0.886272)=-0.628382$; $y_2=0.96+0.1(-0.997022)=0.860298$.
(c) Midpoint Step 1: $k_2=f(0.1,\,1+0.1\cdot0)=-0.2$, $y_1=1+0.2(-0.2)=0.96$. Step 2: $k_1=-0.36864$, half-step value $0.96-0.036864=0.923136$, $k_2=f(0.3,0.923136)=-0.511308$, $y_2=0.96-0.102262=0.857738$.
(d) Compare Exact $y(0.4)=\tfrac1{1.16}=0.862069$. Errors: Euler $-0.0579$, Heun $0.00177$, midpoint $0.00433$, Ralston $0.00347$. The three second-order methods agree in the leading behaviour of their error but not in its constant; Euler is worse by more than an order of magnitude. Note that the first step of Heun and midpoint gave the same $0.96$ but different second steps: the coincidence of Theorem 9.27(2) holds only for linear $f$.
✏️ Example 3 — Prove or disprove: order of two-stage methods
In the notation of Definition 9.20: (a) $a=\tfrac13$, $b=\tfrac23$, $\alpha=\beta=\tfrac34$ gives a method of order $2$. (b) $a=b=\tfrac12$, $\alpha=1$, $\beta=\tfrac12$ gives a method of order $2$. (c) Heun's method and the midpoint method always produce the same numbers. (d) Some choice of $a,b,\alpha,\beta$ gives a method of order $3$.
(a) True $a+b=1$ and $b\alpha=b\beta=\tfrac23\cdot\tfrac34=\tfrac12$: Theorem 9.26(2). It is the member $\alpha=\tfrac34$ of the second-order family.
(b) False $b\beta=\tfrac14\ne\tfrac12$. A concrete failure: for $y'=y$ we get $k_1=y_n$, $k_2=\left(1+\tfrac h2\right)y_n$, so $y_{n+1}=\left(1+h+\tfrac{h^2}{4}\right)y_n$, while $y(x_n+h)=e^hy(x_n)$. Thus $T_{n+1}=\left(\tfrac{h^2}{2}-\tfrac{h^2}{4}+O(h^3)\right)y(x_n)=\tfrac{h^2}{4}y(x_n)+O(h^3)$: order exactly $1$ (it is consistent, since $a+b=1$).
(c) False Example 2 gives $0.860298$ and $0.857738$ for the same problem. They do coincide when $f$ is linear in $x$ and $y$ (Theorem 9.27(2)) — which is why a counterexample needs a nonlinear $f$.
(d) False Theorem 9.26(3). The witness $f=y$ is enough: for it every two-stage method gives $y_{n+1}=\left(1+(a+b)z+b\beta z^2\right)y_n$ with $z=h$, a polynomial of degree $2$, which cannot match $e^z$ through the $z^3$ term.

Local and Global Error: Order and Convergence

The local truncation error is a property of one step. What we actually care about is the global error at a fixed point $x=X$ after $N=(X-x_0)/h$ steps. Each step adds a local error of size $Kh^{p+1}$, and each step can also amplify the errors already present by a factor of at most $1+h\Lambda$. With $N\sim1/h$ steps, a total of roughly $N\cdot Kh^{p+1}\sim Kh^p$ is collected, magnified by at most $(1+h\Lambda)^N\le e^{\Lambda(X-x_0)}$. That is the whole content of the next theorem.

📘 Definition 9.21 — Global error; convergence
The global error at $x_n$ is $e_n=y(x_n)-y_n$, where $y_n$ is computed by the method from $y_0$. The method is convergent if $\max_{0\le n\le N}|e_n|\to0$ as $h\to0$ (with $e_0\to0$), for every IVP with smooth $f$ that is Lipschitz in $y$; it is convergent of order $p$ if $\max_n|e_n|=O(h^p)$ when $e_0=0$.
📐 Theorem 9.28 — Convergence of one-step methods; the global error bound

Suppose that, for $x\in[x_0,X]$, all $u,v\in\mathbb{R}$ and $0\lt h\le h_0$,

$$\left|\Phi(x,u;h)-\Phi(x,v;h)\right|\le\Lambda|u-v|\qquad(\Lambda\gt0),$$

and that the local truncation errors satisfy $|T_{n+1}|\le Kh^{p+1}$ for all $n$ with $x_{n+1}\le X$. Then for $x_n\le X$

$$|e_n|\le e^{\Lambda(x_n-x_0)}|e_0|+\frac{Kh^p}{\Lambda}\left(e^{\Lambda(x_n-x_0)}-1\right).$$

In particular a method of order $p$ with such a $\Phi$ is convergent of order $p$: local error $O(h^{p+1})$ gives global error $O(h^p)$. If $f$ is Lipschitz in $y$ with constant $L$ on the strip, the hypothesis holds

  • for Euler with $\Lambda=L$, giving $\ |e_n|\le\dfrac{hM_2}{2L}\left(e^{L(x_n-x_0)}-1\right)$ when $e_0=0$ ($M_2=\max|y''|$);
  • for the two-stage method of Definition 9.20 with $\Lambda=L\left(|a|+|b|+|b\beta|h_0L\right)$; so Heun, midpoint and Ralston have global error $O(h^2)$.

Proof. The exact solution satisfies $y(x_{n+1})=y(x_n)+h\Phi(x_n,y(x_n);h)+T_{n+1}$ (this is the definition of $T_{n+1}$), and the method satisfies $y_{n+1}=y_n+h\Phi(x_n,y_n;h)$. Subtracting,

$$e_{n+1}=e_n+h\left[\Phi(x_n,y(x_n);h)-\Phi(x_n,y_n;h)\right]+T_{n+1},$$

so by the Lipschitz condition $|e_{n+1}|\le(1+h\Lambda)|e_n|+Kh^{p+1}$. Put $A=1+h\Lambda$ and $B=Kh^{p+1}$. By induction on $n$,

$$|e_n|\le A^n|e_0|+B\left(1+A+\dots+A^{n-1}\right)=A^n|e_0|+B\,\frac{A^n-1}{A-1}:$$

the case $n=0$ is trivial, and if it holds for $n$ then $|e_{n+1}|\le A\left(A^n|e_0|+B\frac{A^n-1}{A-1}\right)+B$, and the right side is $A^{n+1}|e_0|+B\frac{A^{n+1}-1}{A-1}$. Now $A-1=h\Lambda$, so $B/(A-1)=Kh^p/\Lambda$, and $1+t\le e^t$ gives $A^n\le e^{nh\Lambda}=e^{\Lambda(x_n-x_0)}$. This is the bound.

For Euler $\Phi=f$, so $\Lambda=L$, and $K=M_2/2$ by Theorem 9.25. For the two-stage method, with $w=u+\beta hf(x,u)$ and $w'=v+\beta hf(x,v)$ we have $|w-w'|\le(1+|\beta|hL)|u-v|$, hence

$$|\Phi(x,u;h)-\Phi(x,v;h)|\le|a|L|u-v|+|b|L\,|w-w'|\le L\left(|a|+|b|+|b\beta|hL\right)|u-v|.$$

For a method of order $2$ and smooth $f$ the Taylor expansion in the proof of Theorem 9.26, with remainders bounded on the compact set swept out by the solution, gives $|T_{n+1}|\le Kh^3$. ∎

The bound is a guarantee, not an estimate: it grows like $e^{\Lambda(X-x_0)}$ even when the true solution and the true error decay. In practice the error is estimated from the computation itself, using the fact that, for a method of order $p$ and smooth $f$, the global error at a fixed point $X$ behaves like

$$y(X)-y_h(X)=C\,h^p+O(h^{p+1})$$

with a constant $C$ independent of $h$ (here $y_h(X)$ is the value computed with step $h$).

🧭 Problem-solving strategy — reading order from data; Richardson extrapolation
  1. Halving the step. If $h$ is halved, the global error of a method of order $p$ is divided by about $2^p$ (Euler: $2$; any RK2: $4$), and the local error per step by about $2^{p+1}$ (Euler: $4$; RK2: $8$). From two errors $E_h$, $E_{h/2}$: $\ p\approx\log_2\left(E_h/E_{h/2}\right)$.
  2. Error estimate without the exact solution. From $y-y_h\approx Ch^p$ and $y-y_{h/2}\approx C(h/2)^p$: $$y-y_{h/2}\approx\frac{y_{h/2}-y_h}{2^p-1}.$$
  3. Richardson extrapolation. The combination $\dfrac{2^py_{h/2}-y_h}{2^p-1}$ cancels the $Ch^p$ term and is accurate to $O(h^{p+1})$. For Euler it is $2y_{h/2}-y_h$; for RK2 it is $\tfrac13\left(4y_{h/2}-y_h\right)$.
  4. Rounding. With rounding error $\delta$ per step the total error behaves like $Ch^p+\delta/h$: making $h$ smaller helps only down to $h\approx(\delta/(pC))^{1/(p+1)}$.
✏️ Example 4 — Euler and Heun meet $e$
Apply Euler's method and Heun's method to $y'=y$, $y(0)=1$ on $[0,1]$ with $h=\tfrac1N$. (a) Find $y_N$ exactly for both methods. (b) Tabulate the errors at $x=1$ for $N=10,20,40$ and read off the orders. (c) Show that Euler's error is $\tfrac{e}{2N}+O(N^{-2})$, and compare with the bound of Theorem 9.28. (d) Improve the Euler values by Richardson extrapolation.
(a) Euler: $y_{n+1}=(1+h)y_n$, so $y_N=\left(1+\tfrac1N\right)^N$. Heun: by Theorem 9.27(2), $y_{n+1}=\left(1+h+\tfrac{h^2}2\right)y_n$, so $y_N=\left(1+\tfrac1N+\tfrac1{2N^2}\right)^N$.
(b) Table
$N$Euler $y_N$errorHeun $y_N$error
102.5937420.1245392.7140810.004201
202.6532980.0649842.7171910.001091
402.6850640.0332182.7180040.000278
Error ratios when $N$ doubles: Euler $1.92$, $1.96$ (→ $2$, order $1$); Heun $3.85$, $3.93$ (→ $4$, order $2$).
(c) Asymptotics $N\log\left(1+\tfrac1N\right)=1-\tfrac1{2N}+O(N^{-2})$, so $\left(1+\tfrac1N\right)^N=e\left(1-\tfrac1{2N}+O(N^{-2})\right)$ and $e-y_N=\tfrac{e}{2N}+O(N^{-2})=1.359h+O(h^2)$. The bound with $L=1$, $M_2=\max_{[0,1]}e^x=e$ is $\tfrac{eh}{2}(e-1)=2.335h$: the right order, a constant $1.7$ times too large.
(d) Richardson $2y_{1/20}-y_{1/10}=2(2.653298)-2.593742=2.712853$, error $0.0054$ — better than the Euler value with $N=40$, at the cost of $30$ evaluations of $f$ instead of $40$.

Absolute Stability: the Test Equation $y'=\lambda y$

Theorem 9.28 is a statement about $h\to0$. In a real computation $h$ is fixed, and a second question arises: does the computed solution behave qualitatively like the true one? The standard test is the linear equation $y'=\lambda y$ with a complex constant $\lambda$, $\operatorname{Re}\lambda\lt0$, whose solutions $e^{\lambda x}y_0$ decay to $0$. This is not as special as it looks: near any solution of a smooth system the error obeys approximately the linearised equation $u'=Ju$, $J$ the Jacobian matrix, and after diagonalising $J$ this splits into scalar equations $u'=\lambda u$ with $\lambda$ the eigenvalues of $J$ (Theorem 9.30 below; compare the linearisation of §6.4, Linear Systems and Stability).

📘 Definition 9.22 — Stability function; region and interval of absolute stability; A-stability

Suppose a method applied to $y'=\lambda y$ with step $h$ gives $y_{n+1}=R(z)\,y_n$, where $z=h\lambda\in\mathbb{C}$. Then $R$ is the stability function of the method and $y_n=R(z)^ny_0$. The region of absolute stability is

$$\mathcal{S}=\left\{z\in\mathbb{C}:\ |R(z)|\lt1\right\},$$

and the method is absolutely stable for $\lambda$ and $h$ if $h\lambda\in\mathcal{S}$ — then $y_n\to0$, as the exact solution does. The real set $\mathcal{S}\cap\mathbb{R}$ is the interval of absolute stability. The method is A-stable if $\mathcal{S}$ contains the whole open left half-plane $\{\operatorname{Re}z\lt0\}$, i.e. it is absolutely stable for every $h\gt0$ whenever $\operatorname{Re}\lambda\lt0$.

📘 Definition 9.23 — Backward Euler and the trapezoidal rule (implicit methods)
Backward (implicit) Euler $$y_{n+1}=y_n+hf(x_{n+1},y_{n+1})$$ — the slope at the end of the step.
Trapezoidal rule $$y_{n+1}=y_n+\tfrac h2\left[f(x_n,y_n)+f(x_{n+1},y_{n+1})\right]$$ — Heun's corrector with the exact new value.

Both are implicit: each step requires solving an equation for $y_{n+1}$ (by hand when $f$ is linear in $y$; by Newton's method or fixed-point iteration, §9.1, in general). Backward Euler has order $1$ and the trapezoidal rule order $2$ (their local errors are $-\tfrac{h^2}{2}y''+O(h^3)$ and $-\tfrac{h^3}{12}y'''+O(h^4)$).

📐 Theorem 9.29 — Stability functions and intervals
  1. The two-stage method of Definition 9.20 has $R(z)=1+(a+b)z+b\beta z^2$. Hence Euler has $R(z)=1+z$, and every two-stage method of order $2$ (Heun, midpoint, Ralston) has $R(z)=1+z+\tfrac{z^2}{2}$.
  2. Euler: $\mathcal{S}$ is the open disc $|z+1|\lt1$, and the interval of absolute stability is $(-2,0)$. Order-$2$ two-stage methods: the interval is also $(-2,0)$. So for real $\lambda\lt0$ both need $$0\lt h\lt\frac{2}{|\lambda|}.$$
  3. For an explicit method of this kind $R$ is a non-constant polynomial, so $\mathcal{S}$ is bounded: no explicit Runge–Kutta method is A-stable.
  4. Backward Euler: $R(z)=\dfrac1{1-z}$ and $\mathcal{S}=\{|z-1|\gt1\}$. Trapezoidal rule: $R(z)=\dfrac{1+z/2}{1-z/2}$ and $\mathcal{S}=\{\operatorname{Re}z\lt0\}$. Both are A-stable.
  5. On the imaginary axis ($\lambda=i\omega$, pure oscillation, $|e^{\lambda x}|=1$): $|R(iy)|^2=1+y^2$ for Euler, $1+\tfrac{y^4}{4}$ for the order-$2$ methods, $\tfrac1{1+y^2}$ for backward Euler, and $|R(iy)|=1$ for the trapezoidal rule.

Proof. (1) With $f=\lambda y$: $k_1=\lambda y_n$ and $k_2=\lambda\left(y_n+\beta h\lambda y_n\right)=\lambda(1+\beta z)y_n$, so $y_{n+1}=y_n+z\left(a+b(1+\beta z)\right)y_n$, that is, $y_{n+1}=\left(1+(a+b)z+b\beta z^2\right)y_n$. Euler is $a=1$, $b=0$; order $2$ means $a+b=1$, $b\beta=\tfrac12$.

(2) $|1+z|\lt1$ is the disc of radius $1$ about $-1$; on the real line it is $-2\lt z\lt0$. For order $2$ write $R(z)=\tfrac12\left((1+z)^2+1\right)$. For real $z$ this is $\ge\tfrac12\gt0$, so $|R(z)|\lt1$ iff $(1+z)^2\lt1$ iff $-2\lt z\lt0$.

(3) A non-constant polynomial satisfies $|R(z)|\to\infty$ as $|z|\to\infty$, so $|R|\lt1$ only on a bounded set, which cannot contain a half-plane.

(4) Backward Euler: $y_{n+1}=y_n+zy_{n+1}$ gives $R=\frac1{1-z}$, and $|R|\lt1$ iff $|1-z|\gt1$; every $z$ with $\operatorname{Re}z\lt0$ satisfies $|1-z|\ge1-\operatorname{Re}z\gt1$. Trapezoidal: $\left(1-\tfrac z2\right)y_{n+1}=\left(1+\tfrac z2\right)y_n$, and $\left|1+\tfrac z2\right|\lt\left|1-\tfrac z2\right|$ says that $\tfrac z2$ is closer to $-1$ than to $1$, i.e. $\operatorname{Re}z\lt0$.

(5) $|1+iy|^2=1+y^2$; $\ \left|1+iy-\tfrac{y^2}2\right|^2=\left(1-\tfrac{y^2}2\right)^2+y^2=1+\tfrac{y^4}4$; $\ |1-iy|^{-2}=\tfrac1{1+y^2}$; and $|1+\tfrac{iy}2|=|1-\tfrac{iy}2|$. ∎

Read (5) physically: applied to an undamped oscillation, Euler's numerical amplitude grows by the factor $\sqrt{1+h^2\omega^2}$ per step for every $h\gt0$, Heun's grows much more slowly, backward Euler damps the oscillation artificially, and only the trapezoidal rule keeps the amplitude exactly. The same theory applies to systems.

📐 Theorem 9.30 — Linear systems $\mathbf{y}'=A\mathbf{y}$
Let $A$ be a diagonalisable $m\times m$ matrix with eigenvalues $\lambda_1,\dots,\lambda_m$. A two-stage method (Definition 9.20) applied to $\mathbf{y}'=A\mathbf{y}$ gives $\mathbf{y}_{n+1}=R(hA)\,\mathbf{y}_n$ with the same polynomial $R$ as in Theorem 9.29 (backward Euler gives $(I-hA)^{-1}$), and $$\mathbf{y}_n\to\mathbf{0}\ \text{ for every }\mathbf{y}_0\iff|R(h\lambda_i)|\lt1\ \text{ for every }i.$$ So the step must place every $h\lambda_i$ in $\mathcal{S}$; for Euler or RK2 and real negative eigenvalues this means $h\lt2/\max_i|\lambda_i|$.

Proof. The stages are $\mathbf{k}_1=A\mathbf{y}_n$ and $\mathbf{k}_2=A(\mathbf{y}_n+\beta h\mathbf{k}_1)=A(I+\beta hA)\mathbf{y}_n$, so $\mathbf{y}_{n+1}=\left(I+(a+b)hA+b\beta h^2A^2\right)\mathbf{y}_n$, i.e. $\mathbf{y}_{n+1}=R(hA)\mathbf{y}_n$. If $A=PDP^{-1}$ with $D=\operatorname{diag}(\lambda_i)$, then $R(hA)^n=P\,\operatorname{diag}\left(R(h\lambda_i)^n\right)P^{-1}$, which tends to $0$ iff each $|R(h\lambda_i)|\lt1$ (if some $|R(h\lambda_j)|\ge1$, the eigenvector $\mathbf{y}_0=P\mathbf{e}_j$ gives $|\mathbf{y}_n|=|R(h\lambda_j)|^n|\mathbf{y}_0|\not\to0$). Backward Euler: $(I-hA)\mathbf{y}_{n+1}=\mathbf{y}_n$. ∎

A system is called stiff when its eigenvalues have very different negative real parts: the fast modes (large $|\lambda|$) die out almost at once in the exact solution, yet they still force an explicit method to use $h\lt2/|\lambda_{\max}|$ for as long as the computation runs. Implicit A-stable methods remove that restriction.

✏️ Example 5 — Step-size limits for a decaying solution
For $y'=-10y$, $y(0)=1$, compute $y_n$ at $x=1$ by Euler's method with $h=0.05,\ 0.1,\ 0.125,\ 0.25$, and by Heun, backward Euler and the trapezoidal rule with $h=0.25$. Compare with $y(1)=e^{-10}=4.54\times10^{-5}$ and explain each result with Theorem 9.29.
Euler $R=1-10h$ and $y(1)\approx R^{1/h}$.
$h$$z=-10h$$R(z)$$y_n$ at $x=1$
0.05−0.50.5$9.5\times10^{-7}$
0.1−10$0$
0.125−1.25−0.25$1.5\times10^{-5}$ (signs alternate)
0.25−2.5−1.5$5.06$
Reading For $h\lt0.2$ ($z\in(-2,0)$) the iterates decay — though for $0.1\lt h\lt0.2$ they oscillate in sign, which the true solution never does. For $h=0.25$, $z=-2.5\notin\mathcal{S}$ and the "solution" grows like $(-1.5)^n$. Decay is guaranteed only for $h\lt2/10=0.2$.
Heun $R(-2.5)=1-2.5+3.125=1.625$, so $y_4=1.625^4=6.97$: also unstable — a higher order does not buy a longer interval.
Implicit Backward Euler: $R=\tfrac1{3.5}$, $y_4=0.00666$; trapezoidal: $R=\tfrac{1-1.25}{1+1.25}=-\tfrac19$, $y_4=1.5\times10^{-4}$. Both decay, as A-stability promises, although with $h=0.25$ neither is accurate.
✏️ Example 6 — Prove or disprove: absolute stability
(a) For $y'=\lambda y$ with $\lambda\lt0$, Euler's and Heun's iterates tend to $0$ whenever $h$ is small enough. (b) Heun's method applied to $y'=5iy$ keeps $|y_n|=|y_0|$. (c) Backward Euler applied to the growing equation $y'=3y$ with $h=1$ gives $y_n\to0$. (d) For $\lambda=-2+6i$, Euler's method with $h=0.1$ is absolutely stable.
(a) True Both intervals of absolute stability are $(-2,0)$, so $h\lt2/|\lambda|$ suffices. (More generally a consistent method has $R(z)=1+z+O(z^2)$, which lies in $(0,1)$ for small negative $z$.)
(b) False $z=5ih$ and $|R(z)|^2=1+\tfrac{(5h)^4}{4}\gt1$ by Theorem 9.29(5): $|y_n|$ grows, though slowly for small $h$ (with $h=0.1$: by the factor $1.0078$ per step).
(c) True $R(3)=\tfrac1{1-3}=-\tfrac12$, so $y_n=\left(-\tfrac12\right)^ny_0\to0$, while $y=e^{3x}y_0$ grows. The region $\{|z-1|\gt1\}$ contains real $z\gt2$: backward Euler can be "too stable" and turn growth into spurious decay when $h\lambda\gt2$.
(d) False $z=-0.2+0.6i$ and $|1+z|=|0.8+0.6i|=1$, not $\lt1$: the iterates neither decay nor grow ($|y_n|=|y_0|$). In general $|1+h\lambda|^2=(1-2h)^2+36h^2\lt1$ iff $40h^2\lt4h$ iff $h\lt0.1$; $h=0.1$ is exactly the boundary.
✏️ Example 7 — A stiff second-order equation
The equation $y''+101y'+100y=0$, $y(0)=1$, $y'(0)=0$ has the solution $y=\tfrac{1}{99}\left(100e^{-x}-e^{-100x}\right)$. (a) Write it as a first-order system and find the largest $h$ for which Euler's method is absolutely stable. (b) Do one Euler step with $h=0.01$. (c) What happens with $h=0.03$, although the component $e^{-100x}$ is negligible after $x=0.1$?
(a) System With $u=y$, $v=y'$: $u'=v$, $v'=-100u-101v$, i.e. $\mathbf{y}'=A\mathbf{y}$ with $A=\begin{pmatrix}0&1\\-100&-101\end{pmatrix}$. Its characteristic polynomial $r^2+101r+100=(r+1)(r+100)$ gives $\lambda=-1,-100$. By Theorem 9.30, Euler needs $h\lt2$ and $h\lt\tfrac{2}{100}$: so $h\lt0.02$.
(b) One step $u_1=u_0+hv_0=1$, $v_1=v_0+h(-100u_0-101v_0)=-1$. Exact: $y(0.01)=0.99633$, $y'(0.01)=-0.62845$. (With $h=0.01$, $R(-1)=0$ annihilates the fast mode in one step; continuing to $x=0.3$ gives $u_{30}=0.74717$ against $y(0.3)=0.74830$.)
(c) Instability With $h=0.03$, $R(h\lambda)=1-3=-2$ for the fast mode: rounding and truncation errors in that mode double at every step. After $10$ steps ($x=0.3$) Euler gives $u_{10}\approx-9.6$; after $20$ steps, $u_{20}\approx-1.06\times10^4$, while $y(0.6)=0.554$. The step size is dictated by a component that is physically invisible — the hallmark of stiffness.
⚠️ Counterexamples and pitfalls
  1. Local versus global order. Euler's local truncation error is $O(h^2)$, its global error $O(h)$; for RK2 they are $O(h^3)$ and $O(h^2)$. "Euler is a second-order method" is a confusion of the two.
  2. Two stages cannot give order 3. The witness is $f=y$: any two-stage method gives $R(z)=1+(a+b)z+b\beta z^2$, which disagrees with $e^z$ at $z^3$ (Theorem 9.26(3)).
  3. Both order conditions are needed. $b\alpha=\tfrac12$ alone is not enough: $a=b=\tfrac12$, $\alpha=1$, $\beta=\tfrac12$ has order exactly $1$ (Example 3(b)). The condition $b\alpha=\tfrac12$ is tested by $f=x$, the condition $b\beta=\tfrac12$ by $f=y$.
  4. Coincidence on linear problems. All second-order two-stage methods give identical numbers when $f$ is linear in $x$ and $y$ (Theorem 9.27(2)); to tell Heun from midpoint you need a nonlinear $f$.
  5. An individual local error can beat the order. For $y'=\cos x$ the first Euler step from $0$ has error $\sin h-h\approx-\tfrac{h^3}6$, because $y''(0)=0$. Order is a worst-case statement over all smooth $f$ and all steps.
  6. Consistency is not optional. $a=b=1$ in Definition 9.20 gives $\Phi(x,y;0)=2f$; applied to $y'=1$, $y(0)=0$ it gives $y_n=2x_n$ — it converges, but to the wrong function.
  7. Higher order does not cure instability. Euler and every RK2 method share the interval $(-2,0)$. With $h=0.25$ for $y'=-10y$, Heun is just as unstable as Euler (Example 5).
  8. The boundary of the region is not inside it. With $|R(z)|=1$ the iterates neither decay nor grow: Euler with $h\lambda=-2$ gives $y_n=(-1)^ny_0$; with $\lambda=-2+6i$, $h=0.1$ gives $|y_n|=|y_0|$ (Example 6(d)). Watch whether a problem asks for $|R|\lt1$ or $|R|\le1$.
  9. Euler cannot represent oscillation. For $\lambda=i\omega$, $|R|=\sqrt{1+h^2\omega^2}\gt1$ for every $h\gt0$; RK2 also grows ($1+\tfrac{h^4\omega^4}{4}$). A smaller step only slows the growth.
  10. A-stable is not "always right". Backward Euler turns the growing $y'=3y$ into a decaying sequence when $h\gt\tfrac23$ (Example 6(c)), and damps oscillations that should persist.
  11. The global bound overestimates. For $y'=-y$ Theorem 9.28 grows like $e^{x}-1$ while the true error stays small (Exercise III.2). Use step halving to estimate errors.
  12. Orders assume smoothness. For $y'=|x-\tfrac12|$ the steps that straddle $x=\tfrac12$ lose an order; for $y'=\sqrt{|y|}$ at $y=0$ the expansions fail altogether (and uniqueness, §6.1, may fail too).
📚 Go deeper — full proofs in the CSIR NET course
  • CSIR Unit 3 · §5.5 Numerical Solution of ODEs — Picard's successive approximations and the Taylor series method, the classical fourth-order Runge–Kutta method with its order conditions, the convergence theorem for one-step methods in full, the stability interval of RK4, and the treatment of systems and higher-order equations.

Two Labs

Interactive 1 — Euler, Heun and Midpoint Following the Slopes

The thick curve is the exact solution. The polygons are Euler, Heun (modified Euler) and the midpoint method with $N$ steps. In purple, the construction of the current step of the method you choose: Euler's tangent; Heun's predictor and the second slope at its end; the midpoint method's half-step. Press Play to build the solution step by step, and move the slider to change $N$. Watch the readout "error ratio": when $N$ doubles, which error halves and which is quartered?

N, h—
Euler error at end—
Heun error at end—
midpoint error at end—
error ratio N → 2N (Euler, Heun)—
Interactive 2 — Where Does $z=h\lambda$ Land? Stability Regions and the Test Equation

Left: the complex $z$-plane with the region of absolute stability $|R(z)|\lt1$ of the chosen method, and the point $z=h\lambda$ (red). Right: the real part of the numerical solution $y_n=R(z)^n$ of $y'=\lambda y$, $y(0)=1$ (dots), against the exact $\operatorname{Re}e^{\lambda x}$ (thick curve). Press Play to sweep $h$, or drag the slider. The iterates decay exactly while the red point is inside the green region. Try the oscillation $\lambda=5i$ with every method.

h—
z = hλ—
|R(z)|—
|yₙ| at end vs exact—

Exercises

I
Computing with Euler, Heun, midpoint and backward Euler.
  • 1 Use Euler's method with $h=0.25$ to approximate $y(1)$ for $y'=2x-y$, $y(0)=1$. Compare with the exact solution $y=2x-2+3e^{-x}$.
  • 2 Solve the same problem by Heun's method with $h=0.5$. Both computations use four evaluations of $f$; which is more accurate?
  • 3 Apply Euler, Heun and the midpoint method with $h=0.5$ to $y'=\dfrac{y}{1+x}$, $y(0)=1$ on $[0,1]$. Show that all three reproduce the exact solution, and explain why.
  • 4 For $y'=y-\dfrac{2x}{y}$, $y(0)=1$ (exact $y=\sqrt{2x+1}$), take one step with $h=0.2$ by Ralston's method, and compare with Euler and Heun.
  • 5 Apply Euler's method with $h=0.1$ to the system $u'=v$, $v'=-u$, $u(0)=1$, $v(0)=0$ for two steps. Compute $u_n^2+v_n^2$ and find a formula for it.
  • 6 Write $y''=x+y$, $y(0)=1$, $y'(0)=0$ as a system and take one Heun step with $h=0.2$. Compare with the exact solution $y=e^x-x$.
  • 7 Modelling. A fish population (in thousands) obeys the logistic law $P'=0.5P\left(1-\tfrac{P}{1000}\right)$, $t$ in years, $P(0)=100$. Use Heun's method with $h=1$ year to estimate $P(1)$ and $P(2)$, and compare with the exact $P=\dfrac{1000}{1+9e^{-t/2}}$.
  • 8 Backward Euler with $h=0.5$: (a) one step for $y'=-y^2$, $y(0)=1$ (choose the root of the quadratic close to $y_0$); (b) two steps for $y'=-2y+x$, $y(0)=1$.
1 $y_{n+1}=y_n+0.25(2x_n-y_n)$: $y_1=0.75$, $y_2=0.6875$, $y_3=0.765625$, $y_4=0.949219$. Exact $y(1)=3e^{-1}=1.103638$; error $0.1544$.
2 Step 1: $k_1=-1$, $y^*=0.5$, $k_2=f(0.5,0.5)=0.5$, $y_1=1+0.25(-0.5)=0.875$. Step 2: $k_1=f(0.5,0.875)=0.125$, $y^*=0.9375$, $k_2=f(1,0.9375)=1.0625$, $y_2=0.875+0.25(1.1875)=1.171875$. Error $-0.0682$ — less than half of Euler's $0.154$ for the same work.
3 All three give $y_1=1.5$, $y_2=2$; e.g. midpoint: $k_2=f\left(x_n+\tfrac h2,\ y_n+\tfrac h2\frac{y_n}{1+x_n}\right)=\dfrac{y_n}{1+x_n}$ when $y_n=1+x_n$. The exact solution $y=1+x$ is linear, so $y''\equiv0$ and Euler's local error $\tfrac{h^2}2y''$ vanishes. Along the line $f\equiv1$; a stage point $(x_n+\alpha h,\ y_n+\alpha h\cdot1)$ of a method with $\alpha=\beta$ lies on the same line, so every slope sampled is $1$ and each step is exact.
4 $k_1=1$; $k_2=f\left(0.1\overline3,\ 1.1\overline3\right)=1.133333-\dfrac{0.266667}{1.133333}=0.898039$; $y_1=1+0.2\left(0.25+0.75\cdot0.898039\right)=1.184706$. Euler $1.2$, Heun $1.186667$, exact $\sqrt{1.4}=1.183216$: errors $-0.0168$, $-0.00345$, $-0.00149$.
5 $(u_1,v_1)=(1,-0.1)$, $(u_2,v_2)=(0.99,-0.2)$; exact $(\cos0.2,-\sin0.2)=(0.980067,-0.198669)$. $u_{n+1}^2+v_{n+1}^2=(u_n+hv_n)^2+(v_n-hu_n)^2=(1+h^2)(u_n^2+v_n^2)$, so $u_n^2+v_n^2=1.01^n$: $1.01$, $1.0201$. (The exact value is $1$ for all $x$ — Theorem 9.29(5).)
6 $\mathbf{Y}=(y,z)$, $\mathbf{Y}'=(z,\ x+y)$. $\mathbf{K}_1=(0,1)$, predictor $(1,0.2)$, $\mathbf{K}_2=F(0.2;1,0.2)=(0.2,1.2)$, $\mathbf{Y}_1=(1,0)+0.1(0.2,2.2)=(1.02,0.22)$. Exact $(e^{0.2}-0.2,\ e^{0.2}-1)=(1.021403,0.221403)$.
7 Year 1: $k_1=45$, $P^*=145$, $k_2=61.9875$, $P_1=153.49$ thousand. Year 2: $k_1=64.9667$, $P^*=218.460$, $k_2=85.3677$, $P_2=228.66$ thousand. Exact $154.83$ and $231.97$ thousand (errors about $0.9\%$ and $1.4\%$).
8 (a) $y_1=1-0.5y_1^2$, i.e. $y_1^2+2y_1-2=0$, $y_1=-1+\sqrt3=0.7321$ (exact $y(0.5)=\tfrac23$). (b) $y_{n+1}(1+2h)=y_n+hx_{n+1}$: $y_1=\tfrac{1+0.25}{2}=0.625$, $y_2=\tfrac{0.625+0.5}{2}=0.5625$; exact $y=\tfrac x2-\tfrac14+\tfrac54e^{-2x}$ gives $0.4598$ and $0.4192$.
II
Local truncation error and order.
  • 1 Compute the local truncation error of the first Euler step for $y'=\cos x$, $y(0)=0$ with $h=0.1$. Why is it much smaller than $\tfrac{h^2}{2}$?
  • 2 Show that for every $\alpha\gt0$ the method with $\beta=\alpha$, $b=\tfrac1{2\alpha}$, $a=1-\tfrac1{2\alpha}$ has order $2$. Which values of $\alpha$ give the midpoint, Ralston and Heun methods?
  • 3 Find $a,b,\beta$ so that the method with $\alpha=\tfrac34$ has order $2$.
  • 4 Show that $y_{n+1}=y_n+hf\left(x_n+h,\ y_n+hf_n\right)$ is consistent but has order exactly $1$, and find the leading term of its local error for $y'=y$.
  • 5 Find the leading term of the local truncation error of Heun's method for $y'=\lambda y$.
  • 6 For $y'=f(x)$ find the local error of Heun's method exactly (in terms of $f''$). Compare the constant with the one in Exercise 5 written as a multiple of $h^3y'''$.
  • 7 Show that the method with $a=b=1$ (any $\alpha,\beta$) is inconsistent, and find what it computes for $y'=1$, $y(0)=0$.
  • 8 Prove that for $f(x,y)=px+qy+r$ every second-order two-stage method coincides with the Taylor method of order $2$, and deduce that Heun's and the midpoint method give identical tables for $y'=x+y$.
Check-lab: test the order conditions of a two-stage method (with $a=1-b$)
a, b, α, β—
bα (need ½)—
bβ (need ½)—
slopes (test x, test y)—
1 $T_1=y(0.1)-0-0.1\cos0=\sin0.1-0.1=-1.666\times10^{-4}$, against $\tfrac{h^2}{2}=5\times10^{-3}$. By Theorem 9.25, $T_1=\tfrac{h^2}{2}y''(\xi)=-\tfrac{h^2}{2}\sin\xi$ with $\xi$ near $0$, where $y''$ vanishes; the next Taylor term gives $T_1\approx-\tfrac{h^3}{6}$.
2 $a+b=1$, $b\alpha=b\beta=\tfrac{\alpha}{2\alpha}=\tfrac12$: Theorem 9.26(2). $\alpha=\tfrac12$: $a=0$, $b=1$ (midpoint); $\alpha=\tfrac23$: $a=\tfrac14$, $b=\tfrac34$ (Ralston); $\alpha=1$: $a=b=\tfrac12$ (Heun).
3 $b=\tfrac1{2\alpha}=\tfrac23$, $a=\tfrac13$, $\beta=\alpha=\tfrac34$.
4 $a=0$, $b=1$, $\alpha=\beta=1$: $\Phi(x,y;0)=f(x,y)$ (consistent), but $b\alpha=1\ne\tfrac12$. For $y'=y$: $k_2=(1+h)y_n$, $y_{n+1}=(1+h+h^2)y_n$, so $T_{n+1}=\left(e^h-1-h-h^2\right)y(x_n)=-\tfrac{h^2}{2}y(x_n)+O(h^3)$.
5 $R(z)=1+z+\tfrac{z^2}2$ and $y(x_{n+1})=e^zy(x_n)$, so $T_{n+1}=\left(e^z-R(z)\right)y(x_n)=\tfrac{(h\lambda)^3}{6}y(x_n)+O(h^4)=\tfrac{h^3}{6}y'''(x_n)+O(h^4)$.
6 Heun is the trapezoidal rule (Theorem 9.27(1)): $T_{n+1}=\int_{x_n}^{x_{n+1}}f-\tfrac h2\left[f(x_n)+f(x_{n+1})\right]=-\tfrac{h^3}{12}f''(\xi)=-\tfrac{h^3}{12}y'''(\xi)$. So the $h^3$-constant is $-\tfrac1{12}$ here and $+\tfrac16$ for $y'=\lambda y$: the order is universal, the error constant is not — it depends on $f$ through the "elementary differentials" in the proof of Theorem 9.26.
7 $\Phi(x,y;0)=(a+b)f=2f\ne f$. For $f\equiv1$: $y_{n+1}=y_n+2h$, so $y_n=2x_n$. The method converges as $h\to0$ — to the solution $2x$ of $y'=2$, not to $y=x$.
8 As in the proof of Theorem 9.27(2): $k_2=k_1+h(\alpha p+\beta qk_1)$ and $y_{n+1}=y_n+hk_1+\tfrac{h^2}2(p+qk_1)$ $=y_n+hy'+\tfrac{h^2}2y''$, where $y'=f_n$ and $y''=p+qf_n$ are the Taylor coefficients of the solution through $(x_n,y_n)$. The right side does not depend on $a,b,\alpha,\beta$, so all second-order members — Heun and midpoint among them — produce the same table for $y'=x+y$ ($p=q=1$, $r=0$): $y_{n+1}=y_n+h(x_n+y_n)+\tfrac{h^2}2(1+x_n+y_n)$.
III
Global error, convergence and error estimation.
  • 1 Euler's method for $y'=-y$, $y(0)=1$ with $h=\tfrac1N$: find $y_N$ at $x=1$, show that the error is $\tfrac{e^{-1}}{2N}+O(N^{-2})$, and evaluate both for $N=10$.
  • 2 Evaluate the bound of Theorem 9.28 for the problem of Exercise 1 at $x=1$, $h=0.1$, and compare with the true error.
  • 3 A method gives errors $3.2\times10^{-3}$, $8.1\times10^{-4}$, $2.0\times10^{-4}$ at a fixed point for $h=0.2,0.1,0.05$. Estimate its order.
  • 4 Euler's method for $y'=y$, $y(0)=1$ gives $y(1)\approx2.593742$ with $h=0.1$ and $2.653298$ with $h=0.05$. Compute the Richardson extrapolation and its error, and explain why it is better.
  • 5 Heun's method for the same problem gives $2.714081$ ($h=0.1$) and $2.717191$ ($h=0.05$). Without using $e$, estimate the error of the second value; then extrapolate.
  • 6 Suppose the computed error behaves like $E(h)=Ch^p+\dfrac{\delta}{h}$ with $C=1$, $\delta=10^{-8}$. Find the best $h$ and the smallest error for $p=1$ and for $p=2$.
  • 7 Prove the discrete Gronwall inequality used in Theorem 9.28: if $E_0=0$ and $E_{n+1}\le(1+h\Lambda)E_n+B$ with $h,\Lambda,B\gt0$, then $E_n\le\dfrac{B}{h\Lambda}\left(e^{nh\Lambda}-1\right)$.
  • 8 How many Euler steps on $[0,1]$ does the bound of Theorem 9.28 require to guarantee an error at most $10^{-3}$ for $y'=y$, $y(0)=1$? How many are actually needed (use Example 4(c))?
1 $y_N=\left(1-\tfrac1N\right)^N$. $N\log\left(1-\tfrac1N\right)=-1-\tfrac1{2N}+O(N^{-2})$, so $y_N=e^{-1}\left(1-\tfrac1{2N}+O(N^{-2})\right)$ and the error is $\tfrac{e^{-1}}{2N}+O(N^{-2})$. $N=10$: $0.9^{10}=0.348678$, error $0.019201$; estimate $0.018394$.
2 $L=1$, $M_2=\max_{[0,1]}e^{-x}=1$: bound $\tfrac{0.1}{2}(e-1)=0.0859$ — about $4.5$ times the true $0.0192$. The bound grows with $e^{Lx}$ although the solution and the error decay.
3 $\log_2\tfrac{3.2}{0.81}=1.98$ and $\log_2\tfrac{8.1}{2.0}=2.02$: order $p=2$.
4 $2(2.653298)-2.593742=2.712854$; error $e-2.712854=0.0054$, against $0.065$ for the $h=0.05$ value. Since $y_h=y-Ch+O(h^2)$ and $y_{h/2}=y-\tfrac{C}2h+O(h^2)$, the combination $2y_{h/2}-y_h$ cancels the $h$-term: $2y_{h/2}-y_h=y+O(h^2)$.
5 $p=2$: error of the second value $\approx\tfrac{2.717191-2.714081}{3}=0.001037$ (true $0.001091$). Extrapolation $\tfrac{4(2.717191)-2.714081}{3}=2.718228$, error $5.4\times10^{-5}$.
6 $p=1$: $E'(h)=1-\delta/h^2=0$ gives $h^*=\sqrt\delta=10^{-4}$ and $E^*=2\sqrt\delta=2\times10^{-4}$. $p=2$: $2h=\delta/h^2$ gives $h^*=(\delta/2)^{1/3}=1.71\times10^{-3}$, $E^*=8.8\times10^{-6}$. A higher order allows larger steps and a smaller attainable error.
7 Induction: $E_n\le B\sum_{k=0}^{n-1}(1+h\Lambda)^k=B\,\dfrac{(1+h\Lambda)^n-1}{h\Lambda}$ (true for $n=0$; if true for $n$, then $E_{n+1}\le(1+h\Lambda)B\frac{(1+h\Lambda)^n-1}{h\Lambda}+B=B\frac{(1+h\Lambda)^{n+1}-1}{h\Lambda}$). Finally $(1+h\Lambda)^n\le e^{nh\Lambda}$ because $1+t\le e^t$.
8 Bound: $2.3354h\le10^{-3}$ needs $h\le4.28\times10^{-4}$, i.e. $N\ge2336$. Actual error $\approx1.359h$: $h\le7.36\times10^{-4}$, $N\ge1360$ suffices.
IV
Absolute stability and stiffness.
  • 1 Find the largest step for which Euler's method, and Heun's method, is absolutely stable for $y'=-40y$.
  • 2 Find the stability function and the interval of absolute stability of the method of Exercise II.4.
  • 3 For which $h\gt0$ is Euler's method absolutely stable for $y'=(-2+2i)y$?
  • 4 Show that the first-order method of Example 3(b) has $R(z)=\left(1+\tfrac z2\right)^2$ and interval of absolute stability $(-4,0)$ — twice that of every second-order method. Is it a better method?
  • 5 For $\mathbf{y}'=A\mathbf{y}$ with $A=\begin{pmatrix}-2&1\\1&-2\end{pmatrix}$, find the steps for which Euler's and Heun's methods give $\mathbf{y}_n\to\mathbf{0}$ for every $\mathbf{y}_0$.
  • 6 Modelling (chemical kinetics). A fast reaction relaxes a concentration towards a slowly varying equilibrium: $y'=-1000\left(y-\cos x\right)-\sin x$, $y(0)=1$, whose solution is $y=\cos x$. Which steps make Euler's method stable? Compute one backward Euler formula step and say what backward Euler with $h=0.1$ gives at $x=1$.
  • 7 Apply backward Euler to $y'=3y$, $y(0)=1$ with $h=1$ and with $h=0.25$. For which $h$ does the numerical solution decay?
  • 8 Ten periods of $y''+y=0$ (that is, $x\in[0,20\pi]$) are computed with $h=0.1$ ($628$ steps). By what factor do Euler, Heun and the trapezoidal rule change the amplitude?
1 Both intervals are $(-2,0)$: $40h\lt2$, so $h\lt0.05$ for each.
2 $R(z)=1+z+z^2$ (Theorem 9.29(1) with $a=0$, $b=\beta=1$). For real $z$: $1+z+z^2\gt-1$ always (discriminant $1-8\lt0$), and $1+z+z^2\lt1$ iff $z(1+z)\lt0$ iff $-1\lt z\lt0$. Interval $(-1,0)$.
3 $|1+h(-2+2i)|^2=(1-2h)^2+4h^2=1-4h+8h^2\lt1$ iff $h\lt\tfrac12$. So $0\lt h\lt0.5$.
4 $R=1+z+\tfrac{z^2}4=\left(1+\tfrac z2\right)^2$, and $|R|\lt1$ iff $\left|1+\tfrac z2\right|\lt1$; on the real line $-4\lt z\lt0$. Its accuracy is only first order (Example 3(b)), so with a stable step its error is $O(h)$; a longer stability interval does not compensate. Stability and accuracy are separate requirements.
5 Eigenvalues $-1$ and $-3$ (symmetric, so diagonalisable). Theorem 9.30: $3h\lt2$, so $0\lt h\lt\tfrac23$ for Euler and for Heun.
6 The equation is $y'=\lambda y+g(x)$ with $\lambda=-1000$; the error obeys $e'\approx\lambda e$, so Euler needs $h\lt0.002$ (with $h=0.1$ it reaches about $-4.5\times10^{15}$ at $x=1$). Backward Euler: $y_{n+1}=\dfrac{y_n+h\left(1000\cos x_{n+1}-\sin x_{n+1}\right)}{1+1000h}$; with $h=0.1$ it gives $y(1)\approx0.540274$, against $\cos1=0.540302$ (error $3\times10^{-5}$).
7 $R(z)=\tfrac1{1-3h}$. $h=1$: $R=-\tfrac12$, $y_n=\left(-\tfrac12\right)^n$ — decaying and oscillating, while $e^{3x}$ grows. $h=0.25$: $R=4$ (exact factor $e^{0.75}=2.12$): grows, too fast. Decay happens iff $|1-3h|\gt1$, i.e. $h\gt\tfrac23$.
8 With $\lambda=\pm i$, $z=\pm0.1i$: amplitude factor $|R|^{628}$. Euler: $(1.01)^{314}=22.7$; Heun: $\left(1+\tfrac{10^{-4}}4\right)^{314}=1.0079$; trapezoidal rule: exactly $1$ (Theorem 9.29(5)).
🎯 GATE corner GATE MA · MCQGATE MA · MSQGATE MA · NAT

E1. GATE MA · MCQ Consider the method $k_1=f(x_n,y_n)$, $k_2=f(x_n+\alpha h,\ y_n+\beta hk_1)$, $y_{n+1}=y_n+h\left(\tfrac14k_1+bk_2\right)$ for $y'=f(x,y)$. The method has order $2$ exactly when $(b,\alpha,\beta)$ equals (A) $\left(\tfrac34,\tfrac12,\tfrac12\right)$; (B) $\left(\tfrac34,\tfrac23,\tfrac23\right)$; (C) $\left(\tfrac34,\tfrac34,\tfrac34\right)$; (D) $\left(\tfrac34,\tfrac23,\tfrac12\right)$.

Idea Theorem 9.26: $\tfrac14+b=1$, $b\alpha=\tfrac12$, $b\beta=\tfrac12$.
Solve $b=\tfrac34$ and $\alpha=\beta=\tfrac{1}{2b}=\tfrac23$ (Ralston's method).
Options (A) gives $b\alpha=\tfrac38$; (C) gives $\tfrac9{16}$; (D) satisfies $b\alpha=\tfrac12$ but $b\beta=\tfrac38$ — order $1$ only.
Answer (B).

E2. GATE MA · MCQ Euler's method is applied to $\mathbf{y}'=A\mathbf{y}$ with $A=\begin{pmatrix}-51&49\\49&-51\end{pmatrix}$. The iterates tend to $\mathbf{0}$ for every initial vector if and only if $0\lt h\lt h^*$, where $h^*$ equals (A) $1$; (B) $0.04$; (C) $0.02$; (D) $0.01$.

Eigenvalues $A$ is symmetric with eigenvectors $(1,1)$ and $(1,-1)$: $\lambda=-51+49=-2$ and $\lambda=-51-49=-100$.
Condition Theorem 9.30: $|1-2h|\lt1$ and $|1-100h|\lt1$, i.e. $h\lt1$ and $h\lt0.02$.
Options (A) uses only the slow eigenvalue; (B) and (D) are $4/100$ and $1/100$.
Answer (C).

E3. GATE MA · MSQ Which of the following statements is/are true? (One or more options may be correct.) (A) For smooth $f$, the global error of Euler's method at a fixed point $X$ is $O(h)$. (B) If $h$ is halved, the local truncation error of Heun's method decreases by a factor of approximately $8$. (C) There is an explicit two-stage Runge–Kutta method of order $3$. (D) For $y'=f(x)$, $y(a)=0$, Heun's method with step $h$ returns at $x=b$ the composite trapezoidal approximation of $\int_a^bf(x)\,dx$.

(A) True Local error $O(h^2)$, global $O(h)$ by Theorem 9.28.
(B) True Heun has order $2$, so $T=Ch^3+O(h^4)$ with $C\ne0$ in general; halving $h$ divides it by about $2^3=8$.
(C) False Theorem 9.26(3); for $f=y$ the method's $R(z)$ has degree $2$.
(D) True Theorem 9.27(1): each step adds $\tfrac h2\left[f(x_n)+f(x_{n+1})\right]$.
Answer (A), (B) and (D).

E4. GATE MA · MSQ CSIR Part C For the test equation $y'=\lambda y$, which of the following is/are true? (One or more options may be correct.) (A) If $\lambda\lt0$, backward Euler gives $y_n\to0$ for every $h\gt0$. (B) If $\lambda=i\omega$ with real $\omega\ne0$, Heun's method gives $|y_n|=|y_0|$ for all $n$. (C) For $\lambda=-10$ and $h=0.3$, Euler's iterates alternate in sign and $|y_n|\to\infty$. (D) The midpoint method has a longer interval of absolute stability than Heun's method.

(A) True $R(z)=\tfrac1{1-z}$ with $z=h\lambda\lt0$ lies in $(0,1)$.
(B) False $|R(i\omega h)|^2=1+\tfrac{(\omega h)^4}{4}\gt1$: $|y_n|$ grows.
(C) True $R=1-3=-2$: $y_n=(-2)^ny_0$.
(D) False Both have $R(z)=1+z+\tfrac{z^2}2$ (Theorem 9.29(1)) and the interval $(-2,0)$.
Answer (A) and (C).

E5. GATE MA · NAT For $y'=x^2+y^2$, $y(0)=1$, the modified Euler (Heun) method $y_{n+1}=y_n+\tfrac h2\left[f(x_n,y_n)+f\left(x_{n+1},\,y_n+hf(x_n,y_n)\right)\right]$ with $h=0.1$ gives $y(0.2)\approx$ ______ (correct to three decimal places).

Step 1 $k_1=f(0,1)=1$, $y^*=1.1$, $k_2=f(0.1,1.1)=0.01+1.21=1.22$, $y_1=1+0.05(2.22)=1.111$.
Step 2 $k_1=f(0.1,1.111)=0.01+1.234321=1.244321$; $y^*=1.111+0.124432=1.235432$; $k_2=f(0.2,1.235432)=0.04+1.526292=1.566292$; $y_2=1.111+0.05(2.810614)=1.251531$.
Answer $1.2515$. Answer: $1.252$ (accept $1.251$ to $1.253$). (The exact value is $1.25302$; Euler would give $1.222$.)

E6. GATE MA · NAT Euler's method applied to $y'=\lambda y$ with $\lambda=-4+3i$ is absolutely stable exactly for $0\lt h\lt h^*$. The value of $h^*$ is ______ (correct to two decimal places).

Idea Need $|1+h\lambda|\lt1$: $|1-4h+3ih|^2=(1-4h)^2+9h^2=1-8h+25h^2$.
Solve $1-8h+25h^2\lt1$ iff $h(25h-8)\lt0$ iff $0\lt h\lt\tfrac8{25}$. In general $h^*=\dfrac{-2\operatorname{Re}\lambda}{|\lambda|^2}$.
Answer $h^*=0.32$. Answer: $0.32$ (accept $0.31$ to $0.33$).
🧑‍🏫 For the teacher

Suggested plan — 2 lectures × 60 min.

  1. Methods and order. Definitions 9.16–9.18, Theorem 9.25 with proof, Example 1 on the board (stress the recursion $e_{n+1}=(1+h)e_n+T_{n+1}$). Definitions 9.19–9.20 and the full proof of Theorem 9.26 — it is short and it is the source of a whole class of GATE MCQs. Theorem 9.27 and Example 3. Project Interactive 1 with the construction set to Heun, then to midpoint, for $y'=-2xy^2$; finish by doubling $N$ and reading off the ratios $2$ and $4$.
  2. Error and stability. Theorem 9.28 with proof, Example 4 and the step-halving strategy box. Definitions 9.22–9.23, Theorem 9.29 (prove (1), (2) and (4)), Example 5. Project Interactive 2: $\lambda=-10$ with Euler while sweeping $h$ through $0.2$; the same with backward Euler; then $\lambda=5i$ with all four methods. Theorem 9.30, Example 7, and GATE corner E2 and E6 live.

Discussion questions. (1) Why does a local error of $O(h^{p+1})$ become a global error of $O(h^p)$ — not $O(h^{p+1})$, and not worse? What would happen if the amplification factor were $1+\sqrt h\Lambda$ instead of $1+h\Lambda$? (2) The exact solution of Example 7 is dominated by $e^{-x}$ after $x=0.05$. Why does the step size still have to respect the eigenvalue $-100$ for the whole computation? (3) Heun and midpoint give identical tables for $y'=x+y$. Which experiment would you design to tell them apart, and why must it be nonlinear?

Misconceptions to watch for. Confusing local and global order; forgetting to advance $x$ in the second stage ($f(x_n+h,\dots)$, not $f(x_n,\dots)$); using the corrected value instead of the predictor inside $k_2$; believing that higher order means a longer stability interval; treating the stability boundary $|R|=1$ as stable; thinking that A-stability means accuracy; applying the scalar stability condition to one eigenvalue of a system only.

Suggested homework. I(1, 2, 4, 6, 7), II(2, 4, 5, 6, 7), III(1, 3, 4, 7), IV(1, 2, 3, 5, 7); GATE corner E1, E3, E5.

🔬 Research–Teaching NexusResearch-tutored · optional, about 60 minutes

Research question. Space agencies propagate satellite orbits for years, and molecular-dynamics codes simulate proteins for billions of time steps. Over such long runs, which simple method keeps the energy of an oscillating system under control — and why is the answer not "the one with the highest order"?

Why it matters. For the oscillator $u'=v$, $v'=-u$ the energy $u^2+v^2$ is constant. Theorem 9.29(5) says Euler multiplies it by $1+h^2$ every step and Heun by $1+\tfrac{h^4}{4}$: tiny per step, ruinous over a million steps. A planet simulated this way spirals outwards; a molecule heats up. Long-time simulation in astronomy and chemistry is built on methods designed to respect such conserved quantities.

What to do.

  1. Implement Euler, Heun and the symplectic Euler method $u_{n+1}=u_n+hv_n$, $v_{n+1}=v_n-hu_{n+1}$ (note the new $u$ in the second formula) for the oscillator with $u(0)=1$, $v(0)=0$, $h=0.1$, and plot $u_n^2+v_n^2$ over $10^4$ steps.
  2. Prove that symplectic Euler is explicit, has order $1$, and exactly conserves the modified energy $u^2+huv+v^2$. Deduce that its energy error stays bounded for ever.
  3. Repeat for the Kepler problem $\mathbf{r}''=-\mathbf{r}/|\mathbf{r}|^3$ with a circular orbit of radius $1$: compare the radius after $100$ orbits for the three methods and the same number of $f$-evaluations.
  4. Find the stability function of symplectic Euler for the oscillator (it is a $2\times2$ matrix): compute its eigenvalues and show they lie on the unit circle when $0\lt h\lt2$.

Tools: Python (NumPy, Matplotlib) or a spreadsheet; pencil and paper for step 2.

Hand in: the energy plots of steps 1 and 3, the proof of step 2, and a paragraph answering the research question.

Going further. Read about the Störmer–Verlet (leapfrog) method, the second-order symplectic method used in most molecular-dynamics packages, and about "backward error analysis": the numerical solution of a symplectic method is the exact solution of a slightly modified Hamiltonian system.

Instructor note: Euler's energy after $N$ steps is $(1+h^2)^N$ ($\approx1.6\times10^{43}$ for $N=10^4$, $h=0.1$); Heun's is $\left(1+\tfrac{h^4}4\right)^N\approx1.28$. For symplectic Euler, substituting $u_{n+1}=u_n+hv_n$ and $v_{n+1}=v_n-hu_n-h^2v_n$ gives $u_{n+1}^2+hu_{n+1}v_{n+1}+v_{n+1}^2=u_n^2+hu_nv_n+v_n^2$ identically, so the energy $u^2+v^2$ oscillates within a band of width $O(h)$ but never drifts. Its matrix $\begin{pmatrix}1&h\\-h&1-h^2\end{pmatrix}$ has determinant $1$ and trace $2-h^2$, so for $0\lt h\lt2$ its eigenvalues are complex conjugates of modulus $1$. In the Kepler test the Euler orbit spirals out, Heun's drifts slowly, and the symplectic orbit precesses but keeps its radius.

🧪 Self-check quiz

0/5 correct

Q1. One step of Euler's method with $h=0.1$ for $y'=x+2y$, $y(0)=1$ gives

Q2. The local truncation error of the modified Euler (Heun) method is

Q3. The stability function $R(z)$, $z=h\lambda$, of the midpoint method $y_{n+1}=y_n+hf\left(x_n+\frac h2,\ y_n+\frac h2f_n\right)$ is

Q4. Euler's method for $y'=-20y$ produces iterates that tend to $0$ exactly when

Q5. A smooth IVP is solved by a second-order Runge–Kutta method. If the step size is halved, the global error at a fixed point is divided by approximately