Ec. DiferencialesFirst-Order Equations

Improved Euler and Runge–Kutta Methods

Average slopes for much better accuracy.

Sin empezar Ir a la práctica

Esta lección aún no está traducida. Por ahora se muestra en inglés; la versión en español está en camino.

Euler's method steps forward along the slope at the start of each step: $y_{n+1} = y_n + hf(t_n, y_n)$. It is simple, but its error shrinks only in proportion to $h$. Better methods sample the slope at more than one place in each step.

Idea clave

Improved Euler (Heun): $k_1 = f(t_n, y_n)$, $k_2 = f(t_n + h,\ y_n + hk_1)$, $y_{n+1} = y_n + \frac{h}{2}(k_1 + k_2)$.
Runge–Kutta (RK4): $k_1 = f(t_n, y_n)$, $k_2 = f(t_n + \frac{h}{2}, y_n + \frac{h}{2}k_1)$, $k_3 = f(t_n + \frac{h}{2}, y_n + \frac{h}{2}k_2)$, $k_4 = f(t_n + h, y_n + hk_3)$, $$y_{n+1} = y_n + \frac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4).$$

Por qué funciona

Taylor's theorem gives $y(t + h)$ $= y + hy' + \frac{h^{2}}{2}y'' + \dots$. Euler keeps only $hy'$, so each step is off by about $\frac{h^{2}}{2}y''$; after $T/h$ steps the errors add up to something proportional to $h$. Improved Euler averages the slope at both ends of the step, like the trapezoid rule, and that average matches the $h^{2}$ term too: the total error is proportional to $h^{2}$. RK4 weights four slopes like Simpson's rule and reaches $h^{4}$.
Accuracy versus work.
MethodSlopes per stepGlobal errorHalve $h$: error shrinks by
Euler1$\approx Ch$2
Improved Euler2$\approx Ch^{2}$4
Runge–Kutta (RK4)4$\approx Ch^{4}$16

Ejemplo resuelto: One step of improved Euler

For $y' = t + y$, $y(0) = 1$, take one step with $h = 0.1$. The exact solution is $y = 2e^{t} - t - 1$.
  1. $k_1 = f(0, 1) = 1$.
  2. Euler prediction: $1 + 0.1(1) = 1.1$ at $t = 0.1$, so $k_2 = f(0.1, 1.1) = 1.2$.
  3. $y_1 = 1 + \frac{0.1}{2}(1 + 1.2)$ $= 1.11$.
  4. Exact: $y(0.1) = 2e^{0.1} - 1.1$ $\approx 1.110342$. Euler alone gives $1.1$ (error $0.0103$); improved Euler's error is $0.00034$.

Respuesta: $y(0.1) \approx 1.11$

Ejemplo resuelto: One step of RK4

For $y' = y$, $y(0) = 1$, take one RK4 step with $h = 0.5$.
  1. $k_1 = 1$; $k_2 = f(0.25, 1.25) = 1.25$; $k_3 = f(0.25, 1.3125)$ $= 1.3125$; $k_4 = f(0.5, 1.65625)$ $= 1.65625$.
  2. $y_1$ $= 1$ $+ \frac{0.5}{6}(1 + 2.5 + 2.625 + 1.65625)$ $= 1 + \frac{0.5}{6}(7.78125)$ $\approx 1.648438$.
  3. Exact: $e^{0.5} \approx 1.648721$, an error of about $0.0003$ with a single large step.

Respuesta: $y(0.5) \approx 1.6484$

Euler's method (orange) on $y' = t + y$ from $(0, 1)$. Its path falls below the true solution (blue) because the slope keeps increasing during each step. Shrink $h$ and watch the error shrink roughly in proportion; the methods above shrink it much faster.

Error común

In improved Euler, evaluating $k_2$ at the old value $y_n$ instead of at the Euler prediction $y_n + hk_1$, or using $h$ instead of $\frac{h}{2}$ in the average. In RK4, the middle slopes use half a step, $t_n + \frac{h}{2}$, but the final update uses the whole $h$. A quick check: your answer should be close to plain Euler's, and closer to the exact value when you know it.

Práctica

Apruebas con 3 respuestas correctas, las 2 últimas seguidas. Cada respuesta correcta da 2 XP.

Cargando la práctica…

Se apoya en

Lleva a

Fuentes y lecturas

  • OpenStax Calculus Volume 2, 4.2 Direction Fields and Numerical Methods
  • Paul's Online Math Notes, Differential Equations: Euler's Method
  • MIT OpenCourseWare 18.03SC Differential Equations (Fall 2011), Unit I: First Order Differential Equations