6. Milne - Simpson
6
k xk pk fpk yk fk
0 x0 y0 f0
1 x1 y1 f1
2 x2 y2 f2
3 x3 y3 f3
4 x4 p4 fp4 y4 f4
n xn pn fpn yn fn
El paso general del método de Milne es:
• Valor corrector:
El método considera el problema de valor inicial:
𝑝𝑘 + 1 = 𝑦𝑘 − 3 +
4ℎ
3
2𝑓𝑘 − 2 − 𝑓𝑘−1 + 2𝑓𝑘
• Valor predictor:
11. Milne - matlab
Solo es valido para EDO de
1er orden
Ejer. 1
11
x0=2; % x0 e y0 puntos iniciales
y0=0;
y1=0.0197; % y1 y2 y3 calculado con RK4
y2=0.0389;
y3=0.0575;
h=0.1; % h paso
n=17; % n numero de divisiones
syms x;
A=1/x;
B=1/(1+x^2);
x1=x0+h;
x2=x1+h;
x3=x2+h;
resultMS=[x0 y0; x1 y1; x2 y2; x3 y3];
%continua en la siguiente hoja
26. Hamming - matlab
Solo es valido para EDO de
1er orden
Ejer. 1
26
x0=2; % x0 e y0 puntos iniciales
y0=0;
y1=0.0197; % y1 y2 y3 calculado con RK4
y2=0.0389;
y3=0.0575;
h=0.1; % h paso
n=17; % n numero de divisiones sobrantes
syms x;
A=1/x;
B=1/(1+x^2);
%%
x1=x0+h;
x2=x1+h;
x3=x2+h;
resultHg=[x0 y0; x1 y1; x2 y2; x3 y3];
%continua en la siguiente hoja
28. x0=0; % x0 e y0 puntos iniciales
y0=[ 1.0000,-1.0000,0]';
y1=[ 0.9013 -0.9613 0.7184]'; % y1, y2, y3 calculado con RK4
y2=[ 0.8096 -0.8653 1.1645]';
y3=[ 0.7294 -0.7342 1.4357]';
h=0.1;
n=17; % 3 de 20 iteraciones ya usamos en RK4
syms x;
a=[8/(1+x)^3,-1/(1+x)^2,-1/(1+x)];
f=x/(1+x)^5;
x1=x0+h;
x2=x1+h;
x3=x2+h;
m=length(y1);
resultHg=[x0, y0(1); x1,y1(1);x2,y2(1);x3,y3(1)];
A=[zeros(m-1,1) eye(m-1);a];
B=[zeros(1,m-1),f]';
Algoritmo Hamming- matlab
Valido para EDO de orden N
N=1, 2, 3…N orden
Ejer. 3
28
29. 29
Valido para EDO de orden N
N=1, 2, 3…N orden
for i=1:n
x=x1;
f1=eval(A)*y1+eval(B);
x=x2;
f2=eval(A)*y2+eval(B);
x=x3;
f3=eval(A)*y3+eval(B);
p=y0+(4/3)*h*(2*f1-f2+2*f3);
x=x3+h;
fp=eval(A)*p+eval(B);
y=(9*y3-y1)/8+(3/8)*h*(-f2+2*f3+fp);
resultHg=[resultHg;x y(1)];
y0=y1;
y1=y2;
y2=y3;
y3=y;
x1=x2;
Ejer. 3
34. x0=0; % x0 e y0 puntos iniciales
y0=[ 1.0000,-1.0000,0]';
y1=[ 0.9013 -0.9613 0.7184]'; % y1, y2, y3 calculado con RK4
y2=[ 0.8096 -0.8653 1.1645]';
y3=[ 0.7294 -0.7342 1.4357]';
h=0.1;
n=17; % 3 de 20 iteraciones ya usamos en RK4
syms x;
a=[8/(1+x)^3,-1/(1+x)^2,-1/(1+x)];
f=x/(1+x)^5;
x1=x0+h;
x2=x1+h;
x3=x2+h;
m=length(y1);
resultHgM=[x0, y0(1); x1,y1(1);x2,y2(1);x3,y3(1)];
A=[zeros(m-1,1) eye(m-1);a];
B=[zeros(1,m-1),f]';
Hamming modificado- matlab
Valido para EDO de orden N
N=1, 2, 3…N orden
Ejer. 3
34
35. 35
Valido para EDO de orden N
N=1, 2, 3…N orden
for i=1:n
x=x1;
f1=eval(A)*y1+eval(B);
x=x2;
f2=eval(A)*y2+eval(B);
x=x3;
f3=eval(A)*y3+eval(B);
p=y0+(4/3)*h*(2*f1-f2+2*f3);
if i>1
mod=p+(112/121)*(y3-p0);
else mod=p;
end
x=x3+h;
fm=eval(A)*mod+eval(B);
y=(9*y3-y1)/8+(3/8)*h*(-f2+2*f3+fm);
resultHgM=[resultHgM;x y(1)];
Ejer. 3