Está en la página 1de 7

Universidad peruana de

ciencias aplicadas
·        INTRODUCCION A LOS METODOS COMPUTACIONALES
. “RESOLUCION DE UNA ECUACION DIFERENCIAL POR EL METODO DE RUNGE KUTA DE
CUARTO ORDEN”
ALUMNO:
·        Mayhua Paucar, Boris Zósimo.
 
PROFESOR:
·        Cuba Samaniego, Lisbeth Mónica.

LIMA 2019-II
TRABAJO 5
• PROBLEMA ASIGNADO: (25.7)
Use le método de RK de cuarto orden, para resolver las siguientes ecuaciones
diferenciales:

• 
 

 en el rango de x = 0 a 0.4, con un tamaño de paso de 0.1, con y(0) = 2 y z(0)=4
Resolución utilizando el método RK para la EDO 1 por Matlab

function f
fprintf('\n \tECUACIONES DIFERENCIALES POR RUNGE-KUTTA DE
ORDEN 4\n')
f=input('\n Ingrese la ecuación 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 condición inicial y(x0):\n');
n=input('\n Ingrese el número de pasos n:\n');
h=(x1-x0)/n;
xs=x0:h:x1;
fprintf('\n''it x0 y(x1)');
for i=1:n
it=i-1;
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);
Para la segunda ecuación diferencial se utiliza el método analítico para
desarrollar la función “y” y así poder desarrollar el método RK de cuarto orden:
   Evaluando que Cuando X=0, Y=2
 
  Entonces obtenemos que C=-3
 
 

*5  
Ahora remplazamos la función “y” en la ecuación
diferencial

 
Resolución utilizando el método RK para la EDO 2 por
Matlab
function f
fprintf('\n \tECUACIONES DIFERENCIALES POR RUNGE-KUTTA DE ORDEN 4\n')
f=input('\n Ingrese la ecuación diferencial\n','s');
x0=input('\n Ingrese el primer punto x0:\n');
x1=input('\n Ingrese el segundo punto x1:\n');
z0=input('\n Ingrese la condición inicial z(x0):\n');
n=input('\n Ingrese el número de pasos n:\n');
h=(x1-x0)/n;
xs=x0:h:x1;
fprintf('\n''it x0 z(x1)');
for i=1:n
it=i-1;
x0=xs(i);
x=x0;
z=z0;
k1=h*eval(f);
x=x0+h/2;
z=z0+k1/2;
k2=h*eval(f);
x=x0+h/2;
z=z0+k2/2;
k3=h*eval(f);
x=x0+h;
z=z0+k3;
k4=h*eval(f);
z0=z0+(k1+2*k2+2*k3+k4)/6;
fprintf('\n%2.0f%10.6f%10.6f\n',it,x0,z0);
end
fprintf('\n El punto aproximado z(x1) es = %8.6f\n',z0);

También podría gustarte