Documente Academic
Documente Profesional
Documente Cultură
Del alumno
Al profesor
Angel Sangiacomo
Asunto
Fecha
09-09-2015
Qu hace?
Obtiene una aproximacin al problema de valor inicial bien planteado.
at b
y
=f ( t , y )
t
Obtener
f i , f i1 , f i2
otros mtodos)
f ( t i , y i ) =f i
f ( t i1 , y i1 )=f i1
f ( t i2 , y i2 )=f i2
f ( t i+1 , y i+1 )= y i +
h
[ 23f i 16f i1 +5f i2 ]
12
Variables:
fu: Funcin f(t,y) en formato texto debe contener variables t y y
vi: Valor de Valor Inicial
a: Valor de a
b: Valor de b
n: Numero de iteraciones
h: Tamao de paso
t: Vector con los datos obtenidos pata la variable t
RungeKutta4: Vector con los datos obtenidos por rk4
AdamsBasforth03: Vector con los datos obtenidos por AdamsBasforth de tres
pasos
Algoritmo
f=f(z,t,y): funcin en formato texto debe contener variables t y y
function f=f(z,t,y)
f=eval(z);
RungeKutta4(z,a,b,vi,n) : Funcion que devuelve un vector con los valores de Rk4
function mRungeKutta4=RungeKutta4(z,a,b,vi,n)
mRungeKutta4=[];
h=(b-a)/n;
ti=a;
yrk4=vi;
mRungeKutta4(1)=vi;
for r=2:n+1
k1=h*f(z,ti,yrk4);
k2=h*f(z,ti+h/2,yrk4+k1/2);
k3=h*f(z,ti+h/2,yrk4+k2/2);
k4=h*f(z,ti+h,yrk4+k3);
yrk4=yrk4+1/6*(k1+2*k2+2*k3+k4);
mRungeKutta4(r)=yrk4;
ti=ti+h;
end
Basforth03 (z,a,b,vi,n) : Funcion que devuelve un vector con los valores de Rk4
function mBasforth=Basforth03(z,a,b,vi,n)
mBasforth03=[];
h=(b-a)/n;
ti=a;
yBasforth03=vi;
mBasforth03=RungeKutta4(z,a,b,vi,n);
ti=ti+(3)*h;
r=4;
yBasforth03=mBasforth03 (r-1)+h/12*(23*f(z,ti-1*h,mBasforth03 (r-1))-16*f(z,ti-2*h,mBasforth03
(r-2))+5*f(z,ti-3*h,mBasforth03 (r-3)));
ti=ti+h;
mBasforth03 (r)=yBasforth03;
AdamsBashForth03.m
%------Metodos de AdamsBashForth de 3 pasos-----clc;
disp(' Metodos de AdamsBashForth de 3 pasos ');
fu=input('ingrese funcion f(t,y) = ');
vi=input('ingrese Valor de Valor Inicial = ');
a=input('ingrese Valor de A = ');
b=input('ingrese Valor de B = ');
n=input('ingrese iteraciones = ');
h=(b-a)/n;
fprintf ('\n ti
yi \n ');
AdamsBasforth03=Basforth03(fu,a,b,vi,n);
for i=1:n+1
t(i)= (i-1)*h;
fprintf ('%5.5f %5.5f \n ',t(i),AdamsBasforth03(i));
end
hold off;
plot(t,AdamsBasforth03,'+');
xlabel('Pasos');
ylabel('Valor aproximado');
legend('Metodo AdamsBashForth de 3 pasos');
hold on;
disp('________________');