Métodos de cuarto orden

Para \( s = 4 \) $$ \begin{align*} k_{1} &= f(t_{n}, y_{n}) \\ k_{2} &= f(t_{n} + c_{2} h, y_{n} + h(a_{21} k_{1})) \\ k_{3} &= f(t_{n} + c_{3} h, y_{n} + h(a_{31} k_{1} + a_{32} k_{2})) \\ k_{4} &= f(t_{n} + c_{4} h, y_{n} + h(a_{41} k_{1} + a_{42} k_{2} + a_{43} k_{3})) \\ y_{n+1} &= y_{n} + h (b_{1} k_{1} + b_{2} k_{2} + b_{3} k_{3} + b_{4} k_{4}) \end{align*} $$

tabla parametrizada de Butcher desarrollado por Tan Delin y Chen Zhen

\begin{array}{c|c c c} 0 & & & & \\ \frac{1}{2} & \frac{1}{2} & & & \\ \frac{1}{2} & \frac{1}{2} - \frac{1}{\lambda} & \frac{1}{\lambda} & & \\ 1 & 0 & 1 - \frac{\lambda}{2} & \frac{\lambda}{2} & \\ \hline & \frac{1}{6} & \frac{4 - \lambda}{6} & \frac{\lambda}{6} & \frac{1}{6} \end{array}

si \( \lambda = 2 \)

\begin{array}{c|c c c} 0 & & & & \\ \frac{1}{2} & \frac{1}{2} & & & \\ \frac{1}{2} & 0 & \frac{1}{2} & & \\ 1 & 0 & 0 & 1 & \\ \hline & \frac{1}{6} & \frac{1}{3} & \frac{1}{3} & \frac{1}{6} \end{array}

reemplazando se obtiene el método clásico de cuarto orden $$ \begin{align*} k_{1} &= f(t_{n}, y_{n}) \\ k_{2} &= f \left( t_{n} + \frac{1}{2} h, y_{n} + h \left( \frac{1}{2} k_{1} \right) \right) \\ k_{3} &= f \left( t_{n} + \frac{1}{2} h, y_{n} + h \left( \frac{1}{2} k_{2} \right) \right) \\ k_{4} &= f(t_{n} + h, y_{n} + h(k_{3})) \\ y_{n+1} &= y_{n} + h \left( \frac{1}{6} k_{1} + \frac{1}{3} k_{2} + \frac{1}{3} k_{3} + \frac{1}{6} k_{4} \right) \end{align*} $$

Resolver $$ \begin{align*} y' &= 4 e^{0.8 x} - 0.5 y \\ y(0) &= 2 \\ y(1) &= ? \end{align*} $$

Para la solución numérica elegimos \( n = 2 \) $$ \begin{equation*} h = \frac{x_{f} - x_{i}}{n} = \frac{1 - 0}{2} = 0.5 \end{equation*} $$

Iteracion 0 $$ \begin{align*} y_{0} &= 2 \\ x_{0} &= 0 \end{align*} $$

Iteración 1 $$ \begin{align*} k_{1} &= f(x_{0}, y_{0}) = f(0, 2) \\ &= 4 e^{0.8 (0)} - 0.5 (2) = 3 \\ k_{2} &= f \left( x_{0} + \frac{1}{2} h, y_{0} + h \left( \frac{1}{2} k_{1} \right) \right) = f ( 0 + 0.5(0.5), 2 + 0.5(0.5 \cdot 3)) = f(0.25, 2.75) \\ &= 4 e^{0.8 (0.25)} - 0.5 (2.75) = 3.511 \\ k_{3} &= f \left( x_{0} + \frac{1}{2} h, y_{0} + h \left( \frac{1}{2} k_{2} \right) \right) = f ( 0 + 0.5(0.5), 2 + 0.5(0.5 \cdot 3.511)) = f(0.25, 2.878) \\ &= 4 e^{0.8 (0.25)} - 0.5 (2.878) = 3.447 \\ k_{4} &= f(x_{0} + h, y_{0} + h(k_{3})) = f(0 + 0.5, 2 + 0.5(3.447)) = f(0.5, 3.724) \\ &= 4 e^{0.8 (0.5)} - 0.5 (3.724) = 4.105 \\ y_{1} &= y_{0} + h \left( \frac{1}{6} k_{1} + \frac{1}{3} k_{2} + \frac{1}{3} k_{3} + \frac{1}{6} k_{4} \right) \\ &= 2 + 0.5[0.167(3) + 0.333(3.511) + 0.333(3.447) + 0.167(4.105)] = 3.752 \\ x_{1} &= x_{0} + h \\ &= 0 + 0.5 = 0.5 \end{align*} $$

Iteración 2 $$ \begin{align*} k_{1} &= f(x_{1}, y_{1}) = f(0.5, 3.752) \\ &= 4 e^{0.8 (0.5)} - 0.5 (3.752) = 4.091 \\ k_{2} &= f \left( x_{1} + \frac{1}{2} h, y_{1} + h \left( \frac{1}{2} k_{1} \right) \right) = f ( 0.5 + 0.5(0.5), 3.752 + 0.5(0.5 \cdot 4.091)) = f(0.75, 4.775) \\ &= 4 e^{0.8 (0.75)} - 0.5 (4.775) = 4.901 \\ k_{3} &= f \left( x_{1} + \frac{1}{2} h, y_{1} + h \left( \frac{1}{2} k_{2} \right) \right) = f ( 0.5 + 0.5(0.5), 3.752 + 0.5(0.5 \cdot 4.901)) = f(0.75, 4.977) \\ &= 4 e^{0.8 (0.75)} - 0.5 (4.977) = 4.8 \\ k_{4} &= f(x_{1} + h, y_{1} + h(k_{3})) = f(0.5 + 0.5, 3.752 + 0.5(4.8)) = f(1, 6.152) \\ &= 4 e^{0.8 (1)} - 0.5 (6.152) = 5.826 \\ y_{2} &= y_{1} + h \left( \frac{1}{6} k_{1} + \frac{1}{3} k_{2} + \frac{1}{3} k_{3} + \frac{1}{6} k_{4} \right) \\ &= 3.752 + 0.5[0.167(4.091) + 0.333(4.901) + 0.333(4.8) + 0.167(5.826)] = 6.195 \\ x_{2} &= x_{1} + h \\ &= 0.5 + 0.5 = 1 \end{align*} $$

function prueba3(f::Function, n, xi, yi, xf)
    h = (xf - xi)/n
    y = yi
    x = xi
    c2 = 1/2
    a21 = 1/2
    c3 = 1/2
    a31 = 0
    a32 = 1/2
    c4 = 1
    a41 = 0
    a42 = 0
    a43 = 1
    b1 = 1/6
    b2 = 1/3
    b3 = 1/3
    b4 = 1/6
    @printf("%s  %s  %8s  %8s  %8s  %7s  %8s\n", "i", "k1", "k2", "k3", "k4", "x", "y")
    for i = 1:n
        k1 = f(x,y)
        k2 = f(x + (c2 * h), y + (h * a21 * k1))
        k3 = f(x + (c3 * h), y + (h * ((a31 * k1) + (a32 * k2))))
        k4 = f(x + (c4 * h), y + (h * ((a41 * k1) + (a42 * k2) + (a43 * k3))))
        y = y + (h * ((b1 * k1) + (b2 * k2) + (b3 * k3) + (b4 * k4)))
        x = x + h
        @printf("%d  %f  %f  %f  %f  %f  %f\n", i, k1, k2, k3, k4, x, y)
    end
    println("x = $x")
    println("y = $y")
end

    prueba3 (generic function with 1 method)

prueba3(f,2,0,2,1)

    i  k1        k2        k3        k4        x         y
    1  3.000000  3.510611  3.446785  4.105603  0.500000  3.751699
    2  4.091449  4.901194  4.799976  5.826320  1.000000  6.195042
    x = 1.0
    y = 6.1950419941330015

Método regla \( \frac{3}{8} \) (Kutta, 1901)

\begin{array}{c|c c c} 0 & & & & \\ \frac{1}{3} & \frac{1}{3} & & & \\ \frac{2}{3} & -\frac{1}{3} & 1 & & \\ 1 & 1 & -1 & 1 & \\ \hline & \frac{1}{8} & \frac{3}{8} & \frac{3}{8} & \frac{1}{8} \end{array}

reemplazando $$ \begin{align*} k_{1} &= f(t_{n}, y_{n}) \\ k_{2} &= f \left( t_{n} + \frac{1}{3} h, y_{n} + h \left( \frac{1}{3} k_{1} \right) \right) \\ k_{3} &= f \left( t_{n} + \frac{2}{3} h, y_{n} + h \left( -\frac{1}{3} k_{1} + k_{2} \right) \right) \\ k_{4} &= f(t_{n} + h, y_{n} + h(k_{1} - k_{2} + k_{3})) \\ y_{n+1} &= y_{n} + h \left( \frac{1}{8} k_{1} + \frac{3}{8} k_{2} + \frac{3}{8} k_{3} + \frac{1}{8} k_{4} \right) \end{align*} $$

Resolver $$ \begin{align*} y' &= 4 e^{0.8 x} - 0.5 y \\ y(0) &= 2 \\ y(1) &= ? \end{align*} $$

Para la solución numérica elegimos \( n = 2 \) $$ \begin{equation*} h = \frac{x_{f} - x_{i}}{n} = \frac{1 - 0}{2} = 0.5 \end{equation*} $$

Iteracion 0 $$ \begin{align*} y_{0} &= 2 \\ x_{0} &= 0 \end{align*} $$

Iteración 1 $$ \begin{align*} k_{1} &= f(x_{0}, y_{0}) = f(0, 2) \\ &= 4 e^{0.8 (0)} - 0.5 (2) = 3 \\ k_{2} &= f \left( x_{0} + \frac{1}{3} h, y_{0} + h \left( \frac{1}{3} k_{1} \right) \right) = f ( 0 + 0.333(0.5), 2 + 0.5(0.333 \cdot 3)) = f(0.166, 2.5) \\ &= 4 e^{0.8 (0.166)} - 0.5 (2.5) = 3.318 \\ k_{3} &= f \left( x_{0} + \frac{2}{3} h, y_{0} + h \left( -\frac{1}{3} k_{1} + k_{2} \right) \right) = f ( 0 + 0.667(0.5), 2 + 0.5[(-0.333 \cdot 3) + 3.318]) = f(0.334, 3.16) \\ &= 4 e^{0.8 (0.334)} - 0.5 (3.16) = 3.645 \\ k_{4} &= f(x_{0} + h, y_{0} + h(k_{1} - k_{2} + k_{3})) = f(0 + 0.5, 2 + 0.5(3 - 3.318 + 3.645)) = f(0.5, 3.664) \\ &= 4 e^{0.8 (0.5)} - 0.5 (3.664) = 4.135 \\ y_{1} &= y_{0} + h \left( \frac{1}{8} k_{1} + \frac{3}{8} k_{2} + \frac{3}{8} k_{3} + \frac{1}{8} k_{4} \right) \\ &= 2 + 0.5[0.125(3) + 0.375(3.318) + 0.375(3.645) + 0.125(4.135)] = 3.752 \\ x_{1} &= x_{0} + h \\ &= 0 + 0.5 = 0.5 \end{align*} $$

Iteración 2 $$ \begin{align*} k_{1} &= f(x_{1}, y_{1}) = f(0.5, 3.752) \\ &= 4 e^{0.8 (0.5)} - 0.5 (3.752) = 4.091 \\ k_{2} &= f \left( x_{1} + \frac{1}{3} h, y_{1} + h \left( \frac{1}{3} k_{1} \right) \right) = f ( 0.5 + 0.333(0.5), 3.752 + 0.5(0.333 \cdot 4.091)) = f(0.666, 4.433) \\ &= 4 e^{0.8 (0.666)} - 0.5 (4.433) = 4.598 \\ k_{3} &= f \left( x_{1} + \frac{2}{3} h, y_{1} + h \left( -\frac{1}{3} k_{1} + k_{2} \right) \right) = f ( 0.5 + 0.667(0.5), 3.752 + 0.5[(-0.333 \cdot 4.091) + 4.598]) = f(0.834, 5.37) \\ &= 4 e^{0.8 (0.834)} - 0.5 (5.37) = 5.11 \\ k_{4} &= f(x_{1} + h, y_{1} + h(k_{1} - k_{2} + k_{3})) = f(0.5 + 0.5, 3.752 + 0.5(4.091 - 4.598 + 5.11)) = f(1, 6.054) \\ &= 4 e^{0.8 (1)} - 0.5 (6.054) = 5.875 \\ y_{2} &= y_{1} + h \left( \frac{1}{8} k_{1} + \frac{3}{8} k_{2} + \frac{3}{8} k_{3} + \frac{1}{8} k_{4} \right) \\ &= 3.752 + 0.5[0.125(4.091) + 0.375(4.598) + 0.375(5.11) + 0.125(5.875)] = 6.195 \\ x_{2} &= x_{1} + h \\ &= 0.5 + 0.5 = 1 \end{align*} $$

function prueba4(f::Function, n, xi, yi, xf)
    h = (xf - xi)/n
    y = yi
    x = xi
    c2 = 1/3
    a21 = 1/3
    c3 = 2/3
    a31 = -1/3
    a32 = 1
    c4 = 1
    a41 = 1
    a42 = -1
    a43 = 1
    b1 = 1/8
    b2 = 3/8
    b3 = 3/8
    b4 = 1/8
    @printf("%s  %s  %8s  %8s  %8s  %7s  %8s\n", "i", "k1", "k2", "k3", "k4", "x", "y")
    for i = 1:n
        k1 = f(x,y)
        k2 = f(x + (c2 * h), y + (h * a21 * k1))
        k3 = f(x + (c3 * h), y + (h * ((a31 * k1) + (a32 * k2))))
        k4 = f(x + (c4 * h), y + (h * ((a41 * k1) + (a42 * k2) + (a43 * k3))))
        y = y + (h * ((b1 * k1) + (b2 * k2) + (b3 * k3) + (b4 * k4)))
        x = x + h
        @printf("%d  %f  %f  %f  %f  %f  %f\n", i, k1, k2, k3, k4, x, y)
    end
    println("x = $x")
    println("y = $y")
end

    prueba4 (generic function with 1 method)

prueba4(f,2,0,2,1)

    i  k1        k2        k3        k4        x         y
    1  3.000000  3.320523  3.642290  4.136857  0.500000  3.751581
    2  4.091508  4.601670  5.105687  5.877492  1.000000  6.194773
    x = 1.0
    y = 6.194772995719224