2 Stage, Order 3 IRK

100 Views Asked by At

Looking for a program for this method. Any suggestions on where I can find one? The tableau for this method is,

                          0| 1/4  -1/4
                        2/3| 1/4  5/12
                         --------------
                           | 1/4  3/4

Trying to solve $y'=y ; y(0)=1$ Also trying to figure out how many time steps are necessary to get an error at t=1 of < $10^{-5}$ and how many (f) function evaluations are necessary.

As for the time step question after using taylor expansion I get the following error term: $$1/72h^4+O(h^5)$$ Can I use this to find the number of steps or will I need the program for this? As for the function evaluations I really have no idea where to start. Help please.

1

There are 1 best solutions below

0
On BEST ANSWER

Figured it out!

function  IRK(t0, tf, h)

y(1)=1;
t=t0:h:tf;

for i=1:length(t)-1

syms z1 z2
eqn1 = (1-h/4)*z1+h/4*z2==y(i);
eqn2 =(-1)*h/4*z1+(1-5/12*h)*z2==y(i);
zsol = solve([eqn1,eqn2], [z1,z2]);  
y(i+1)=y(i)+h/4*(zsol.z1+3*zsol.z2);
end

abs(y(i+1)-exp(1))

So 0.125 as the step size gets closest to the error being $10^{-5}$ . As for the function evaluations I know that each stage of the RK method has two, so 32 all together....But should I include the actual method as two more f evaluations??? I suppose not since the method uses the results from solving the system for each z1...