Documente Academic
Documente Profesional
Documente Cultură
Solucion
2. Respuesta
>> runge2
'it x0 y(x1)
0 0.000000 6.701082
1 1.000000 16.319782
2 2.000000 37.199249
3 3.000000 83.337767
respuesta
>> runge4
'it x0 y(x1)
0 0.000000 1.753950
1 0.100000 2.331200
2 0.200000 2.753950
3 0.300000 3.043200
4 0.400000 3.218750
function ye=f1(x,y)
ye=x*y+1;
clear x,y;
x0=0;
y0=21;
xf=10;
n=20;
h=(xf-x0)/n;
i=1;
x(i)=x0;
y(i)=y0;
while i<=n
k1=h*f1(x0,y0);
k2=h*f1(x0+h/2,y0+k1/2);
k3=h*f1(x0+h/2,y0+k2/2);
k4=h*f1(x0+h,y0+k3);
km=(k1+2*k2+2*k3+k4)/6;
y1=y0+km;
x1=x0+h;
i=i+1;
x(i)=x1;
y(i)=y1;
x0=x1;
y0=y1;
disp([y1])
end
plot(x,y)
grid on
%disp([x1])
%disp([y1])
title('Mtodo de Runge Kutta de cuarto orden')