Escolar Documentos
Profissional Documentos
Cultura Documentos
METODO DE RK-2
Aplicando la regla del trapecio al lado derecho de la ecuación (2)
𝑡𝑛−1 1
∫𝑡 𝑓(𝑦, 𝑡)𝑑𝑡 ≈ 2 ℎ[𝑓(𝑦𝑛 , 𝑡𝑛 ) + 𝑓(𝑦𝑛+1 , 𝑡𝑛+1 )] (3)
𝑛
En esta ecuación 𝑦𝑛+1 es una incógnita, por lo que aproximamos el segundo
término mediante 𝑓( ̅̅̅̅̅̅,
𝑦𝑛+1 𝑡𝑛+1 ), donde ̅̅̅̅̅̅
𝑦𝑛+1 es la primera estimación de 𝑦𝑛+1
obtenida mediante el método de Euler haci adelante. El método se resume
como:
̅̅̅̅̅̅
𝑦 𝑛+1 = 𝑦𝑛 + ℎ𝑓(𝑦𝑛 , 𝑡𝑛 )
1
𝑦𝑛+1 = 𝑦𝑛 + ℎ[𝑓(𝑦𝑛 , 𝑡𝑛 ) + 𝑓(𝑦 ̅̅̅̅̅̅,
𝑛+1 𝑡𝑛+1 )]
2
Una forma canónica de estas últimas expresiones es:
𝑘1 = ℎ𝑓(𝑦𝑛 , 𝑡𝑛 )
𝑘2 = ℎ𝑓(𝑦𝑛 + 𝑘1 , 𝑡𝑛+1 ) (4)
1
𝑦𝑛+1 = 𝑦𝑛 + [𝑘1 + 𝑘2 ]
2
Figura 1:
𝑛 = 1, (𝑡 = 0.2)
𝑘1 = 0.1[(−0.4)(0.0196) + (0.2)] = 0.019216
𝑘2 = 0.1[(−0.4)(0.0196 + 0.019216) + 0.2] = 0.018447
1 1
𝐼2 = 𝐼1 + (𝑘1 + 𝑘2 ) = 0.0196 + (0.019216 + 0.018447) = 0.038431
2 2
% grafico
plot(x,y,x,y)
grid on
title('Plot de dy/dx')
xlabel('Eje x')
ylabel('Eje y')
Página 2 de 6
En la ventana de comandos escribimos
f =
Inline function:
f(R,I) = (-(20/50)*I + 10/50)
SOLUCION
1−0
El intervalo es [0,1] al dividirlo en cinco sub intervalos se tiene ℎ = 5 = 0.2
entonces:
𝑥0 = 0.0, 𝑥1 = 𝑥0 + ℎ = 0.00 + 0.2 = 0.2
𝑥2 = 𝑥1 + ℎ = 0.2 + 0.2 = 0.4
𝑥3 = 𝑥2 + ℎ = 0.4 + 0.2 = 0.6
Página 3 de 6
𝑥4 = 𝑥3 + ℎ = 0.6 + 0.2 = 0.8
𝑥5 = 𝑥4 + ℎ = 0.8 + 0.2 = 1.0
Ahora calculamos las constantes 𝑘1 , 𝑘2 , 𝑘3 , 𝑘4
𝑘1 = 𝑓(𝑥1 , 𝑦1 ) = (0.2 − 16562) = −1.4562
ℎ ℎ𝑘1 1.4562
𝑘2 = 𝑓 (𝑥1 + , 𝑦1 + ) = [(0.2 + 0.2/2) − (1.6562 + 0.2(− )]
2 2 2
= −1.21058
ℎ ℎ𝑘2 0.2 1.21058
𝑘3 = 𝑓 (𝑥1 + , 𝑦1 + ) = [(0.2 + ) − (1.6562 + 0.2(− ))]
2 2 2 2
= −1.235142
𝑘4 = 𝑓(𝑥1 + ℎ, 𝑦1 + ℎ𝑘3 ) = [(0.2 + 0.2) − (1.6562 + 0.2(−1.235142))]
= −1.0091716
Calculo de 𝑦2
ℎ
𝑦(0.4) = 𝑦2 = 𝑦1 + [𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ]
6
0.2
= 1.6562 + ( ) (−1.4562 + 2(−1.21058) + 2(−1.235142) − 1.0091716)
6
= 1.410972813
Continuando el procedimiento, en las siguientes iteraciones se tiene
𝑦(0.6) = 𝑦3 = 1.246450474
𝑦(0.8) = 𝑦4 = 1.148003885
𝑦(1.0) = 𝑦5 = 1.103655714
El cual tiene un error absoluto de 0.00001 y un error porcentual de 0.0009
function f = Ejemplo(x,y)
f(1) = x - y;
>> xx = 0:0.2:1;
>> y0 = [2];
>> [T, Y] = ode45('Ejemplo', xx, y0)
T =
0
0.200000000000000
0.400000000000000
0.600000000000000
0.800000000000000
1.000000000000000
Y =
2.000000000000000
1.656192260848395
1.410960140750517
1.246434911528673
1.147986895895780
1.103638327141421
Página 4 de 6
>>
x =
0
Página 5 de 6
0.200000000000000
0.400000000000000
0.600000000000000
0.800000000000000
1.000000000000000
y =
2.000000000000000
1.656200000000000
1.410972813333333
1.246450474703111
1.148003885321927
1.103655714375906
2015-1
Página 6 de 6