Predictor Corrector Methods
Predictor Corrector Methods
The task
The RK4 code that is mentioned above is as follows:
function [y,fvalues] = RK4(f,h,y0,a,s)
y=zeros(1,s+1);
fvalues=zeros(1,s+1);
y(1)=y0;
b = a+s*h;
t = a:h:b;
for i=1:s
fvalues(i) = f(t(i),y(i));
k1=h*fvalues(i);
k2=h*f(t(i)+h/2,y(i)+k1/2);
k3=h*f(t(i)+h/2,y(i)+k2/2);
k4 =h*f(t(i)+h,y(i)+k3) ;
y(i+1)=y(i)+ (1/6)*(k1+2*k2+2*k3+k4);
end
fvalues(s+1) = f(t(s+1),y(s+1));
end
I will attach two separate PDF’s that give more information about RK(The
Runge-Kutta method) and about predictor corrector methods as, it should help
with understanding of how the theory of the methods works and how they
work on paper.
I’m knowledgeable on the written theory and can do written exercises easily so
I can answer any questions to do with the theory however, I’m useless at
programing so I won’t be able to help at all there.
Best of luck and thanks.