Si $M$ es un valor desconocido y $N(h)$ una fórmula de aproximación, el error será
\begin{equation*} M - N(h) = K_{1} h + K_{2} h^{2} + K_{3} h^{3} + K_{4} h^{4} + K_{5} h^{5} + \cdots \end{equation*}Reescribiendo la anterior ecuación el valor desconocido $M$ tiene una aproximación de $\mathcal{O}(h)$
\begin{equation*} M = N(h) + K_{1} h + K_{2} h^{2} + K_{3} h^{3} + K_{4} h^{4} + K_{5} h^{5} + \cdots \end{equation*}Combinando dos fórmulas de aproximación de diferente tamaño de paso puede obtenerse una aproximación de $\mathcal{O}(h^{2})$
\begin{equation*} M = \hat{N}(h) + \hat{K}_{1} h^{2} + \hat{K}_{2} h^{3} + \hat{K}_{3} h^{4} + \hat{K}_{4} h^{5} + \cdots \end{equation*}Disminuyendo el tamaño de paso a la mitad de la aproximación $\mathcal{O}(h)$
\begin{equation*} M = N_{1} \biggl( \frac{h}{2} \biggr) + \frac{1}{2} K_{1} h + \frac{1}{4} K_{2} h^{2} + \frac{1}{8} K_{3} h^{3} + \frac{1}{16} K_{4} h^{4} + \frac{1}{32} K_{5} h^{5} + \cdots \end{equation*}Multiplicando por dos
\begin{equation*} 2 M = 2 N_{1} \biggl( \frac{h}{2} \biggr) + K_{1} h + \frac{1}{2} K_{2} h^{2} + \frac{1}{4} K_{3} h^{3} + \frac{1}{8} K_{4} h^{4} + \frac{1}{16} K_{5} h^{5} + \cdots \end{equation*}Restando la aproximación $\mathcal{O}(h)$
\begin{equation*} M = 2 N_{1} \biggl( \frac{h}{2} \biggr) - N_{1}(h) - \frac{1}{2} K_{2} h^{2} - \frac{3}{4} K_{3} h^{3} - \frac{7}{8} K_{4} h^{4} - \frac{15}{16} K_{5} h^{5} - \cdots \end{equation*}Agrupando términos
\begin{equation*} M = N_{1} \biggl( \frac{h}{2} \biggr) + \biggl[ N_{1} \biggl( \frac{h}{2} \biggr) - N_{1}(h) \biggr] - \frac{1}{2} K_{2} h^{2} - \frac{3}{4} K_{3} h^{3} - \frac{7}{8} K_{4} h^{4} - \frac{15}{16} K_{5} h^{5} - \cdots \end{equation*}Usando un cambio de variable
\begin{equation} M = N_{2}(h) - \frac{1}{2} K_{2} h^{2} - \frac{3}{4} K_{3} h^{3} - \frac{7}{8} K_{4} h^{4} - \frac{15}{16} K_{5} h^{5} - \cdots \end{equation}Disminuyendo el tamaño de paso a la mitad de la aproximación $\mathcal{O}(h^{2})$
\begin{equation*} M = N_{2} \biggl( \frac{h}{2} \biggr) - \frac{1}{8} K_{2} h^{2} - \frac{3}{32} K_{3} h^{3} - \frac{7}{128} K_{4} h^{4} - \frac{15}{512} K_{5} h^{5} - \cdots \end{equation*}Multiplicando por cuatro
\begin{equation*} 4 M = 4 N_{2} \biggl( \frac{h}{2} \biggr) - \frac{1}{2} K_{2} h^{2} - \frac{3}{8} K_{3} h^{3} - \frac{7}{32} K_{4} h^{4} - \frac{15}{128} K_{5} h^{5} - \cdots \end{equation*}Restando la aproximación $\mathcal{O}(h^{2})$
\begin{equation*} 3 M = 4 N_{2} \biggl( \frac{h}{2} \biggr) - N_{2}(h) + \frac{3}{8} K_{3} h^{3} + \frac{21}{32} K_{4} h^{4} + \frac{105}{128} K_{5} h^{5} + \cdots \end{equation*}Simplificando y agrupando términos
\begin{equation*} M = N_{2} \biggl( \frac{h}{2} \biggr) + \frac{1}{3} \biggl[ N_{2} \biggl( \frac{h}{2} \biggr) - N_{2}(h) \biggr] + \frac{1}{8} K_{3} h^{3} + \frac{7}{32} K_{4} h^{4} + \frac{35}{128} K_{5} h^{5} + \cdots \end{equation*}Usando un cambio de variable
\begin{equation} M = N_{3}(h) + \frac{1}{8} K_{3} h^{3} + \frac{7}{32} K_{4} h^{4} + \frac{35}{128} K_{5} h^{5} + \cdots \end{equation}Disminuyendo el tamaño de paso a la mitad de la aproximación $\mathcal{O}(h^{3})$
\begin{equation*} M = N_{3} \biggl( \frac{h}{2} \biggr) + \frac{1}{64} K_{3} h^{3} + \frac{7}{512} K_{4} h^{4} + \frac{35}{4096} K_{5} h^{5} + \cdots \end{equation*}Multiplicando por ocho
\begin{equation*} 8 M = 8 N_{3} \biggl( \frac{h}{2} \biggr) + \frac{1}{8} K_{3} h^{3} + \frac{7}{64} K_{4} h^{4} + \frac{35}{512} K_{5} h^{5} + \cdots \end{equation*}Restando la aproximación $\mathcal{O}(h^{3})$
\begin{equation*} 7 M = 8 N_{3} \biggl( \frac{h}{2} \biggr) - N_{3}(h) - \frac{7}{64} K_{4} h^{4} - \frac{105}{512} K_{5} h^{5} - \cdots \end{equation*}Simplificando y agrupando términos
\begin{equation*} M = N_{3} \biggl( \frac{h}{2} \biggr) + \frac{1}{7} \biggl[ N_{3} \biggl( \frac{h}{2} \biggr) - N_{3}(h) \biggr] - \frac{1}{64} K_{4} h^{4} - \frac{15}{512} K_{5} h^{5} - \cdots \end{equation*}Usando un cambio de variable
\begin{equation} M = N_{4}(h) - \frac{1}{64} K_{4} h^{4} - \frac{15}{512} K_{5} h^{5} - \cdots \end{equation}Calcular $f'(0.5)$ usando una diferencia hacia adelante
\begin{equation*} f(x) = - 0.10 x^{4} - 0.15 x^{3} - 0.5 x^{2} - 0.25 x + 1.2 \end{equation*}Aproximación con $h=1$
\begin{equation*} f'(0.5) = \frac{f(1.5) - f(0.5)}{1} = \frac{-1.3125 - 0.925}{1} = -2.2375 \end{equation*}Aproximación con $h=0.5$
\begin{equation*} f'(0.5) = \frac{f(1) - f(0.5)}{1} = \frac{0.2 - 0.925}{0.5} = -1.45 \end{equation*}Extrapolación $\mathcal{O}(h)$
\begin{equation*} f'(0.5) = -1.45 + \bigl[ -1.45 - (-2.2375) \bigr] = -0.6625 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-0.6625 - (-1.45)}{-0.6625}\bigg| \times 100\% = 118.87\% \end{equation*}Aproximación con $h=0.25$
\begin{equation*} f'(0.5) = \frac{f(0.75) - f(0.5)}{0.25} = \frac{0.636328 - 0.925}{0.25} = -1.154688 \end{equation*}Extrapolación $\mathcal{O}(h)$
\begin{equation*} f'(0.5) = -1.154688 + \bigl[ -1.154688 - (-1.45) \bigr] = -0.859376 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-0.859376 - (-1.154688)}{-0.859376}\bigg| \times 100\% = 34.36\% \end{equation*}Extrapolación $\mathcal{O}(h^{2})$
\begin{equation*} f'(0.5) = -0.859376 + \frac{1}{3} \bigl[ -0.859376 - (-0.6625) \bigr] = -0.925001 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-0.925001 - (-0.859376)}{-0.925001}\bigg| \times 100\% = 7.09\% \end{equation*}Aproximación con $h=0.125$
\begin{equation*} f'(0.5) = \frac{f(0.625) - f(0.5)}{0.125} = \frac{0.796558 - 0.925}{0.125} = -1.027539 \end{equation*}Extrapolación $\mathcal{O}(h)$
\begin{equation*} f'(0.5) = -1.027539 + \bigl[ -1.027539 - (-1.154688) \bigr] = -0.900390 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-0.900390 - (-1.027539)}{-0.900390}\bigg| \times 100\% = 14.12\% \end{equation*}Extrapolación $\mathcal{O}(h^{2})$
\begin{equation*} f'(0.5) = -0.900390 + \frac{1}{3} \bigl[ -0.900390 - (-0.859376) \bigr] = -0.914061 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-0.914061 - (-0.900390)}{-0.914061}\bigg| \times 100\% = 1.5\% \end{equation*}Extrapolación $\mathcal{O}(h^{3})$
\begin{equation*} f'(0.5) = -0.914061 + \frac{1}{7} \bigl[ -0.914061 - (-0.925001) \bigr] = -0.912498 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg| \frac{-0.912498 - (-0.914061)}{-0.912498} \bigg| \times 100\% = 0.17\% \end{equation*}Resumiendo los resultados en una matriz
\begin{equation*} \begin{array}{c|cccc} h & f'(0.5) & \mathcal{O}(h) & \mathcal{O}(h^{2}) & \mathcal{O}(h^{3}) \\ \hline 1 & -2.2375 & & & \\ 0.5 & -1.45 & -0.6625 & & \\ 0.25 & -1.154688 & -0.859376 & -0.925001 & \\ 0.125 & -1.027539 & -0.900390 & -0.914061 & -0.912498 \end{array} \end{equation*}Lo anterior puede escribirse como
\begin{equation*} \begin{matrix} \mathcal{O}(h) & \mathcal{O}(h^{2}) & \mathcal{O}(h^{3}) & \mathcal{O}(h^{4}) \\ \hline N_{(1,1)} & & & \\ N_{(2,1)} & N_{(2,2)} & & \\ N_{(3,1)} & N_{(3,2)} & N_{(3,3)} & \\ N_{(4,1)} & N_{(4,2)} & N_{(4,3)} & N_{(4,4)} \end{matrix} \end{equation*}Lo anterior puede escribirse como
\begin{align*} N_{(i,?)} &= N(h) \\ N_{(i,?)} &= N_{(i,?)} + \frac{1}{2^{?-1} - 1} \bigl[ N_{(i,?)} - N_{(i-1,?)} \bigr] \end{align*}para $i = 1, 2, 3, 4 = 1, \dots, m$
Lo anterior puede escribirse como
\begin{align*} N_{(i,1)} &= N(h) \\ N_{(i,j)} &= N_{(i,j-1)} + \frac{1}{2^{j-1} - 1} \bigl[ N_{(i,j-1)} - N_{(i-1,j-1)} \bigr] \end{align*}para
\begin{align*} j &= 2 \\ &= 2, 3 \\ &= 2, 3, 4 \end{align*}function extrapolacion_Richarson_n(f, x, h)
for i=1 to m do
N(i,1) = g(f, x, h)
for j=2 to i+1 do
N(i,j) = N(i,j-1) + (N(i,j-1) - N(i-1,j-1))/(2^(j-1) - 1)
end for
h = h/2
end for
return N
end function
In [1]:
import numpy as np
def g(x):
resultado = - 0.1*x**4 - 0.15*x**3 - 0.5*x**2 - 0.25*x + 1.2
return resultado
def diferencia_adelante(f,x,h):
derivada = (f(x+h) - f(x))/h
return derivada
def extrapolacion_Richarson_n(f,x,h):
m = 4
N = np.zeros((m,m))
for i in range(0,m):
N[i,0] = diferencia_adelante(f,x,h)
for j in range(1,i+1):
N[i,j] = N[i,j-1] + (N[i,j-1] - N[i-1,j-1])/(2**j - 1)
h = h/2
return N
In [2]:
A = extrapolacion_Richarson_n(g,0.5,1.0)
print(A)
Disminuyendo el tamaño de paso a la mitad de la aproximación $\mathcal{O}(h^{2})$
\begin{equation*} M = N_{1} \biggl( \frac{h}{2} \biggr) + \frac{1}{4} K_{1} h^{2} + \frac{1}{16} K_{2} h^{4} + \frac{1}{64} K_{3} h^{6} + \frac{1}{256} K_{4} h^{8} + \frac{1}{1024} K_{5} h^{10} + \cdots \end{equation*}Multiplicando por cuatro
\begin{equation*} 4 M = 4 N_{1} \biggl( \frac{h}{2} \biggr) + K_{1} h^{2} + \frac{1}{4} K_{2} h^{4} + \frac{1}{16} K_{3} h^{6} + \frac{1}{64} K_{4} h^{8} + \frac{1}{256} K_{5} h^{10} + \cdots \end{equation*}Restando la aproximación $\mathcal{O}(h^{2})$
\begin{equation*} 3 M = 4 N_{1} \biggl( \frac{h}{2} \biggr) - N_{1}(h) - \frac{3}{4} K_{2} h^{4} - \frac{15}{16} K_{3} h^{6} - \frac{63}{64} K_{4} h^{8} - \frac{255}{256} K_{5} h^{10} - \cdots \end{equation*}Simplificando y agrupando términos
\begin{equation*} M = N_{1} \biggl( \frac{h}{2} \biggr) + \frac{1}{3} \biggl[ N_{1} \biggl( \frac{h}{2} \biggr) - N_{1}(h) \biggr] - \frac{1}{4} K_{2} h^{4} - \frac{5}{16} K_{3} h^{6} - \frac{21}{64} K_{4} h^{8} - \frac{85}{256} K_{5} h^{10} - \cdots \end{equation*}Usando un cambio de variable
\begin{equation} M = N_{2}(h) - \frac{1}{4} K_{2} h^{4} - \frac{5}{16} K_{3} h^{6} - \frac{21}{64} K_{4} h^{8} - \frac{85}{256} K_{5} h^{10} - \cdots \end{equation}Calcular $f'(0.5)$ usando una diferencia hacia adelante
\begin{equation*} f(x) = - 0.10 x^{4} - 0.15 x^{3} - 0.5 x^{2} - 0.25 x + 1.2 \end{equation*}Aproximación con $h=1$
\begin{equation*} f'(0.5) = \frac{f(1.5) - f(0.5)}{1} = \frac{-1.3125 - 0.925}{1} = -2.2375 \end{equation*}Aproximación con $h=0.5$
\begin{equation*} f'(0.5) = \frac{f(1) - f(0.5)}{1} = \frac{0.2 - 0.925}{0.5} = -1.45 \end{equation*}Extrapolación $\mathcal{O}(h^{2})$
\begin{equation*} f'(0.5) = -1.45 + \frac{1}{3} \bigl[ -1.45 - (-2.2375) \bigr] = -1.1875 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-1.1875 - (-1.45)}{-1.1875}\bigg| \times 100\% = 22.1\% \end{equation*}Aproximación con $h=0.25$
\begin{equation*} f'(0.5) = \frac{f(0.75) - f(0.5)}{0.25} = \frac{0.636328 - 0.925}{0.25} = -1.154688 \end{equation*}Extrapolación $\mathcal{O}(h^{2})$
\begin{equation*} f'(0.5) = -1.154688 + \frac{1}{3} \bigl[ -1.154688 - (-1.45) \bigr] = -1.056251 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-1.026251 - (-1.154688)}{-1.026251}\bigg| \times 100\% = 9.32\% \end{equation*}Extrapolación $\mathcal{O}(h^{4})$
\begin{equation*} f'(0.5) = -1.056251 + \frac{1}{15} \bigl[ -1.056251 - (-1.1875) \bigr] = -1.047501 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-1.047501 - (-1.056251)}{-1.047501}\bigg| \times 100\% = 0.84\% \end{equation*}Aproximación con $h=0.125$
\begin{equation*} f'(0.5) = \frac{f(0.625) - f(0.5)}{0.125} = \frac{0.796558 - 0.925}{0.125} = -1.027539 \end{equation*}Extrapolación $\mathcal{O}(h^{2})$
\begin{equation*} f'(0.5) = -1.027539 + \frac{1}{3} \bigl[ -1.027539 - (-1.154688) \bigr] = -0.985152 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-0.985152 - (-1.027539)}{-0.985152}\bigg| \times 100\% = 4.3\% \end{equation*}Extrapolación $\mathcal{O}(h^{4})$
\begin{equation*} f'(0.5) = -0.985152 + \frac{1}{15} \bigl[ -0.985152 - (-1.056251) \bigr] = -0.980412 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-0.980412 - (-0.985152)}{-0.980412}\bigg| \times 100\% = 0.48\% \end{equation*}Extrapolación $\mathcal{O}(h^{6})$
\begin{equation*} f'(0.5) = -0.980412 + \frac{1}{63} \bigl[ -0.980412 - (-1.047501) \bigr] = -0.979347 \end{equation*}Error relativo
\begin{equation*} e_{r} = \bigg|\frac{-0.979347 - (-0.980412)}{-0.979347}\bigg| \times 100\% = 0.11\% \end{equation*}Resumiendo los resultados en una matriz
\begin{equation*} \begin{array}{c|cccc} h & f'(0.5) & \mathcal{O}(h^{2}) & \mathcal{O}(h^{4}) & \mathcal{O}(h^{6}) \\ \hline 1 & -2.2375 & & & \\ 0.5 & -1.45 & -1.1875 & & \\ 0.25 & -1.154688 & -1.056251 & -1.047501 & \\ 0.125 & -1.027536 & -0.985152 & -0.980412 & -0.979347 \end{array} \end{equation*}Lo anterior puede escribirse como
\begin{equation*} \begin{matrix} \mathcal{O}(h^{2}) & \mathcal{O}(h^{4}) & \mathcal{O}(h^{6}) & \mathcal{O}(h^{8}) \\ \hline N_{(1,1)} & & & \\ N_{(2,1)} & N_{(2,2)} & & \\ N_{(3,1)} & N_{(3,2)} & N_{(3,3)} & \\ N_{(4,1)} & N_{(4,2)} & N_{(4,3)} & N_{(4,4)} \end{matrix} \end{equation*}function extrapolacion_Richarson_2n(f, x, h)
for i=1 to m do
N(i,1) = g(f, x, h)
for j=2 to i+1 do
N(i,j) = N(i,j-1) + (N(i,j-1) - N(i-1,j-1))/(4^(j-1) - 1)
end for
h = h/2
end for
return N
end function
In [3]:
def extrapolacion_Richarson_2n(f,x,h):
m = 4
N = np.zeros((m,m))
for i in range(0,m):
N[i,0] = diferencia_adelante(f,x,h)
for j in range(1,i+1):
N[i,j] = N[i,j-1] + (N[i,j-1] - N[i-1,j-1])/(4**j - 1)
h = h/2
return N
In [4]:
B = extrapolacion_Richarson_2n(g,0.5,1.0)
print(B)