#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Subroutine predictor corrector

Posts: 3Member
Hello everyone!!! I'm writing because I should write this subroutine:

Given the Cauchy problem

[img=http://s22.postimg.org/y2vo838hd/Senza_titolo_3.jpg]

write a subroutine for the calculation of its solution using the predictor corrector method in 5 steps (k = 4), according to the PECE scheme, with fixed step.

for the initiation values use the Matlab routine ode45.

So, I have this program but I need of to do some tests but I don't understand what kind of functions I should use...so, you can give me an example of tests that can I do? This is the program:

[code]
% The function calculates the solution of the Cauchy problem
% y'=f(t,y)
% y()=y0

% takes as input a function, the initial condition, the extremes of the %integration interval and the width of interval

function [t,y]=pece(fty,y0,x0,xn,h)
t=0;
p=(xn-x0)/h;
n=length(y0);
for i=1:p+1
t(i)=x0+(i-1)*h;

y=zeros(1,n);
f=zeros(3,n);

for i=1:4
f(i,:)=feval(fty,t(i),y0);
[t0,m_i]=ode45(fty,[t(1) t(2) t(3) t(4)],y0);

y(1:4,:)=m_i(1:4,:);

mi=m_i(4,:);
for i = 4:p
fnew= feval (fty, t0(4), mi);
m_i0=mi+(h/24)*(55*fnew-59*f(3,:)+37*f(2,:)-9*f(1,:));
f_i0= feval (fty, t0(4)+h, m_i0);
mi= mi+(h/24)*(9*f_i0+19*fnew-5*f(3,:)+f(2,:));
f(1,:) = f(2,:);
f(2,:) = f(3,:);
f(3,:) = fnew;
t0 = t0 + h;
y(i+1,:)= mi;
end

end

[/code]

Sorry for my mistakes...but I am Italian!!!! Thanks in advance!!!!
· ·
Sign In or Register to comment.