Documente Academic
Documente Profesional
Documente Cultură
k1 = f(xi,yi)
Donde:
Los valores de a1, a2, p1 y q11 son evaluados al igualar el trmino de segundo
orden de la ecuacin dada con la expansin de la serie de Taylor.
Desarrollando tres ecuaciones para evaluar las cuatro incgnitas:
Como se tienen tres ecuaciones con cuatro incgnitas se tiene que suponer el valor
de una de ellas. Suponiendo que se especific un valor para a2, se puede resolver
de manera simultnea el sistema de ecuaciones obtenido:
Como se puede elegir un nmero infinito de valores para a2, hay un nmero
infinito de mtodos Runge-Kutta de segundo orden.
Donde:
- y(0)=1
- h = 0.25
SOLUCIN
y i1 y i k 2 h
k1 f(xi, y i )
1 1
k 2 = f(x i h , y i k 1 h)
2 2
Primera iteracin:
k 1 f(x 0 , y 0 ) f (0 , 1)
-
k1 (1)(0) 2 1.2(1)
k1 1.2
1 1
k 2 f ( x0 h y 0 k1 h )
- 2 , 2
1 1
k 2 f (0 (0.25) 1 (1.2)(0.25))
2 , 2
k 2 f (0.125,0.85)
k 2 0.85(0.125) 2 1.2(0.85)
k 2 1.006718
- y1 1 (1.006718)0.25
y1 0.748320
Segunda iteracin
-
x1 x0 h
x1 0 0.25
x1 0.25
k1 (0.748320)(0.25) 2 1.2(0.748320)
k1 0.851432
1 1
k 2 f (0.25 (0.25) 0.748320 (0.851432)(0.25))
- 2 , 2
k 2 f (0.375,0.641891)
k 2 0.641891(0.375) 2 1.2(0.641891)
k 2 0.680003
y2 0.748320 (0.680003)0.25
y2 0.578319
Tercera iteracin
- x2 x1 h
x2 0.25 0.25
x2 0.5
- k1 f(x 2 , y 2 ) f (0.5,0.578319)
k1 (0.578319)(0.5) 2 1.2(0.578319)
k1 0.549403
1 1
k 2 f ( x2 h y 2 k1 h )
- 2 , 2
1 1
k 2 f (0.5 (0.25) 0.578319 (0.549403)(0.25))
2 , 2
k 2 f (0.625,0.509643)
k 2 0.509643(0.625) 2 1.2(0.509643)
k 2 0.4125
y3 0.578319 (0.4125)0.25
y 3 0.4752
Cuarta iteracin
- x3 x 2 h
x3 0.5 0.25
x3 0.75
-
k 1 f(x 3 , y 3 ) f (0.75,0.4752)
k1 (0.4752)(0.75) 2 1.2(0.4752)
k1 0.3029
1 1
k 2 f ( x3 h y 3 k1 h )
- 2 , 2
1 1
k 2 f (0.75 (0.25) , 0.4752 (0.3029)(0.25))
2 2
k 2 f (0.875,0.4373)
k 2 0.4373(0.875) 2 1.2(0.4373)
k 2 0.1900
- y4 0.4752 (0.1900)0.25
y 4 0.4277
x4 x3 h
x4 0.75 0.25
x4 1
Vectores solucin:
Se resuelve el mismo problema anterior pero esta vez mediante el uso del mtodo
Runge kutta de tercer grado, de valor inicial, en el intervalo de x=0 a x=1.
dy
yx 2 1.2 y
dx
Donde:
- y(0)=1
- h = 0.25
SOLUCIN
1
y i 1 y i (k 1 4k 2 k 3 )h
6
k1 f(xi, y i )
1 1
k 2 = f(x i h , y i k 1 h)
2 2
k 3 f(x i h , y i k 1h 2k 2 h)
Primera iteracin
k1 f(x 0 , y0 ) f (0 , 1)
k1 (1)(0) 2 1.2(1)
k1 1.2
1 1
k 2 f ( x0 h y0 k1 h )
2 2
- ,
1 1
k 2 f (0 (0.25) 1 (1.2)(0.25))
2 , 2
k 2 f (0.125,0.85)
k 2 0.85(0.125) 2 1.2(0.85)
k 2 1.0067
k 3 f(x o h , y o k1h 2k 2 h)
k 3 f (0.25,0.7966)
k 3 0.7966(0.25) 2 1.2(0.7966)
k 3 0.9062
1
y1 y 0 (k 1 4k 2 k 3 )h
6
y1 0.7445
Segunda iteracin
- x1 x0 h
x1 0 0.25
x1 0.25
k1 (0.7445)(0.25) 2 1.2(0.7445)
k1 0.8468
1 1
k 2 f ( x1 h y1 k1 h)
- 2 , 2
1 1
k 2 f (0.25 (0.25) 0.7445 (0.8469)(0.25))
2 , 2
k 2 f (0.375,0.6386)
k 2 0.6386(0.375) 2 1.2(0.6386)
k 2 0.6765
-
k 3 f(x 1 h , y1 k 1h 2k 2 h)
k 3 f (0.5,0.6178)
k 3 0.6178(0.5) 2 1.2(0.6178)
k 3 0.5870
1
y 2 y1 (k 1 4k 2 k 3 )h
- 6
y2 0.5720
Tercera iteracin
x2 x1 h
x2 0.25 0.25
x2 0.5
- k1 f(x 2 , y 2 ) f (0.5,0.5720)
k1 (0.5720)(0.5) 2 1.2(0.5720)
k1 0.5434
1 1
k 2 f ( x2 h y 2 k1 h )
- 2 , 2
1 1
k 2 f (0.5 (0.25) 0.5720 (0.5434)(0.25))
2 , 2
k 2 f (0.625,0.5041)
k 2 0.5041(0.625) 2 1.2(0.5041)
k 2 0.4080
- k 3 f(x 2 h , y 2 k 1h 2k 2 h)
k 3 f (0.75,0.5038)
k 3 0.5038(0.75) 2 1.2(0.5038)
k 3 0.3212
1
y 3 y 2 (k 1 4k 2 k 3 )h
- 6
y3 0.4679
Cuarta iteracin
x3 x 2 h
-
x3 0.5 0.25
x3 0.75
k 1 f(x 3 , y 3 ) f (0.75,0.4679)
-
k1 (0.4679)(0.75) 2 1.2(0.4679)
k1 0.2986
1 1
k 2 f ( x3 h y 3 k1 h )
- 2 , 2
1 1
k 2 f (0.75 (0.25) 0.4679 (0.2983)(0.25))
2 , 2
k 2 f (0.875,0.4306)
k 2 0.4306(0.875) 2 1.2(0.4306)
k 2 0.1871
- k 3 f(x 3 h , y 3 k 1h 2k 2 h)
k 3 f (1,0.4489)
k 3 0.4489(1) 2 1.2(0.4489)
k 3 0.0898
1
y 4 y 3 (k 1 4k 2 k 3 )h
- 6
y4 0.4206
x 4 x3 h
x4 0.75 0.25
x4 1
Vectores solucin
vectory
vectort
subplot (1,1,1);
plot(vectort,vectory,'r-*');
title('Mtodo runge kutta Tercer orden. y vs t');
xlabel ('valores t');
ylabel ('valores y');
Runge Kutta para cuarto orden.
Los llamados mtodos de Runge-Kutta son una serie de algoritmos para calcular
aproximaciones numricas del valor de la solucin de:
= (, ); () =
Con muy buena precisin, sin que, para ello, sea necesario que los h sean muy
pequeos. El procedimiento consta de los siguientes pasos:
k1 h f ( x0 , y0 )
h k
k 2 h f ( x0 , y0 1 )
2 2
h k
k3 h f ( x0 , y0 2 )
2 2
k4 h f ( x0 h, y0 k3 )
1
K 0 (k1 2k 2 2k3 k 4 )
6
y entonces se toma:
y1 y0 K 0
Del mismo modo, se calcula el valor aproximado de
la solucin, y , en el punto x = x + h:
2 2 1
k1 h f ( x1 , y1 )
h k
k 2 h f ( x1 , y1 1 )
2 2
h k
k3 h f ( x1 , y1 2 )
2 2
k4 h f ( x1 h, y1 k3 )
1
K0 (k1 2k 2 2k3 k 4 )
6
y2 y1 K 0
Y as, sucesivamente
El algoritmo es el siguiente:
function f
fprintf('\n \tRESOLUCION DE ECUACIONES DIFERENCIALES POR MEDIO RUNGE-KUTTA DE
ORDEN 4\n')
f=input('\n Ingrese la ecuacion diferencial\n','s');
x0=input('\n Ingrese el primer punto x0:\n');
x1=input('\n Ingrese el segundo punto x1:\n');
y0=input('\n Ingrese la condicion inicial y(x0):\n');
n=input('\n Ingrese el numero de pasos n:\n');
h=(x1-x0)/n;
xs=x0:h:x1;
fprintf('\n''it x0 y(x1)');
for i=1:n
it=i;
x0=xs(i);
x=x0;
y=y0;
k1=h*eval(f);
x=x0+h/2;
y=y0+k1/2;
k2=h*eval(f);
x=x0+h/2;
y=y0+k2/2;
k3=h*eval(f);
x=x0+h;
y=y0+k3;
k4=h*eval(f);
y0=y0+(k1+2*k2+2*k3+k4)/6;
fprintf('\n%2.0f%10.6f%10.6f\n',it,x0,y0);
end
fprintf('\n El punto aproximado y(x1) es = %8.6f\n',y0);